######################################################################
### Scripts pour relier AideBot, #Aide et aide.igt.net/canal & co. ###
######################################################################
proc cw_net {text} {
regsub -all {<} $text {\<} text
regsub -all {>} $text {\>} text
return $text
}
proc cw_liste {} {
foreach user [chanlist #aide] {
if [isop $user #aide] {
lappend liste "@$user
"
}
}
foreach user [chanlist #aide] {
if [isvoice $user #aide] {
if ![isop $user #aide] {
lappend liste "+$user
"
}
}
}
foreach user [chanlist #aide] {
if {![isop $user #aide] & ![isvoice $user #aide]} {
lappend liste "$user
"
}
}
set ftmp [open "/aide/www/canal/liste.tmp" w]
puts $ftmp "
"
if ![info exist liste] {
set liste "-Néant-"
}
foreach user $liste {
puts $ftmp $user
}
puts $ftmp "
"
close $ftmp
exec /bin/mv /aide/www/canal/liste.tmp /aide/www/canal/liste.htm
}
bind pubm - #aide* pubm_aide
proc pubm_aide {nick host hand chan text} {
set text [cw_net $text]
canalweb_ajout "1<$nick> $text
"
}
bind ctcp - action cw_ctcpaction
proc cw_ctcpaction {nick host hand dest key text} {
set text [cw_net $text]
canalweb_ajout "6* $nick $text
"
}
bind notc - * cw_notc
proc cw_notc {nick host hand text dest} {
set text [cw_net $text]
if {[string tolower $dest] == "#aide"} {
canalweb_ajout "5-$nick:#Aide\- $text
"
}
}
bind join - #aide* cw_join
proc cw_join {nick host hand chan} {
canalweb_ajout "3*** Joins: $nick ($host)
"
cw_liste
}
bind part - #aide* cw_part
proc cw_part {nick host hand chan msg} {
if {[lindex $msg 0] == ""} {
canalweb_ajout "3*** Part: $nick ($host)
"
} else {
set msg [cw_net $msg]
canalweb_ajout "3*** Part: $nick ($host) ($msg3)
"
}
cw_liste
}
bind sign - #aide* cw_sign
proc cw_sign {nick host hand chan msg} {
if {[lindex $msg 0] == ""} {
canalweb_ajout "2*** Quits: $nick ($host)
"
} else {
set msg [cw_net $msg]
canalweb_ajout "2*** Quits: $nick ($host) ($msg2)
"
}
cw_liste
}
bind nick - #aide* cw_nick
proc cw_nick {nick host hand chan newnick} {
canalweb_ajout "3*** Part: $nick is now know as $newnick
"
cw_liste
}
bind mode - #aide* cw_mode
proc cw_mode {nick host hand chan mode victim} {
canalweb_ajout "3*** $nick sets mode: $mode $victim
"
cw_liste
}
bind kick - #aide* cw_kick
proc cw_kick {nick host hand chan target msg} {
if {[lindex $msg 0] == ""} {
canalweb_ajout "3*** $target was kick by $nick
"
} else {
set msg [cw_net $msg]
canalweb_ajout "3*** $target was kick by $nick ($msg3)
"
}
cw_liste
}
proc cw_gras_soul_coul {ligne} {
lappend paires " B"
lappend paires " U"
foreach paire $paires {
set M [lindex $paire 0]
set H [lindex $paire 1]
if [regsub $M $ligne "<$H>" ligne] {
regsub $M $ligne "$H>" ligne
if [regsub $M $ligne "<$H>" ligne] {
regsub $M $ligne "$H>" ligne
if [regsub $M $ligne "<$H>" ligne] {
regsub $M $ligne "$H>" ligne
if [regsub $M $ligne "<$H>" ligne] {
regsub $M $ligne "$H>" ligne
if [regsub $M $ligne "<$H>" ligne] {
regsub -all $M $ligne "$H>" ligne
} } } } }
}
regsub -all {} $ligne "" ligne
regsub -all {15} $ligne "" ligne
regsub -all {14} $ligne "" ligne
regsub -all {13} $ligne "" ligne
regsub -all {12} $ligne "" ligne
regsub -all {11} $ligne "" ligne
regsub -all {10} $ligne "" ligne
regsub -all {9} $ligne "" ligne
regsub -all {8} $ligne "" ligne
regsub -all {7} $ligne "" ligne
regsub -all {6} $ligne "" ligne
regsub -all {5} $ligne "" ligne
regsub -all {4} $ligne "" ligne
regsub -all {3} $ligne "" ligne
regsub -all {2} $ligne "" ligne
regsub -all {1} $ligne "" ligne
regsub -all {0} $ligne "" ligne
regsub -all {} $ligne "" ligne
return $ligne
}
proc canalweb_ajout {ligne} {
ajout_commun_web "/aide/www/canal/canal" $ligne ""
set ftmp [open "/aide/www/canal/index.tmp" w]
puts $ftmp "#Aide \[[llength [chanlist #aide]]\] \[[getchanmode #aide]\]: [topic #aide .]"
puts $ftmp ""
close $ftmp
exec /bin/mv /aide/www/canal/index.tmp /aide/www/canal/index.htm
}
proc ajout_commun_web {fichier ligne refresh} {
set ligne [cw_gras_soul_coul $ligne]
set ligne "$ligne"
exec /bin/cp $fichier\.htm $fichier\.bak
set ftmp [open "$fichier\.tmp" w]
set f [open "$fichier\.bak" r]
puts $ftmp "$refresh"
set moinslapremiereligne [gets $f]
set moinslapremiereligne [gets $f]
for {set i 1} {$i < 50} {incr i} {
puts $ftmp [gets $f]
}
puts $ftmp $ligne
puts $ftmp ""
close $f
close $ftmp
exec /bin/mv $fichier\.tmp $fichier\.htm
}
### Le bot asteur!
bind chat - * cw_chat
proc cw_chat {hand chan txt} {
if {$chan != 0} {return 0}
set txt [cw_net $txt]
set ligne "<AideBot> <$hand> $txt
"
ajout_commun_web "/aide/www/admins/aidebot/bot" $ligne ""
}
utimer 30 ecbot_timer
proc ecbot_timer {} {
if [string match *ecbot_timer* [utimers]] { return 0 }
utimer 5 ecbot_timer
set fichier "/aide/www/admins/aidebot/bla.txt"
set f [open $fichier r]
while {[gets $f line] >= 0} {
foreach user [whom 0] {
putdcc [hand2idx [lindex $user 0]] $line
}
set ligne "<AideBot> \[[string range $line 1 [expr [string length [lindex $line 0]] - 2]]\] [lrange $line 1 end]
"
ajout_commun_web "/aide/www/admins/aidebot/bot" $ligne ""
}
close $f
set f [open $fichier w]
close $f
}