Code: Select all
setudef flag question
bind time - "42 23 * * *" coba:hidupkan
bind time - "06 20 * * *" coba:matikan
proc coba:hidupkan {} {
channel set #bawel +question
putserv "PRIVMSG #bawel : Anti Bot Enable"
}
proc coba:matikan {} {
channel set #bawel -question
putserv "PRIVMSG #bawel : Anti Bot Disabled"
}
namespace eval question {
bind join - * [namespace current]::onjoin
bind msgm - ".jawab *" [namespace current]::answer
namespace eval variable {
variable bantime 1440
variable tag "Banned:"
variable kickreason "Possible bot"
variable channel "#bawel"
}
proc onjoin {nickname hostname handle channel} {
global botnick timers answer
if {$nickname == "Rewel"} { return }
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, please answer with: .jawab <number>"
putserv "PRIVMSG $nickname :$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 :Kamu tidak menjawab pertanyaan saya!"
}
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 :Jawaban salah!"
} else {
killtimer $timers($hostname)
putserv "PRIVMSG $nickname :Jawaban benar!"
putquick "MODE $channel +v $nickname"
}
unset timers($hostname)
unset answer($hostname)
}
}
}
putlog "Antibot Loaded"