rendered paste body# newoptoolz (30/09/2002) #
#################################################################################
# ___ ___ ___ ___ _____ #
# / /\ / /\ / /\ / /\ / /::\ #
# / /:/ / /::\ / /::\ / /::\ / /:/\:\ #
# /__/::\ / /:/\:\ / /:/\:\ / /:/\:\ / /:/ \:\ #
# \__\/\:\ / /:/~/::\ / /:/~/:/ / /:/ \:\ /__/:/ \__\:| #
# \ \:\ /__/:/ /:/\:\ /__/:/ /:/___ /__/:/ \__\:\ \ \:\ / /:/ #
# \__\:\ \ \:\/:/__\/ \ \:\/:::::/ \ \:\ / /:/ \ \:\ /:/ #
# / /:/ \ \::/ \ \::/~~~~ \ \:\ /:/ \ \:\/:/ #
# /__/:/ \ \:\ \ \:\ \ \:\/:/ \ \::/ #
# \__\/ \ \:\ \ \:\ \ \::/ \__\/ #
# \__\/ \__\/ \__\/ #
# #
# #
# ___ #
# ___ / /\ #
# / /\ / /:/ #
# / /:/ / /:/ ___ ___ #
# / /:/ / /:/ ___ /__/\ / /\ #
# / /::\ /__/:/ / /\ \ \:\ / /:/ #
# /__/:/\:\ \ \:\ / /:/ \ \:\ /:/ #
# \__\/ \:\ \ \:\ /:/ \ \:\/:/ #
# \ \:\ \ \:\/:/ \ \::/ #
# \__\/ \ \::/ \__\/ #
# \__\/ #
# #
# #
# web : http://tcl.lagon-bleu.org #
# mail : jarod_angel@yahoo.fr #
# IRC : Jarod_@IRCNet #buffy #
# Asco@UNDERNet #tyranz #
# #
#################################################################################
# #
# NEWOPTOOLZ.tcl est un script de commande sur channel. Le premier argument #
# est le nick du bot ! #
# ATTENTION ! Ce TCL requiert AUTH.TCL ! #
# #
Commandes : #
botnick op [<nick>] : s'op ou op nick #
botnick deop [<nick>] : se deop ou deop quelqu'un #
botnick whois <nick> : donne l'handle et les flags de nick #
botnick kick <nick|mask|*> : kick le nick/mask specifie #
botnick voice [<nick>] : se voice ou voice quelqu'un #
botnick devoice [<nick>] : se devoice ou devoice quelqu'un #
botnick add user <handle> <host> : ajoute un user avec l'host donné #
botnick add op <nick> [<host>] : ajoute cet user en +fo pour le channel #
botnick add owner <nick> [<host>] : ajoute cet user en +fnmo pour le channel #
botnick del user <handle> : efface cet user (faut etre +n global) #
botnick topic <topic> : change le topic #
botnick join <chan> [<pass_chan>] : join le channel specifie #
botnick remove [<chan>] : efface le channel de la memoire du bot #
botnick mode <mode> : change le mode du channel #
botnick deban <host> : deban <host> du bot pour le channel #
botnick cycle : cycle du bot #
botnick boum <nick> : desactive ces commandes pour l'user donne #
botnick deboum <nick> : reactive les commandes #
botnick chattr <handle> <flags> [<chan>] : modifie les flags de l'user #
# #
# J'ai ajoute aussi des commandes globales a tous les bots : #
# !kick <nick|mask|*> : kick le nick/mask specifie #
# !unban <host> : deban <host> pour le channel dans ts les bots #
# !join <chan> [<pass_du_chan>] : join le channel specifie #
# !remove [<chan>] : efface le channel de la memoire des bots #
# !del user|host <hand> [<host>]: efface un user #
# !chattr <handle> <flags> : modifie les flags d'un user #
# !cycle : cycle des bots #
# !boum <nick> : desactive ttes les commandes chan pour l'user #
# !deboum <nick> : reactive les commandes #
# !add user|op|owner|host <nick> [<host>] : ajoute un user/op/owner sur un chan #
# #
#################################################################################
##### CONFIGURATION #####
### personnes qui possedent ce flag ne seront pas kickees (sauf si c un autre +n qui le demande)
set no_flags_kick "nm"
### Ci dessous mettre entre guillemets le trigger ... par défaut c le nick du bot...
### Cepdt il faut savoir que parfois cela ne fonctionne pas et que l'on est obligé
### d'effectuer un .rehash dans le bot pour que le TCL soit pris en compte (idem si le bot
### venait à changer de nick)
set botcmde "Purple_Haze"
set botcmde $botnick
### Indiquer le nom et le repertoire de auth.tcl (par défaut le fichier "auth.tcl" est mis dans le repertoire "scripts")
set loadauth "scripts/auth.tcl"
##### FIN DE LA CONFIGURATION #####
##### DEBUT DU PROGRAMME #####
### Verifie la presence de auth.tcl
if {![file exists $loadauth]} {
putlog "\002 \037/!\\ ATTENTION VOUS N'AVEZ PAS AUTH.TCL ! CE SCRIPT NE POURRA DONC PAS MARCHER CORRECTEMENT !! /!\\ \002"
}
bind pub o|o $botcmde pub_cmde
bind pub o|o !kick pub_kick
bind pub o|o !deban pub_deban
bind pub o|o !unban pub_deban
bind pub n|n !add pub_newadd
bind pub n|n !del pub_newdel
bind pub n|n !chattr pub_newchattr
bind pub n !join pub_join
bind pub n !remove pub_remove
bind pub n|n !cycle pub_cycle
bind pub n|n !boum pub_boum
bind pub n|n !deboum pub_deboum
### $botnick op/deop/voice/devoice/topic/kick/unban/cycle/whois/join/remove/add/del/boum/deboum/mode [arguments]
proc pub_cmde {nick host hand chan arg} {
global botnick botcmde
set arg [charfilter $arg]
set cmd [lindex $arg 0]
set listecmd { {op} {deop} {add} {del} {voice} {devoice} {chattr} {deban} {unban} {mode} {topic} {kick} {cycle} {whois} {join} {remove} {add} {del} {boum} {deboum} }
if {[lsearch $listecmd "[lindex $cmd 0]"] == -1} {
return 0
}
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $host]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botcmde auth <password>\002"
return 0
}
switch -exact $cmd {
"op" {
set opnick [lrange $arg 1 3]
if {[botisop $chan]} {
if {$opnick == ""} {
pushmode $chan +o $nick
set opnick $nick
} else {
putserv "mode $chan +ooo $opnick"
}
} else {
puthelp "NOTICE $nick :Desole, mais je ne suis pas op sur $chan !"
}
putlog "#NEWOPTOOLZ# ($hand) OP de '$opnick' sur $chan"
return 0
}
"deop" {
set deopnick [lrange $arg 1 3]
if {[botisop $chan]} {
if {$deopnick == ""} {
pushmode $chan -o $nick
set deopnick $nick
} else {
putserv "mode $chan -ooo $deopnick"
}
} else {
puthelp "NOTICE $nick :Desole, mais je ne suis pas op sur $chan !"
}
putlog "#NEWOPTOOLZ# ($hand) DEOP de '$deopnick' sur $chan"
return 0
}
"whois" {
if {[llength $arg] != 2} {
puthelp "NOTICE $nick :\002Usage:\002 $botcmde whois <nick>"
return 0
}
set who [lindex $arg 1]
set handle [nick2hand $who $chan]
set host2 [getchanhost $who $chan]
if {$handle == "*"} {
puthelp "NOTICE $nick : $who n'est pas enregistre dans le bot !"
return 0
}
if {$handle != ""} {
puthelp "NOTICE $nick : Le hand de \002$who\002 est \002$handle\002. "
puthelp "NOTICE $nick : L'host actuel de \002$who\002 est \002$host2\002. "
set globalflags [lindex [split [chattr $handle - ] |] 0]
if {$globalflags == "-"} {set globalflags "no flags"}
if {$chan != ""} {
set chanflags [lindex [split [chattr $handle - $chan] |] 1]
if {$chanflags == "-"} {set chanflags "no flags"}
puthelp "NOTICE $nick :et ces global flags: \002$globalflags\002. "
puthelp "NOTICE $nick :$who a ces flags sur $chan: \002$chanflags\002 "
} else {
puthelp "NOTICE $nick :Il a ces global flags: \002$globalflags\002 "
}
} else {
puthelp "NOTICE $nick :Je ne vois pas $who."
return 0
}
putlog "#NEWOPTOOLZ# ($hand) WHOIS sur '$who' sur $chan"
return 0
}
"deban" {
set host [lindex $arg 1]
if {$host == ""} {
puthelp "NOTICE $nick :\002Usage:\002 $botcmde deban <host>"
return 0
}
if {[killchanban $chan $host]} {
puthelp "NOTICE $nick : Le ban sur $host a ete supprime de ma memoire"
putlog "#NEWOPTOOLZ# ($hand) DEBAN de '$host' sur $chan"
save
return 0
}
puthelp "NOTICE $nick : $host n'est pas reconnu comme un ban channel valide !"
return 0
}
"unban" {
set host [lindex $arg 1]
if {$host == ""} {
puthelp "NOTICE $nick :\002Usage:\002 $botcmde deban <host>"
return 0
}
if {[killchanban $chan $host]} {
puthelp "NOTICE $nick : Le ban sur $host a ete supprime de ma memoire"
putlog "#NEWOPTOOLZ# ($hand) DEBAN de '$host' sur $chan"
save
return 0
}
puthelp "NOTICE $nick : $host n'est pas reconnu comme un ban channel valide !"
return 0
}
"kick" {
global no_flags_kick
if {[lindex $arg 1] == ""} {
puthelp "NOTICE $nick :\002Usage:\002 $botcmde kick <nick|mask> \[reason\]"
return 0
}
set who [lindex $arg 1]
set reason [lrange $arg 2 end]
if {$reason == ""} {set reason "requested"}
if {![botisop $chan]} {
puthelp "NOTICE $nick :Desole, je ne suis pas operateur sur $chan."
return 0
}
if {[matchattr [nick2hand $who] m] && ![matchattr $hand m]} {
puthelp "NOTICE $nick :Desole mais $who est mon maitre !"
return 0
}
if {[string first "*" $who] != -1 || [string first "?" $who] != -1} {
if {$reason == "requested"} {set reason "MaskKick: $who"}
if {![matchattr $hand o|o $chan]} {
puthelp "NOTICE $nick :Tu as besoin d'être user-op pour utiliser le mask kick."
return 0
}
set who [strlwr $who]
set kickcount 0
set flags "-$no_flags_kick&-$no_flags_kick"
if {$no_flags_kick == ""} {
set list [strlwr [chanlist $chan]]
} {
set list [strlwr [chanlist $chan $flags]]
}
foreach chanuser $list {
if {[string match $who $chanuser] && $chanuser != [strlwr $botcmde] && $chanuser != [strlwr $nick] && ![isop $chanuser $chan] && ![isvoice $chanuser $chan]} {
incr kickcount
putserv "KICK $chan $chanuser :$nick: $reason"
putlog "#NEWOPTOOLZ# ($hand) KICK de '$chanuser' sur $chan"
}
}
if {!$kickcount} {
puthelp "NOTICE $nick :Desole mais personne ne porte ce mask !"
}
} {
if {![onchan $who $chan]} {
puthelp "NOTICE $nick :Desole, mais je ne trouve pas $who sur $chan."
return 0
}
if {[strlwr $who] == [strlwr $botnick]} {
puthelp "NOTICE $nick :Yeah right, like I'm going to let you kick ME!"
return 0
}
if {[nick2hand $who $chan] != "*"} {
if {$hand != [nick2hand $who $chan]} {
if {([matchattr [nick2hand $who $chan] o|o $chan] && ![matchattr $hand o|o $chan])} {
puthelp "NOTICE $nick :Sorry, you must to be an operator to kick an operator."
return 0
}
if {(([matchattr [nick2hand $who $chan] m|m $chan] || [matchattr [nick2hand $who $chan] b]) && ![matchattr $hand m|m $chan])} {
puthelp "NOTICE $nick :Sorry, you must to be a master to kick a master or a bot."
return 0
}
}
}
putserv "KICK $chan $who :$nick: $reason"
return 0
}
}
"voice" {
set vnick [lrange $arg 1 3]
if {[botisop $chan]} {
if {$vnick == ""} {
pushmode $chan +v $nick
set vnick $nick
} else {
putserv "mode $chan +vvv $vnick"
}
} else {
puthelp "NOTICE $nick :Desole, mais je ne suis pas op sur $chan !"
}
putlog "#NEWOPTOOLZ# ($hand) VOICE de '$vnick' sur $chan"
return 0
}
"devoice" {
set dvnick [lrange $arg 1 3]
if {[botisop $chan]} {
if {$dvnick == ""} {
pushmode $chan -v $nick
set dvnick $nick
} else {
putserv "mode $chan -vvv $dvnick"
}
} else {
puthelp "NOTICE $nick :Desole, mais je ne suis pas op sur $chan !"
}
putlog "#NEWOPTOOLZ# ($hand) DEVOICE de '$dvnick' sur $chan"
return 0
}
"topic" {
if {[lindex $arg 1] == ""} {
puthelp "NOTICE $nick :\002Usage\002: $botcmde topic <topic>"
return 0
}
if {![botisop $chan]} {
puthelp "NOTICE $nick :Desole, je ne suis pas operateur sur $chan."
return 0
}
set topic [lrange $arg 1 end]
puthelp "TOPIC $chan :$topic"
putlog "#NEWOPTOOLZ# ($hand) TOPIC '$topic' sur $chan"
return 0
}
"remove" {
if {[matchattr $hand n]} {
set ch [lindex $arg 1]
if {$ch == ""} {set ch $chan}
if {(![validchan $ch] && ![isdynamic $ch])} {
puthelp "NOTICE $nick :Je ne suis pas sur $ch "
} else {
channel remove $ch
puthelp "NOTICE $nick :$ch a ete supprime de ma memoire."
putlog "#NEWOPTOOLZ# ($hand) REMOVE du channel '$ch' sur $chan"
}
} else {
puthelp "NOTICE $nick :Desole, il faut être mon owner global pour pouvoir supprimer un channel !"
}
return 0
}
"join" {
if {[matchattr $hand n]} {
set jchan [lindex $arg 1]
set pass [lindex $arg 2]
if {$jchan == ""} {
puthelp "NOTICE $nick :\002Usage:\002 $botcmde join <chan> \[chan pass\]"
return 0
}
if {([validchan $jchan] || [isdynamic $jchan])} {
if {![onchan $botnick $jchan]} {
putserv "JOIN $jchan $pass"
} else {
puthelp "NOTICE $nick :Je suis deja sur $jchan."
}
} else {
channel add $jchan
putserv "JOIN $jchan $pass"
puthelp "NOTICE $nick :Nouveau chan : $jchan."
putlog "#NEWOPTOOLZ# ($hand) JOIN du channel '$jchan' sur $chan"
}
return 0
}
puthelp "NOTICE $nick :Desole, il faut être mon owner global pour pouvoir me faire joindre un channel !"
return 0
}
"add" {
switch -exact [lindex $arg 1] {
"user" {
if {[matchattr $hand n]} {
set handuser [lindex $arg 2]
set hostuser [lindex $arg 3]
if {($handuser == "") || ($hostuser == "")} {
puthelp "notice $nick :Commande : \002$botcmde add user <handle> <host>\002"
return 0
}
if {![adduser $handuser $hostuser]} {
puthelp "notice $nick :Impossible d'ajouter le user $handuser ($hostuser) !"
} else {
puthelp "notice $nick :User \002$handuser\002 a été ajouté avec l'host \[ \002$hostuser\002 \]"
save
putlog "#NEWOPTOOLZ# ($hand) ADD USER '$handuser ($hostuser)' sur $chan"
}
return 0
}
puthelp "notice $nick :Désolé, il faut etre owner global pour utiliser cette commande."
return 0
}
"host" {
if {([matchattr $hand |o $chan]) || ([matchattr $hand o])} {
set handuser [lindex $arg 2]
set hostuser [lindex $arg 3]
if {$handuser == ""} {
puthelp "notice $nick :Commande : \002$botcmde add host <handle> <host>\002"
return 0
}
if {![validuser $handuser]} {
puthelp "notice $nick :\002$handuser\002 n'existe pas !"
} else {
setuser $handuser HOSTS $hostuser
puthelp "notice $nick :HOST \002$hostuser\002 ajouté pour \002$handuser\002"
save
putlog "#NEWOPTOOLZ# ($hand) ADD HOST '$handuser ($hostuser)' sur $chan"
}
return 0
}
puthelp "notice $nick :Désolé, il faut etre op de $chan pour utiliser cette commande."
return 0
}
"op" {
if {([matchattr $hand |n $chan]) || ([matchattr $hand n])} {
set handuser [lindex $arg 2]
set hostuser [lindex $arg 3]
if {$handuser == ""} {
puthelp "notice $nick :Commande : \002$botcmde add op <nick> \[<host>\]\002"
return 0
}
if {[validuser $handuser]} {
puthelp "notice $nick :\002$handuser\002 existe déjà, je lui met donc les flags +fo pour le channel $chan !"
chattr $handuser +p|+fo $chan
putlog "#NEWOPTOOLZ# ($hand) ADD OP '$handuser ($hostuser)' sur $chan"
return 0
}
if {$hostuser == ""} {
set hostuser [getchanhost $handuser $chan]
if {$hostuser == ""} {
puthelp "notice $nick :Désolé je ne trouve pas $handuser sur $chan !"
return 0
}
set hostuser "$handuser!*$hostuser"
}
if {([string index $hostuser 0] == "*") && ([string index $hostuser 1] == "!")} {
set hostuser "$handuser![string range $hostuser 2 end]"
}
set hostuser [maskhost $hostuser]
if {![adduser $handuser $hostuser]} {
puthelp "notice $nick :Impossible d'ajouter le user $handuser ($hostuser) !"
return 0
}
puthelp "notice $nick :OP \002$handuser\002 a été ajouté avec l'host \[ \002$hostuser\002 \] pour le channel $chan"
chattr $handuser +p|+fo $chan
putlog "#NEWOPTOOLZ# ($hand) ADD OP '$handuser ($hostuser)' sur $chan"
save
} else {
puthelp "notice $nick :Désolé, il faut etre owner de $chan pour utiliser cette commande."
}
return 0
}
"owner" {
if {[matchattr $hand n]} {
set handuser [lindex $arg 2]
set hostuser [lindex $arg 3]
if {$handuser == ""} {
puthelp "notice $nick :Commande : \002$botcmde add owner <nick> \[<host>\]\002"
return 0
}
if {[validuser $handuser]} {
puthelp "notice $nick :\002$handuser\002 existe déjà, je lui met donc les flags +mnof pour le channel $chan !"
chattr $handuser +p|+fonm $chan
putlog "#NEWOPTOOLZ# ($hand) ADD OWNER '$handuser ($hostuser)' sur $chan"
return 0
}
if {$hostuser == ""} {
set hostuser [getchanhost $handuser $chan]
if {$hostuser == ""} {
puthelp "notice $nick :Désolé je ne trouve pas $handuser sur $chan !"
return 0
}
set hostuser "$handuser!*$hostuser"
}
if {([string index $hostuser 0] == "*") && ([string index $hostuser 1] == "!")} {
set hostuser "$handuser![string range $hostuser 2 end]"
}
set hostuser [maskhost $hostuser]
if {![adduser $handuser $hostuser]} {
puthelp "notice $nick :Impossible d'ajouter le user $handuser ($hostuser) !"
return 0
}
puthelp "notice $nick :OWNER \002$handuser\002 a été ajouté avec l'host \[ \002$hostuser\002 \] pour le channel $chan"
chattr $handuser +p|+fomn $chan
putlog "#NEWOPTOOLZ# ($hand) ADD OWNER '$handuser ($hostuser)' sur $chan"
save
} else {
puthelp "notice $nick :Désolé, il faut etre owner global pour utiliser cette commande."
}
return 0
}
"default" {
puthelp "notice $nick :Commande :\002$botcmde add user/owner/op/host <nick> \[<host>\]"
return 0
}
}
}
"del" {
switch -exact [lindex $arg 1] {
"user" {
if {[matchattr $hand n]} {
set handuser [lindex $arg 2]
if {$handuser == ""} {
puthelp "notice $nick :Commande : \002$botcmde del user <handle>\002"
return 0
}
if {![deluser $handuser]} {
puthelp "notice $nick :Impossible de supprimer \002$handuser\002 !"
} else {
puthelp "notice $nick :User \002$handuser\002 a été supprimé !"
save
putlog "#NEWOPTOOLZ# ($hand) DEL USER '$handuser' sur $chan"
}
} else {
puthelp "notice $nick :Désolé, il faut etre owner global pour utiliser cette commande."
}
return 0
}
"host" {
if {([matchattr $hand |o $chan]) || ([matchattr $hand o])} {
set handuser [lindex $arg 2]
set hostuser [lindex $arg 3]
if {$handuser == ""} {
puthelp "notice $nick :Commande : \002$botcmde del host <handle> <host>\002"
return 0
}
if {![validuser $handuser]} {
puthelp "notice $nick :\002$handuser\002 n'existe pas !"
return 0
}
if {[delhost $handuser $hostuser]} {
puthelp "notice $nick :HOST \002$hostuser\002 effacé pour \002$handuser\002"
putlog "#NEWOPTOOLZ# ($hand) DEL HOST '$handuser ($hostuser)' sur $chan"
} else {
puthelp "notice $nick :Cet host n'existe pas pour cet user !"
}
save
} else {
puthelp "notice $nick :Désolé, il faut etre op de $chan pour utiliser cette commande."
}
return 0
}
}
}
"chattr" {
if {[matchattr $hand n]} {
set handuser [lindex $arg 1]
set flag [lindex $arg 2]
set chanflag [lindex $arg 3]
if {($handuser == "") || ($flag == "")} {
puthelp "notice $nick :Commande : \002$botcmde chattr <handle> <flags> \[<channel>\]\002"
return 0
}
if {[validuser $handuser]} {
if {$chanflag != ""} {
if {([validchan $chanflag] || [isdynamic $chanflag])} {
chattr $handuser -|$flag $chanflag
save
puthelp "notice $nick :Les flags \002$flag\002 ont été apporté à \002$handuser\002 pour le channel \002$chanflag\002"
putlog "#NEWOPTOOLZ# ($hand) CHATTR '$handuser ($flag $chan)' sur $chan"
return 0
}
puthelp "notice $nick :Désolé, mais $chanflag n'est pas un channel valide !"
return 0
}
chattr $handuser $flag
save
puthelp "notice $nick :Les flags \002$flag\002 ont été apporté à \002$handuser\002"
putlog "#NEWOPTOOLZ# ($hand) CHATTR '$handuser ($flag)' sur $chan"
} else {
puthelp "notice $nick :Désolé, je ne connais pas $handuser !"
}
return 0
}
if {[matchattr $hand -|n $chan]} {
set handuser [lindex $arg 1]
set flag [lindex $arg 2]
if {($handuser == "") || ($flag == "")} {
puthelp "notice $nick :Commande : \002$botcmde chattr <handle> <flags>\002"
return 0
}
if {[validuser $handuser]} {
for {set i 0} {$i < [string length $flag]} {incr i} {
if {[string index $flag $i] == "n"} {
puthelp "notice $nick :Désolé, mais tu ne peux pas mettre le flag \002+n\002 à quelqu'un d'autre !"
return 0
}
}
chattr $handuser -|$flag $chan
save
puthelp "notice $nick :Les flags \002$flag\002 ont été apporté à \002$handuser\002 pour le channel \002$chan\002"
putlog "#NEWOPTOOLZ# ($hand) CHATTR '$handuser ($flag $chan)' sur $chan"
return 0
}
puthelp "notice $nick :Désolé, je ne connais pas $handuser !"
} else {
puthelp "notice $nick :Désolé, tu n'as pas les flags suffisant pour utiliser cette commande !"
}
return 0
}
"boum" {
if {[matchattr $hand n]} {
set who [lindex $arg 1]
set whohand [nick2hand $who $chan]
if {$who == ""} {
puthelp "NOTICE $nick :\002Usage:\002 $botcmde boum <nick>"
return 0
}
if {![onchan $who $chan]} {
puthelp "NOTICE $nick :Desole, mais je ne trouve pas $who sur $chan."
return 0
}
if {[strlwr $who] == [strlwr $botnick]} {
puthelp "NOTICE $nick :I can't be disabled, my name is activator :)"
return 0
}
if {$whohand == "*"} {
puthelp "NOTICE $nick :Je ne reconnais pas $who comme un user."
return 0
}
if {[getuser $whohand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :$who est deja desactive."
return 0
}
setuser $whohand xtra auth DEAD
chattr $whohand -3
puthelp "NOTICE $nick :$who est maintenant desactive."
putlog "#NEWOPTOOLZ# ($hand) BOUM '$whohand' sur $chan"
} else {
puthelp "NOTICE $nick :Desole, il faut être mon owner global pour utiliser cette commande !"
}
return 0
}
"deboum" {
if {[matchattr $hand n]} {
set who [lindex $arg 1]
if {$who == ""} {
puthelp "NOTICE $nick :\002Usage:\002 $botcmde deboum <nick>"
return 0
}
set whohand [nick2hand $who $chan]
if {![onchan $who $chan]} {
puthelp "NOTICE $nick :Desole, mais je ne trouve pas $who sur $chan."
return 0
}
if {[strlwr $who] == [strlwr $botcmde]} {
puthelp "NOTICE $nick :I don't need to be enabled, my name is activator :)"
return 0
}
if {$whohand == "*"} {
puthelp "NOTICE $nick :Je ne reconnais pas $who comme un user."
return 0
}
if {[getuser $whohand xtra auth] != "DEAD"} {
puthelp "NOTICE $nick :$who est deja active."
return 0
}
setuser $whohand xtra auth 0
puthelp "NOTICE $nick :$who est maintenant reactive."
putlog "#NEWOPTOOLZ# ($hand) DEBOUM '$whohand' sur $chan"
} else {
puthelp "NOTICE $nick :Desole, il faut être mon owner global pour utiliser cette commande !"
}
return 0
}
"mode" {
set mode [lrange $arg 1 end]
if {$mode == ""} {
puthelp "NOTICE $nick :\002Usage:\002 $botcmde mode <chanmode>"
} else if {![botisop $chan]} {
puthelp "NOTICE $nick :Desole, je ne suis pas operateur sur $chan."
return 0
} else {
putserv "mode $chan $mode"
}
putlog "#NEWOPTOOLZ# ($hand) MODE '$mode' sur $chan"
return 0
}
"cycle" {
if {[matchattr $hand n|n $chan]} {
puthelp "NOTICE $nick :Cycle en cours pour $chan"
puthelp "PART $chan"
putlog "#NEWOPTOOLZ# ($hand) CYCLE sur $chan"
} else {
puthelp "NOTICE $nick :Desole, il faut être owner pour utiliser cette commande !"
}
return 0
}
"default" { return 0 }
return 0
}
}
### !ADD user/op/owner/host <nick> [host]
proc pub_newadd {nick host hand chan arg} {
global botnick
set listecmd { {op} {user} {host} {owner} }
if {[lsearch $listecmd "[lindex $arg 0]"] == -1} {
return 0
}
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $host]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botnick auth <password>\002"
return 0
}
switch -exact [lindex $arg 0] {
"user" {
if {[matchattr $hand n]} {
set handuser [lindex $arg 1]
set hostuser [lindex $arg 2]
if {($handuser == "") || ($hostuser == "")} {
puthelp "notice $nick :Commande : \002!add user <handle> <host>\002"
return 0
}
if {![adduser $handuser $hostuser]} {
puthelp "notice $nick :Impossible d'ajouter le user $handuser ($hostuser) !"
} else {
puthelp "notice $nick :User \002$handuser\002 a été ajouté avec l'host \[ \002$hostuser\002 \]"
save
putlog "#NEWOPTOOLZ# ($hand) ADD USER '$handuser ($hostuser)' sur $chan"
}
return 0
}
puthelp "notice $nick :Désolé, il faut etre owner global pour utiliser cette commande."
return 0
}
"host" {
if {([matchattr $hand |o $chan]) || ([matchattr $hand o])} {
set handuser [lindex $arg 1]
set hostuser [lindex $arg 2]
if {$handuser == ""} {
puthelp "notice $nick :Commande : \002!add host <handle> <host>\002"
return 0
}
if {![validuser $handuser]} {
puthelp "notice $nick :\002$handuser\002 n'existe pas !"
} else {
setuser $handuser HOSTS $hostuser
puthelp "notice $nick :HOST \002$hostuser\002 ajouté pour \002$handuser\002"
save
putlog "#NEWOPTOOLZ# ($hand) ADD HOST '$handuser ($hostuser)' sur $chan"
}
return 0
}
puthelp "notice $nick :Désolé, il faut etre op de $chan pour utiliser cette commande."
return 0
}
"op" {
if {([matchattr $hand |n $chan]) || ([matchattr $hand n])} {
set handuser [lindex $arg 1]
set hostuser [lindex $arg 2]
if {$handuser == ""} {
puthelp "notice $nick :Commande : \002!add op <nick> \[<host>\]\002"
return 0
}
if {[validuser $handuser]} {
puthelp "notice $nick :\002$handuser\002 existe déjà, je lui met donc les flags +fo pour le channel $chan !"
chattr $handuser +p|+fo $chan
putlog "#NEWOPTOOLZ# ($hand) ADD OP '$handuser ($hostuser)' sur $chan"
return 0
}
if {$hostuser == ""} {
set hostuser [getchanhost $handuser $chan]
if {$hostuser == ""} {
puthelp "notice $nick :Désolé je ne trouve pas $handuser sur $chan !"
return 0
}
set hostuser "$handuser!*$hostuser"
}
if {([string index $hostuser 0] == "*") && ([string index $hostuser 1] == "!")} {
set hostuser "$handuser![string range $hostuser 2 end]"
}
set hostuser [maskhost $hostuser]
if {![adduser $handuser $hostuser]} {
puthelp "notice $nick :Impossible d'ajouter le user $handuser ($hostuser) !"
return 0
}
puthelp "notice $nick :OP \002$handuser\002 a été ajouté avec l'host \[ \002$hostuser\002 \] pour le channel $chan"
chattr $handuser +p|+fo $chan
putlog "#NEWOPTOOLZ# ($hand) ADD OP '$handuser ($hostuser)' sur $chan"
save
} else {
puthelp "notice $nick :Désolé, il faut etre owner de $chan pour utiliser cette commande."
}
return 0
}
"owner" {
if {[matchattr $hand n]} {
set handuser [lindex $arg 1]
set hostuser [lindex $arg 2]
if {$handuser == ""} {
puthelp "notice $nick :Commande : \002!add owner <nick> \[<host>\]\002"
return 0
}
if {[validuser $handuser]} {
puthelp "notice $nick :\002$handuser\002 existe déjà, je lui met donc les flags +mnof pour le channel $chan !"
chattr $handuser +p|+fonm $chan
putlog "#NEWOPTOOLZ# ($hand) ADD OWNER '$handuser ($hostuser)' sur $chan"
return 0
}
if {$hostuser == ""} {
set hostuser [getchanhost $handuser $chan]
if {$hostuser == ""} {
puthelp "notice $nick :Désolé je ne trouve pas $handuser sur $chan !"
return 0
}
set hostuser "$handuser!*$hostuser"
}
if {([string index $hostuser 0] == "*") && ([string index $hostuser 1] == "!")} {
set hostuser "$handuser![string range $hostuser 2 end]"
}
set hostuser [maskhost $hostuser]
if {![adduser $handuser $hostuser]} {
puthelp "notice $nick :Impossible d'ajouter le user $handuser ($hostuser) !"
return 0
}
puthelp "notice $nick :OWNER \002$handuser\002 a été ajouté avec l'host \[ \002$hostuser\002 \] pour le channel $chan"
chattr $handuser +p|+fomn $chan
putlog "#NEWOPTOOLZ# ($hand) ADD OWNER '$handuser ($hostuser)' sur $chan"
save
} else {
puthelp "notice $nick :Désolé, il faut etre owner global pour utiliser cette commande."
}
return 0
}
"default" {
puthelp "notice $nick :Commande :\002!add user|owner|op <nick> \[<host>\]"
return 0
}
}
}
### !DEL USER/HOST <handle> [<host>]
proc pub_newdel {nick host hand chan arg} {
global botnick
set listecmd { {user} {host} }
if {[lsearch $listecmd "[lindex $arg 0]"] == -1} {
return 0
}
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $host]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botnick auth <password>\002"
return 0
}
switch -exact [lindex $arg 0] {
"user" {
if {[matchattr $hand n]} {
set handuser [lindex $arg 1]
if {$handuser == ""} {
puthelp "notice $nick :Commande : \002!del user <handle>\002"
return 0
}
if {![deluser $handuser]} {
puthelp "notice $nick :Impossible de supprimer \002$handuser\002 !"
} else {
puthelp "notice $nick :User \002$handuser\002 a été supprimé !"
save
putlog "#NEWOPTOOLZ# ($hand) DEL USER '$handuser' sur $chan"
}
} else {
puthelp "notice $nick :Désolé, il faut etre owner global pour utiliser cette commande."
}
return 0
}
"host" {
if {([matchattr $hand |o $chan]) || ([matchattr $hand o])} {
set handuser [lindex $arg 1]
set hostuser [lindex $arg 2]
if {$handuser == ""} {
puthelp "notice $nick :Commande : \002!del host <handle> <host>\002"
return 0
}
if {![validuser $handuser]} {
puthelp "notice $nick :\002$handuser\002 n'existe pas !"
return 0
}
if {[delhost $handuser $hostuser]} {
puthelp "notice $nick :HOST \002$hostuser\002 effacé pour \002$handuser\002"
putlog "#NEWOPTOOLZ# ($hand) DEL HOST '$handuser ($hostuser)' sur $chan"
} else {
puthelp "notice $nick :Cet host n'existe pas pour cet user !"
}
save
} else {
puthelp "notice $nick :Désolé, il faut etre op de $chan pour utiliser cette commande."
}
return 0
}
"default" {
puthelp "notice $nick :Commande : \002!del user <handle>\002"
return 0
}
}
}
### !CHATTR <handle> <flag> [<channel>]
proc pub_newchattr {nick host hand chan arg} {
global botnick
set hand [nick2hand $nick $chan]
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $host]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botnick auth <password>\002"
return 0
}
if {[lindex $arg 0] == ""} {
puthelp "notice $nick :Commande :\002!chattr <handle> <flag>"
return 0
}
if {[matchattr $hand n]} {
set handuser [lindex $arg 0]
set flag [lindex $arg 1]
set chanflag [lindex $arg 2]
if {($handuser == "") || ($flag == "")} {
puthelp "notice $nick :Commande : \002!chattr <handle> <flags> \[<channel>\]\002"
return 0
}
if {[validuser $handuser]} {
if {$chanflag != ""} {
if {([validchan $chanflag] || [isdynamic $chanflag])} {
chattr $handuser -|$flag $chanflag
save
puthelp "notice $nick :Les flags \002$flag\002 ont été apporté à \002$handuser\002 pour le channel \002$chanflag\002"
putlog "#NEWOPTOOLZ# ($hand) CHATTR '$handuser ($flag $chan)' sur $chan"
return 0
}
puthelp "notice $nick :Désolé, mais $chanflag n'est pas un channel valide !"
return 0
}
chattr $handuser $flag
save
puthelp "notice $nick :Les flags \002$flag\002 ont été apporté à \002$handuser\002"
putlog "#NEWOPTOOLZ# ($hand) CHATTR '$handuser ($flag)' sur $chan"
return 0
}
puthelp "notice $nick :Désolé, je ne connais pas $handuser !"
return 0
}
if {[matchattr $hand -|n $chan]} {
set handuser [lindex $arg 0]
set flag [lindex $arg 1]
if {($handuser == "") || ($flag == "")} {
puthelp "notice $nick :Commande : \002$botnick chattr <handle> <flags>\002"
return 0
}
if {[validuser $handuser]} {
for {set i 0} {$i < [string length $flag]} {incr i} {
if {[string index $flag $i] == "n"} {
puthelp "notice $nick :Désolé, mais tu ne peux pas mettre le flag \002+n\002 à quelqu'un d'autre !"
return 0
}
}
chattr $handuser -|$flag $chan
save
puthelp "notice $nick :Les flags \002$flag\002 ont été apporté à \002$handuser\002 pour le channel \002$chan\002"
putlog "#NEWOPTOOLZ# ($hand) CHATTR '$handuser ($flag $chan)' sur $chan"
return 0
}
puthelp "notice $nick :Désolé, je ne connais pas $handuser !"
return 0
}
puthelp "notice $nick :Désolé, tu n'as pas les flags suffisant pour utiliser cette commande !"
return 0
}
### !KICK <nick|mask> [reason]
proc pub_kick {nick host hand chan arg} {
set arg [charfilter $arg]
global botnick no_flags_kick
set hand [nick2hand $nick $chan]
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $host]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botnick auth <password>\002"
return 0
}
if {$arg == ""} {
puthelp "NOTICE $nick :\002Usage:\002 !kick <nick|mask> \[reason\]"
return 0
}
set who [lindex $arg 0]
set reason [lrange $arg 1 end]
if {$reason == ""} {set reason "requested"}
if {![botisop $chan]} {
puthelp "NOTICE $nick :Desole, je ne suis pas operateur sur $chan."
return 0
}
if {[matchattr [nick2hand $who] m] && ![matchattr $hand m]} {
puthelp "NOTICE $nick :Desole mais $who est mon maitre !"
return 0
}
if {[string first "*" $who] != -1 || [string first "?" $who] != -1} {
if {$reason == "requested"} {set reason "MaskKick: $who"}
if {![matchattr $hand o|o $chan]} {
puthelp "NOTICE $nick :Tu as besoin d'être op pour utiliser le mask kick."
return 0
}
set who [strlwr $who]
set kickcount 0
set flags "-$no_flags_kick&-$no_flags_kick"
if {$no_flags_kick == ""} {
set list [strlwr [chanlist $chan]]
} {
set list [strlwr [chanlist $chan $flags]]
}
foreach chanuser $list {
if {[string match $who $chanuser] && $chanuser != [strlwr $botnick] && $chanuser != [strlwr $nick] && ![isop $chanuser $chan] && ![isvoice $chanuser $chan]} {
incr kickcount
putserv "KICK $chan $chanuser :$nick: $reason"
putlog "#NEWOPTOOLZ# ($hand) KICK '$chanuser ($reason)' sur $chan"
}
}
if {!$kickcount} {
puthelp "NOTICE $nick :Desole mais personne ne porte ce mask !"
}
} {
if {![onchan $who $chan]} {
puthelp "NOTICE $nick :Desole, mais je ne trouve pas $who sur $chan."
return 0
}
if {[strlwr $who] == [strlwr $botnick]} {
puthelp "NOTICE $nick :Yeah right, like I'm going to let you kick ME!"
return 0
}
if {[nick2hand $who $chan] != "*"} {
if {$hand != [nick2hand $who $chan]} {
if {([matchattr [nick2hand $who $chan] o|o $chan] && ![matchattr $hand o|o $chan])} {
puthelp "NOTICE $nick :Sorry, you must to be an operator to kick an operator."
return 0
}
if {(([matchattr [nick2hand $who $chan] m|m $chan] || [matchattr [nick2hand $who $chan] b]) && ![matchattr $hand m|m $chan])} {
puthelp "NOTICE $nick :Sorry, you must to be a master to kick a master or a bot."
return 0
}
}
}
putserv "KICK $chan $who :$nick: $reason"
putlog "#NEWOPTOOLZ# ($hand) KICK '$who ($reason)' sur $chan"
return 0
}
}
### !JOIN <chan> [chan pass]
proc pub_join {nick host hand chan arg} {
set arg [charfilter $arg]
global botnick
set chan2 $chan
set hand [nick2hand $nick $chan]
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $host]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botnick auth <password>\002"
return 0
}
set botnick2 [strlwr $botnick]
set chan [lindex $arg 0]
set pass [lindex $arg 1]
if {$chan == ""} {
puthelp "NOTICE $nick :\002Usage:\002 !join <chan> \[chan pass\]"
return 0
}
if {([validchan $chan] || [isdynamic $chan])} {
if {![onchan $botnick2 $chan]} {
putserv "JOIN $chan $pass"
return 0
}
puthelp "NOTICE $nick :Je suis deja sur $chan."
return 0
}
puthelp "NOTICE $nick :Nouveau chan : $chan."
channel add $chan
putserv "JOIN $chan $pass"
putlog "#NEWOPTOOLZ# ($hand) JOIN '$chan' sur $chan2"
return 0
}
### !cycle
proc pub_cycle {nick host hand chan arg} {
set arg [charfilter $arg]
global botnick
set hand [nick2hand $nick $chan]
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $host]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botnick auth <password>\002"
return 0
}
set botnick2 [strlwr $botnick]
puthelp "NOTICE $nick :Cycle en cours pour $chan"
puthelp "PART $chan"
putlog "#NEWOPTOOLZ# ($hand) CYCLE sur $chan"
}
### !deban <host>
proc pub_deban {nick hoster hand chan arg} {
global botnick
set hand [nick2hand $nick $chan]
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $hoster]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botnick auth <password>\002"
return 0
}
set host [lindex $arg 0]
if {$host == ""} {
puthelp "NOTICE $nick :\002Usage:\002 !deban <host>"
return 0
}
if {[killchanban $chan $host]} {
puthelp "NOTICE $nick : Le ban sur $host a ete supprime de ma memoire"
putlog "#NEWOPTOOLZ# ($hand) DEBAN '$host' sur $chan"
save
return 0
}
puthelp "NOTICE $nick : $host n'est pas reconnu comme un ban channel valide !"
return 0
}
### !boum <nick>
proc pub_boum {nick host hand chan arg} {
set arg [charfilter $arg]
global botnick
set hand [nick2hand $nick $chan]
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $host]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botnick auth <password>\002"
return 0
}
set who [lindex $arg 0]
set whohand [nick2hand $who $chan]
if {$who == ""} {
puthelp "NOTICE $nick :\002Usage:\002 !boum <nick>"
return 0
}
if {![onchan $who $chan]} {
puthelp "NOTICE $nick :Desole, mais je ne trouve pas $who sur $chan."
return 0
}
if {[strlwr $who] == [strlwr $botnick]} {
puthelp "NOTICE $nick :I can't be disabled, my name is activator :)"
return 0
}
if {$whohand == "*"} {
puthelp "NOTICE $nick :Je ne reconnais pas $who comme un user."
return 0
}
if {[getuser $whohand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :$who est deja desactive."
return 0
}
setuser $whohand xtra auth DEAD
chattr $whohand -3
puthelp "NOTICE $nick :$who est maintenant desactive."
putlog "#NEWOPTOOLZ# ($hand) BOUM sur '$whohand' sur $chan"
return 0
}
### !deboum <nick>
proc pub_deboum {nick host hand chan arg} {
set arg [charfilter $arg]
global botnick
set hand [nick2hand $nick $chan]
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $host]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botnick auth <password>\002"
return 0
}
set who [lindex $arg 0]
if {$who == ""} {
puthelp "NOTICE $nick :\002Usage:\002 !deboum <nick>"
return 0
}
set whohand [nick2hand $who $chan]
if {![onchan $who $chan]} {
puthelp "NOTICE $nick :Desole, mais je ne trouve pas $who sur $chan."
return 0
}
if {[strlwr $who] == [strlwr $botnick]} {
puthelp "NOTICE $nick :I don't need to be enabled, my name is activator :)"
return 0
}
if {$whohand == "*"} {
puthelp "NOTICE $nick :Je ne reconnais pas $who comme un user."
return 0
}
if {[getuser $whohand xtra auth] != "DEAD"} {
puthelp "NOTICE $nick :$who est deja active."
return 0
}
setuser $whohand xtra auth 0
puthelp "NOTICE $nick :$who est maintenant reactive."
putlog "#NEWOPTOOLZ# ($hand) DEBOUM sur '$whohand' sur $chan"
return 0
}
### !REMOVE [chan]
proc pub_remove {nick host hand chan arg} {
set arg [charfilter $arg]
global botnick
set hand [nick2hand $nick $chan]
if {[getuser $hand xtra auth] == "DEAD"} {
puthelp "NOTICE $nick :Desole tu ne peux pas utiliser les commandes channel."
return 0
}
if {![check $hand $nick $host]} {
puthelp "NOTICE $nick :Tu as besoin d'être identifie pour utiliser cette fonction. \002/msg $botnick auth <password>\002"
return 0
}
set ch [lindex $arg 0]
if {$ch == ""} {set ch $chan}
if {(![validchan $ch] && ![isdynamic $ch])} {
puthelp "NOTICE $nick :Je ne suis pas sur $ch "
return 0
}
channel remove $ch
puthelp "NOTICE $nick :$ch a ete enleve."
putlog "#NEWOPTOOLZ# ($hand) REMOVE de '$ch' sur $chan"
}
#################
##### OUTILS
proc check {hand nick host} {
if {[getuser $hand xtra auth] != "DEAD"} {
set perm_host [getuser $hand xtra permident]
if {[string match [strlwr $perm_host] [strlwr $nick!$host]]} {
return 1
}
}
set host [lindex [split $host "@"] 1]
if {[getuser $hand xtra auth] == 1} {
if {[getuser $hand xtra authnick] == $nick} {
return 1
}
}
return 0
}
proc charfilter {x {y ""} } {
for {set i 0} {$i < [string length $x]} {incr i} {
switch -- [string index $x $i] {
"\"" {append y "\\\""}
"\\" {append y "\\\\"}
"\[" {append y "\\\["}
"\]" {append y "\\\]"}
"\} " {append y "\\\} "}
"\{" {append y "\\\{"}
default {append y [string index $x $i]}
}
}
return $y
}
putlog "\0032NEWOPTOOLZ.TCL\003 (\0031330/09/2002\003) par Jarod_"