Torrevado Op
Joined: 02 Aug 2006 Posts: 101
|
Posted: Sun Apr 20, 2008 8:13 pm Post subject: hot potato.tcl [solved] |
|
|
Code: | #########################################################################################################
# CONFIGURATION DU SCRIPT
#########################################################################################################
# Le message d'aide qui sera envoyé au nick qui reçoit la bombe
set bombe_message_aide "Pour passer la bombe tape !bombe suivi du nom de la personne ; tu peux aussi feinter avec !feinte nick. Si tu veux désamorcer tape !desamorce"
set bomb_forbidchan "#channel2"
#########################################################################################################
# FIN DE LA CONFIGURATION
# Ne pas éditer plus bas tant que vous ne savez pas ce que vous faites :p
#########################################################################################################
# COMMANDES BOMBE
bind pub - !allume bombe_allumage
bind pub - !bombe bombe_passe
bind pub - !feinte bombe_feinte
bind pub - !desamorce bombe_desamorce
### Initialisation des variables globales
set bombe_en_cours 0
### !allume
proc bombe_allumage {nick host hand chan arg} {
global bomb_forbidchan
if {$chan == $bomb_forbidchan} {
putserv "notice $nick :On ne joue pas à la roulette sur $roulette_forbidchan !"
return 1
}
global bombe_en_cours bombe_allumeur bombe_porteur bombe_timer_moitie bombe_timer_fini bombe_chan bombe_a_tourne bombe_message_aide
if {$bombe_en_cours == 0} {
putserv "PRIVMSG $chan :$nick sifflote, sort une bombe de sa poche et l'allume... Psssshhhhhhhhhhh..."
putnotc $nick "$bombe_message_aide"
set bombe_en_cours 1
set bombe_chan $chan
set bombe_porteur $nick
set bombe_allumeur $nick
set bombe_a_tourne 0
set bombe_timer_moitie [utimer 60 bombe_timer_moitie]
set bombe_timer_fini [utimer 120 bombe_timer_fini]
} else {
if {[strlwr $nick] == [strlwr $bombe_allumeur]} {
puthelp "PRIVMSG $chan :$nick t'as déjà amorcé une bombe, pas la peine de tout faire exploser !!"
} else {
puthelp "PRIVMSG $chan :$bombe_allumeur a déjà piégé le chan $bombe_chan. C'est $bombe_porteur qui l'a entre les mains ... jusqu'à ce qu'il tape !bombe $nick ;)"
}
}
}
### !bombe
proc bombe_passe {nick host hand chan arg} {
global bombe_en_cours bombe_allumeur bombe_porteur bombe_timer_moitie bombe_timer_fini bombe_chan bombe_a_tourne bombe_message_aide
if {$bombe_en_cours==0} {
puthelp "PRIVMSG $chan :$nick tu veux passer quoi là ? T'as pas de bombe encore... !allume en une :)"
return 0
}
if {[strlwr $nick] != [strlwr $bombe_porteur]} {
puthelp "PRIVMSG $chan :Euh $nick c'est pas toi qui a la bombe c'est $bombe_porteur ... tant qu'il tape pas !bombe $nick :)"
return 0
}
if {$arg==""} {
puthelp "PRIVMSG $chan :Ce serait sympa de préciser à qui tu veux refiler le bébé $nick :)"
return 0
}
if {[strlwr $arg] == [strlwr $nick]} {
puthelp "PRIVMSG $chan :Euh $nick tu jongles avec la bombe là ? :)"
return 0
}
if {![onchan $arg $bombe_chan]} {
puthelp "PRIVMSG $chan :Euh $nick je vois personne qui s'appelle $arg ici... Tu ferais mieux de la passer à quelqu'un de présent sur $bombe_chan :)"
return 0
}
if {[strlwr $arg] == [strlwr $bombe_allumeur]} {
puthelp "PRIVMSG $chan :Ah ! La bombe a fait un tour et revient dans les mains de $bombe_allumeur sans que ça ait pété ! Beau jeu d'équipe !"
} else {
puthelp "PRIVMSG $chan :$nick jette la bombe à $arg... Vas-y débrouille toi avec ça !"
}
putnotc $arg "$bombe_message_aide"
set bombe_porteur $arg
set bombe_a_tourne 1
return 0
}
### !feinte
proc bombe_feinte {nick host hand chan arg} {
global bombe_en_cours bombe_allumeur bombe_porteur bombe_timer_moitie bombe_timer_fini bombe_chan bombe_a_tourne
if {$bombe_en_cours==0} {
puthelp "PRIVMSG $chan :$nick tu veux feinter avec quoi ! Tape déjà !allume tu verras après :)"
return 0
}
if {[strlwr $nick] != [strlwr $bombe_porteur]} {
puthelp "PRIVMSG $chan :Euh $nick c'est pas toi qui a la bombe c'est $bombe_porteur ... tant qu'il tape pas !bombe $nick :)"
return 0
}
if {$arg==""} {
puthelp "PRIVMSG $chan :$nick tu devrais dire qui tu veux feinter..."
return 0
}
if {[strlwr $arg] == [strlwr $nick]} {
puthelp "PRIVMSG $chan :lol y'a $nick qui se feinte tout seul :p"
return 0
}
if {![onchan $arg $bombe_chan]} {
puthelp "PRIVMSG $chan :Euh $nick je vois personne qui s'appelle $arg ici... Tu ferais mieux de feinter quelqu'un de présent sur $bombe_chan :)"
return 0
}
if {[strlwr $arg] == [strlwr $bombe_allumeur]} {
puthelp "PRIVMSG $chan :Ah ! C'est $bombe_allumeur qui l'a allumée cette bombe, c'est normal qu'il y ait des représailles :)"
} else {
puthelp "PRIVMSG $chan :$nick s'approche de $arg comme s'il allait l'embrasser ... lui fourre la bombe sous le nez... puis repart avec. Quel talent d'acteur !!"
}
return 0
}
### !desamorce
proc bombe_desamorce {nick host hand chan arg} {
global bombe_en_cours bombe_allumeur bombe_porteur bombe_timer_moitie bombe_timer_fini bombe_chan bombe_a_tourne
if {$bombe_en_cours==0} {
puthelp "PRIVMSG $chan :$nick tu veux désamorcer quoi là, t'as chaud ? Tape déjà !allume tu verras après :)"
return 0
}
if {[strlwr $nick] != [strlwr $bombe_porteur]} {
puthelp "PRIVMSG $chan :Euh $nick c'est pas toi qui a la bombe c'est $bombe_porteur ... tant qu'il tape pas !bombe $nick :)"
return 0
}
if {$bombe_a_tourne==0} {
puthelp "PRIVMSG $chan :$nick désamorce la tranquillement la bombe, sans avoir menacé personne avec. C'est une variante de la !roulette ? T'as de la chance qu'elle t'ait pas explosé en pleine tronche..."
} else {
puthelp "PRIVMSG $chan :$nick sort fébrilement sa p'tite pince et coupe le fil rouge. Il était temps, à mon avis ça allait pas tarder à péter !"
}
set bombe_en_cours 0
if {[utimerexists bombe_timer_moitie]!=""} {killutimer $bombe_timer_moitie}
if {[utimerexists bombe_timer_fini]!=""} {killutimer $bombe_timer_fini}
return 0
}
### bombe_timer_moitie
proc bombe_timer_moitie {} {
global bombe_en_cours bombe_allumeur bombe_porteur bombe_timer_moitie bombe_timer_fini bombe_chan bombe_a_tourne
if {$bombe_en_cours==0} {
return 0
}
if {$bombe_a_tourne==0} {
puthelp "PRIVMSG $bombe_chan :La mèche de la bombe s'est déjà à moitié consumée, et c'est toujours $bombe_allumeur qui l'a dans les mains... $bombe_allumeur t'es pétrifié par la trouille ? :)"
} else {
puthelp "PRIVMSG $bombe_chan :$bombe_porteur s'aperçoit que la mèche de la bombe s'est déjà à moitié consumée..."
}
}
### bombe_timer_fini
proc bombe_timer_fini {} {
global bombe_en_cours bombe_allumeur bombe_porteur bombe_timer_moitie bombe_timer_fini bombe_chan bombe_a_tourne
if {$bombe_en_cours==0} {
return 0
}
if {$bombe_a_tourne==0} {
puthelp "PRIVMSG $bombe_chan :La mèche est totalement consumée, et $bombe_allumeur la tient toujours dans ses mains... C'était un suicide !"
putserv "kick $bombe_chan $bombe_allumeur :BAOUM !!! :'( Adieu on t'aimait bien !"
} else {
puthelp "PRIVMSG $bombe_chan :$bombe_porteur n'a pas le temps de passer la bombe qu'elle explose ! Saleté de $bombe_allumeur tu le paieras ! :)"
putserv "kick $bombe_chan $bombe_porteur :BAOUM !!! Ta mort sera vengée."
}
set bombe_en_cours 0
}
############################
# debug
############################
bind pub - !bdebug bombe_debug
proc bombe_debug {nick host hand chan arg} {
global bombe_en_cours bombe_allumeur bombe_porteur bombe_timer_moitie bombe_timer_fini bombe_chan bombe_a_tourne bombe_message_aide
puthelp "PRIVMSG $bombe_chan :bombe_en_cours -> $bombe_en_cours | bombe_chan -> $bombe_chan | bombe_a_tourne -> $bombe_a_tourne"
puthelp "PRIVMSG $bombe_chan :bombe_allumeur -> $bombe_allumeur | bombe_porteur -> $bombe_porteur"
puthelp "PRIVMSG $bombe_chan :bombe_timer_moitie -> $bombe_timer_moitie | bombe_timer_fini -> $bombe_timer_fini"
puthelp "PRIVMSG $bombe_chan :$bombe_message_aide"
}
putlog "Bombe v$bombe_version par AzazeL. Tapez !allume :)"
|
The hot potato game, for IRC: try to pass the bomb to someone else before it explodes at your face.
!allume
Lights a new bomb.
!bombe <nick>
Gives the bomb to nick.
!feinte <nick>
This is a faint.
!desamorce
Defuse the bomb.
I'd like to add several features:
1- The bot won't pass the bomb to an idle nick
I tried the following code, but it doesn't work:
Code: | set gIdleTime 5
set gIdleOn 1
if { $gIdleOn == 1} {
if { [getchanidle $arg $chan] > $gIdleTime && $arg != $nick} {
putserv "PRIVMSG $chan :$nick: $arg is idle, try another nick ;)"
return
}
|
2- Bot doesn't pass the bomb to the owner or botnick
This code doesn't work either
Code: | set gOwner "mynick"
if { [string tolower $arg] == [string tolower $gOwner] } {
putserv "PRIVMSG $chan :$nick: I can't do it :("
return
}
if { [string tolower $arg] == [string tolower $botnick] } {
set arg $nick
IRCKick $arg $chan ":bye bye!"
return
}
if { [validuser $arg] == 1 } {
if { [matchattr $arg "+b"] == 1 } {
set arg $nick
IRCKick $arg $chan "bye bye!"
return
}
|
Of course I've added Code: | global gIdleTime gIdleOn gOwner | to the process
3- If someone change his nick, bot doesn't kick him, and I'd like it would do it anyway (I have not idea how to do that)
Last edited by Torrevado on Tue Jan 19, 2010 6:09 am; edited 1 time in total |
|