This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Anto Bot

Help for those learning Tcl or writing their own scripts.
Post Reply
g
gembels
Voice
Posts: 26
Joined: Sat Jul 07, 2012 9:31 pm

Anto Bot

Post by gembels »

I got this code somewhere.. credits to him, I try to make improvisation.. but failed.. Usually, human will always on on daily.. only small amount of people are online after 1 AM. But not spammer or bot. So, the idea is, I want make some Captcha or question on after 1 AM, wish that general spam bot can not answer and get kick ban. But its not success.. something wrong.. the answer is always wrong.. where is the faulty code ?

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"
Thanks in advance
Post Reply