-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LEGG.tcl
57 lines (51 loc) · 1.61 KB
/
LEGG.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Script "Listen Eggdrop"
# Ecoute sur un port proteger par un password
# transmet des messages vers un salon IRC
# URL https://github.com/ZarTek-Creole/PHP-PRETIME
if { [info commands ::LEGG::uninstall] eq "::LEGG::uninstall" } { ::LEGG::uninstall }
namespace eval ::LEGG {
array set CONF {
"port" "6666"
"channel" "#ZarTek-Creole"
"password" "MyPasswordLEgg"
}
array set SCRIPT {
"name" "Listen Eggdrop"
"version" "0.0.1"
"auteur" "ZarTek-Creole"
}
}
proc ::LEGG::CORE {idx args} {
putlog "LEGG: -> $args"
set arg [join $args]
set password [lindex $arg 0]
set message [lrange $arg 1 end]
variable CONF
if { ![string match ${password} ${CONF(password)}] } {
set message_error "Bad password!"
putlog "LEGG: $message_error"
putdcc $idx "$message_error"
killdcc ${idx}
return
}
putnow "PRIVMSG ${CONF(channel)} :$message"
killdcc ${idx}
}
proc ::LEGG::slisten { idx } {
putlog "LEGG: Connection $idx"
putdcc $idx "LEGG: Welcome"
control ${idx} ::LEGG::CORE
}
proc ::LEGG::init { } {
variable CONF
listen ${CONF(port)} script ::LEGG::slisten
putlog [format "Chargement de LEGG (%s) version %s by %s" ${::LEGG::SCRIPT(name)} ${::LEGG::SCRIPT(version)} ${::LEGG::SCRIPT(auteur)}]
}
proc ::LEGG::uninstall { args } {
putlog [format "Désallocation des ressources de \002%s\002..." ${::LEGG::SCRIPT(name)}];
foreach binding [lsearch -inline -all -regexp [binds *[set ns [string range [namespace current] 2 end]]*] " \{?(::)?${ns}"] {
unbind [lindex ${binding} 0] [lindex ${binding} 1] [lindex ${binding} 2] [lindex ${binding} 4];
}
namespace delete ::LEGG
}
::LEGG::init