To enable the script:
- telnet your bot, .chanset #channel +question to enable the script.
What does it do:
- if a user joins the channel s/he will be queryed with a calculation question, if s/he answers wrong or dont answer at all, s/he will be banned for 24hours.
- s/he needs to answer with '.answer <answer>'
Please change:
- please change #channel to the channel you wish to use it on.
please change kickreason if needed
Errors or feedback:
- works with eggdrop 1.6.19
- if anything dont work or it gives errors please post them here
- Code: Select all
setudef flag question
namespace eval question {
bind join - * [namespace current]::onjoin
bind msgm - ".answer *" [namespace current]::answer
namespace eval variable {
variable bantime 1440
variable tag "Banned:"
variable kickreason "Possible bot"
variable channel "#channel"
}
proc onjoin {nickname hostname handle channel} {
global botnick timers answer
if {[channel get $channel question] == 1} {
if {![isbotnick $nickname] && ![info exists timers($hostname)]} {
set num1 [rand 9]
set num2 [rand 9]
set q [expr $num1 + $num2]
set answer($hostname) $q
set timers($hostname) [timer 2 [list ::question::noanswer $hostname]]
putserv "PRIVMSG $nickname :I have a question, I want you to answer with '.answer <your-answer>'."
putserv "PRIVMSG $nickname :What is $num1 + $num2"
}
}
}
proc noanswer {hostname} {
global botnick timers answer
if {[info exists timers($hostname)]} {
set channel $::question::variable::channel
set bantime $::question::variable::bantime
foreach user [chanlist $channel] {
if {[string match "$hostname" "[string trim [getchanhost $user $channel] "~"]"]} {
set victim [string tolower $user]
}
}
if {[info exists victim]} {
if {[botisop $channel]} {
putserv "mode $channel +b *!*[string trim $hostname "~"]"
putserv "kick $channel $victim :$::question::variable::tag $::question::variable::kickreason"
putserv "PRIVMSG $victim :you didn't answer my question."
}
newchanban $channel *!*[string trim $hostname "~"] question "$::question::variable::kickreason" $bantime
}
unset timers($hostname)
unset answer($hostname)
}
}
proc answer {nickname hostname handle arguments} {
global botnick timers answer
if {[info exists timers($hostname)]} {
set channel $::question::variable::channel
set bantime $::question::variable::bantime
set correctanswer [lindex $arguments 1]
if {[string match $correctanswer $answer($hostname)] != 1} {
if {[botisop $channel]} {
putserv "mode $channel +b *!*[string trim $hostname "~"]"
putserv "kick $channel $nickname :$::question::variable::tag $::question::variable::kickreason"
}
killtimer $timers($hostname)
newchanban $channel *!*[string trim $hostname "~"] question "$::question::variable::kickreason" $bantime
putserv "PRIVMSG $nickname :incorrect answer."
} else {
killtimer $timers($hostname)
putserv "PRIVMSG $nickname :correct answer."
}
unset timers($hostname)
unset answer($hostname)
}
}
}
putlog "\00304[string range [info script] 0 end]\00304 \002loaded...\002"