Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3938353
MediaWiki.tcl
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
MediaWiki.tcl
View Options
# .tcl source scripts/Daeghrefn/MediaWiki.tcl
#
# MediaWiki RC
#
#
# Configuration
#
set
MediaWikiRC
(
source
)
127.0
.0.1
set
MediaWikiRC
(
port
)
8676
set
MediaWikiRC
(
channel
)
#
wolfplex
set
MediaWikiRC
(
color
)
0
set
MediaWikiRC
(
warnKnownEditorsChanges
)
0
# This code implements "A simple UDP server"
# sample from http://tcludp.sourceforge.net/
package
require udp
#Gets editor
proc
get_editor
{
message
}
{
set
message
[
stripcodes
abcgru
$message
]
regexp
"\\* (.*?) \\*"
$message
match0 match1
if
{
!
[
info
exists match1
]}
{
return
""
}
return
$match1
}
#Checks if editor is known
proc
is_known_editor
{
editor
}
{
expr
{
$editor
==
"Dereckson"
||
$editor
==
"Spike"
}
}
#Handles UDP event from $sock
proc
mediawiki_rc_udp_event_handler
{
sock
}
{
global
MediaWikiRC
set
pkt
[
read
$sock
]
set
peer
[
fconfigure
$sock
-
peer
]
#Check if peer is source IP to avoid flood
if
{[
string
range
$peer
0
[
string
length
$MediaWikiRC
(
source
)]
-
1
]
==
$MediaWikiRC
(
source
)}
{
#putdebug "Received on udp: $pkt"
#putdebug "Editor: [get_editor $pkt]"
if
{
$MediaWikiRC
(
warnKnownEditorsChanges
)
||
!
[
is_known_editor
[
get_editor
$pkt
]]}
{
if
$MediaWikiRC
(
color
)
{
puthelp
"PRIVMSG $MediaWikiRC(channel) :$pkt"
}
{
puthelp
"PRIVMSG $MediaWikiRC(channel) :[stripcodes abcgru $pkt]"
}
}
}
{
putdebug
"$peer: [string length $pkt] {$pkt}"
}
return
}
#Listens UDP on $port
proc
mediawiki_rc_udp_listen
{
port
}
{
set
srv
[
udp_open
$port
]
putdebug
"UDP connection on port $port: $srv"
fconfigure
$srv
-
buffering none
-
translation binary
fileevent
$srv
readable
[
list
::
mediawiki_rc_udp_event_handler
$srv
]
#putdebug "Listening on udp port: [fconfigure $srv -myport]"
return
$srv
}
mediawiki_rc_udp_listen
$MediaWikiRC
(
port
)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 26, 01:27 (5 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2314196
Default Alt Text
MediaWiki.tcl (1 KB)
Attached To
Mode
rVIPERSERV ViperServ scripts [legacy Mercurial repo]
Attached
Detach File
Event Timeline
Log In to Comment