Guest User

Untitled

a guest
Mar 3rd, 2018
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 11.62 KB | None | 0 0
  1. #################################################################################
  2. ## Imeto koeto botyt wi polzwa w IRC.
  3. set ImeNaBota "bot-nick"
  4.  
  5. ## Parolata na botyt wi s koqto se identificira w NS-a.
  6. set Parola "bot-pass"
  7.  
  8. ## Alternatiwniqt psewdonim na botyt. Tozi koito shte polzwa ako $ImeNaBota e zaet.
  9. set AltImeNaBota "bot-nick2"
  10.  
  11. ## Parolata za identifikaciq na Alternatiwniqt psewdonim.
  12. set AltParola "bot-pass2"
  13.  
  14. ## uhost na NS (za ShakeIT go ostawete taka!)
  15. set NSnuh "NickServ!Services@FreeNET.Services"
  16.  
  17. ## uhost na CS (za ShakeIT go ostawete taka!)
  18. set CSnuh "ChanServ!Services@FreeNET.Services"
  19.  
  20. ## Flagowete koito skriptyt da dobawq na Services (Ako neznaete za kakwo stawa duma ne gi pipaite)
  21. set servicesflags "+fEP-dk"
  22.  
  23. ## Maksimalnata dyljina na psewdonim koito se pozwolqwa ot syrwyryt (za ShakeIT go ostawete taka!)
  24. set nicklength 15
  25.  
  26.  
  27.  
  28. ###############################################################################################
  29. ##       AKO NEZNAETE KAKWO PRAWITE NEDEITE DA SE MESITE S KODYT KOJTO SLEDWA !!!!!!!!!!!    ##
  30. ###############################################################################################
  31.  
  32.  
  33.  
  34. bind notc - * serv_check
  35. bind raw - INVITE invite_me
  36.  
  37. proc serv_check {nick uhost hand text dest} {
  38.   global botnick NS NSnuh CSnuh IdPls IdOrDie PassAcc WrongPass NeedID NoAcc
  39.   global NeedReg Parola AltParola ImeNaBota AltImeNaBota nicklength ChanNotReg
  40.   if {[strlwr $botnick] != [strlwr $dest]} {
  41.     return -1
  42.   }
  43. #################################### Start NS #####################################
  44.   if {[strlwr "$nick!$uhost"] == [strlwr $NSnuh]} {
  45.     if {[strlwr $text] == [strlwr $IdPls]} {
  46.       set NS(Critic) 1
  47.       set NS(SentPass) 1
  48.       set NS(NotId) 1
  49.       set NS(NotReg) 0
  50.       botnsidentify
  51.       putlog "ID PLS"
  52.     } elseif {[strlwr $text] == [strlwr $IdOrDie]} {
  53.       set NS(Critic) 2
  54.       set NS(NotId) 1
  55.       set v(NotReg) 0
  56.       if {$NS(SentPass) == 0} {
  57.         set NS(SentPass) 1
  58.         botnsidentify
  59.       }
  60.       putlog "ID OR DIE."
  61.     } elseif {[strlwr $text] == [strlwr $PassAcc]} {
  62.       set NS(Critic) 0
  63.       set NS(SentPass) 0
  64.       set NS(NotReg) 0
  65.       set NS(NotId) 0
  66.       putlog "Acc pass."
  67.     } elseif {[strlwr $text] == [strlwr $WrongPass]} {
  68.       set NS(NotReg) 0
  69.       if {$NS(Critic) == 1} {
  70.         if {[strlwr $botnick] == [strlwr $ImeNaBota]} {
  71.           set NS(Critic) 0
  72.           set NS(SentPass) 0
  73.           set NS(NotId) 0
  74.           puthelp "NICK $AltImeNaBota"
  75.         }
  76.         return 1
  77.       }
  78.       randchangenick
  79.       set NS(Critic) 0
  80.       set NS(SentPass) 0
  81.       set NS(NotReg) 0
  82.       set NS(NotId) 0
  83.       putlog "Wrn pass"
  84.     }
  85. #################################### Start CS #####################################
  86.   } elseif {[strlwr "$nick!$uhost"] == [strlwr $CSnuh]} {
  87.     if {$NS(NotReg) == 1} {
  88.       return -1
  89.     }
  90.     if {[string match -nocase "$NeedID*" $text]} {
  91.       botnsidentify
  92.       set NS(NotId) 1
  93.       set NS(Critic) 0
  94.       set NS(SentPass) 1
  95.       putlog "Ne sam id"
  96.       foreach channel [channels] {
  97.         zanulall $channel "invite op unban Mod"
  98.       }
  99.         } elseif {[string match -nocase "*have been cleared on*" $text]} {
  100.           set channel [lindex $text [expr [llength $text] -1]]
  101.           if {[string match "*GECOSBANS*" $text]} {
  102.             set channel [string replace $channel 0 1 ""]
  103.             set channel [string range $channel 0 [expr [string length $channel] - 2]]
  104.           }
  105.           putserv "JOIN $channel"
  106.     } elseif {[string match -nocase "$NoAcc*" $text]} {
  107.       set level [string replace [lindex $text [expr [llength $text] -3]] 0 1 ""]
  108.       set level [string range $level 0 [expr [string length $level] - 2]]
  109.       set channel [lindex $text [expr [llength $text] -1]]
  110.       if {[lsearch -exact [array names NoLevel] $channel] != -1} {
  111.       set NoLevel($channel) [linsert $NoLevel($channel) end $level]
  112.       } else {
  113.       set NoLevel($channel) [list $level]
  114.       }
  115.       if {[strlwr $level] == "invite"} {
  116.         zanulall $channel invite
  117.       } elseif {[strlwr $level] == "op"} {
  118.         zanulall $channel op
  119.       } elseif {[strlwr $level] == "unban"} {
  120.         zanulall $channel unban
  121.       } elseif {[strlwr $level] == "clear"} {
  122.         zanulall $channel Mod
  123.       }
  124.       putlog "Nqmam level"
  125.     } elseif {[strlwr $text] == [strlwr $NeedReg]} {
  126.       botnsregister
  127.       set NS(NotReg) 1
  128.       set NS(NotId) 1
  129.       set NS(Critic) 0
  130.       set NS(SentPass) 0
  131.       foreach channel [channels] {
  132.         zanulall $channel "invite op unban Mod"
  133.       }
  134.       putlog "Ne sam registriran"
  135.     } elseif {[strlwr $text] == [strlwr ChanNotReg]} {
  136.       set channel [string replace [lindex $text [expr [llength $text] - 4]] 0 1 ""]
  137.       set channel [string range $level 0 [expr [string length $level] - 2]]
  138.       zanulall $channel "invite op unban Mod"
  139.       putlog "$channel ne e reg"
  140.     } else {
  141.     }
  142.   }
  143. }
  144.  
  145. # From alltools.tcl.
  146. proc strlwr {string} {
  147.   string tolower $string
  148. }
  149.  
  150. proc randstring {length {chars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789}} {
  151.   set count [string length $chars]
  152.   for {set index 0} {$index < $length} {incr index} {
  153.     append result [string index $chars [rand $count]]
  154.   }
  155.   return $result
  156. }
  157.  
  158. proc botnsidentify {} {
  159.   global botnick ImeNaBota AltImeNaBota NS NSnuh Parola AltParola
  160.  
  161.   if {[strlwr $botnick] == [strlwr $ImeNaBota]} {
  162.     puthelp "PRIVMSG [lindex [split $NSnuh "!"] 0] :identify $Parola"
  163.   } elseif {[strlwr $botnick] == [strlwr $AltImeNaBota]} {
  164.     puthelp "PRIVMSG [lindex [split $NSnuh "!"] 0] :identify $AltParola"
  165.   } else {
  166.     if {$NS(Critic) == 2} {
  167.       randchangenick
  168.     }
  169.   }
  170. }
  171.  
  172. proc botnsregister {} {
  173.   global botnick ImeNaBota AltImeNaBota NS NSnuh Parola AltParola
  174.  
  175.   if {[strlwr $botnick] == [strlwr $ImeNaBota]} {
  176.     puthelp "PRIVMSG [lindex [split $NSnuh "!"] 0] :register $Parola $Parola"
  177.   } elseif {[strlwr $botnick] == [strlwr $AltImeNaBota]} {
  178.     puthelp "PRIVMSG [lindex [split $NSnuh "!"] 0] :register $AltParola $AltParola"
  179.   }
  180. }
  181.  
  182.  
  183. proc invite_me {from key text} {
  184. global CSnuh
  185.   if {[strlwr [lindex [split $from "!"] 0]] == [lindex [split $CSnuh "!"] 0]} {
  186.     zanulall [string range [lindex $text 1] 1 end] invite
  187.   }
  188. }
  189.  
  190. proc zanulall {chan types} {
  191.   global Sent
  192.  
  193.   foreach type [split $types " "] {
  194.     if {[lsearch -exact $Sent($type) $chan] != -1} {
  195.       set Sent($type) [lreplace $Sent($type) [lsearch -exact $Sent($type) $chan] [lsearch -exact $Sent($type) $chan]]
  196.     }
  197.   }
  198. }
  199.  
  200. ## Fuck the rules.
  201. set keep-nick 0
  202.  
  203. if {[strlwr $nick] != [strlwr $ImeNaBota]} {
  204.   set nick $ImeNaBota
  205.   puthelp "NICK $ImeNaBota"
  206.   putlog "Greshka, set nick ne savpada s \$ImeNaBota"
  207. }
  208.  
  209. set altnick $AltImeNaBota
  210.  
  211. utimer 10 checkzz
  212.  
  213. set IdPls "This nickname is owned by someone else"
  214. set IdOrDie "If you do not \001IDENTIFY\001 within one minute, you will be disconnected"
  215. set PassAcc "Password accepted - you are now recognized"
  216. set WrongPass "Password Incorrect"
  217. set NeedID "Password identification is required for"
  218. set NoAcc "An access level of"
  219. set NeedReg "Your nickname is not registered"
  220. set ChanNotReg "The channel"
  221.  
  222. array set NoLevel ""
  223. set NS(Critic) 0
  224. set NS(SentPass) 0
  225. set NS(NotId) 0
  226. set NS(NotReg) 0
  227. set NS(Critic) 0
  228. set Sent(op) ""
  229. set Sent(unban) ""
  230. set Sent(Mod) ""
  231. set Sent(invite) ""
  232.  
  233. proc checkzz {} {
  234.   global NSnuh CSnuh servicesflags
  235.  
  236.   foreach ignore [ignorelist] {
  237.     if {[string match [lindex $ignore 0] $NSnuh] || [string match [lindex $ignore 0] $CSnuh] ||
  238.         [string match -nocase *!*@[lindex [split $NSnuh "@"] 1] [lindex $ignore 0] ]} {
  239.       killignore [lindex $ignore 0]
  240.     }
  241.   }
  242.  
  243.   if {![validuser Services]} {
  244.     if {[adduser Services *@[lindex [split $NSnuh "@"] 1]]} {
  245.       chattr Services +$servicesflags
  246.       setuser Services HOSTS "[lindex [split $CSnuh "!"] 0]!*@*"
  247.       setuser Services PASS [randstring 10]
  248.     } else {
  249.       putlog "Can't add Services, \001ERROR\001!"
  250.     }
  251.   } else {
  252.     chattr Services +$servicesflags
  253.   }
  254.  
  255.   foreach chan [channels] {
  256.     channel set $chan need-op ""
  257.     channel set $chan need-unban ""
  258.     channel set $chan need-invite ""
  259.     channel set $chan need-key ""
  260.     channel set $chan need-limit ""
  261.     foreach ban [banlist $chan] {
  262.       if {[string match -nocase [lindex $ban 0] $CSnuh]} {
  263.         killchanban $chan [lindex $ban 0]
  264.       }
  265.     }
  266.   }
  267.  
  268.   foreach ban [banlist] {
  269.     if {[string match -nocase [lindex $ban 0] $CSnuh]} {
  270.       killban [lindex $ban 0]
  271.     }
  272.   }
  273. }
  274.  
  275. putlog "NS/CS support TCL by X Loaded!!!"
  276.  
  277. bind mode - *+o* opala
  278.  
  279. proc opala {nick uhost hand chan mdechg op} {
  280. global botnick
  281.   if {[strlwr $botnick] == [strlwr $op]} {
  282.       zanulall [strlwr $chan] op
  283.     }
  284. }
  285. bind need - "*" needall
  286.  
  287. proc needall {chan type} {
  288.   global NS NoLevel CSnuh Sent
  289.   if {([botonchan $chan] && $type != "op") || ([botisop $chan] && $type == "op") ||
  290.  
  291.       ($NS(NotId) == 1 || $NS(NotReg) == 1) || (($type != "limit" && $type != "key"
  292.          && [lsearch -exact $Sent($type) $chan] != -1)) ||
  293.       ([lsearch -exact $Sent(Mod) $chan] != -1 && ($type == "limit" || $type == "key"))} {
  294.     return
  295.   }
  296.  
  297.   if {$type == "op"} {
  298.     if {[lsearch -exact [array names NoLevel] $chan] != -1} {
  299.       if {[lsearch -exact $NoLevel($chan) "op"] == -1} {
  300.         putquick "PRIVMSG [lindex [split $CSnuh "!"] 0] :op $chan"
  301.         set Sent(op) [linsert $Sent(op) end $chan]
  302.       }
  303.       return
  304.     }
  305.     putquick "PRIVMSG [lindex [split $CSnuh "!"] 0] :op $chan"
  306.     set Sent(op) [linsert $Sent(op) end $chan]
  307.   } elseif {$type == "invite"} {
  308.     if {[lsearch -exact [array names NoLevel] $chan] != -1} {
  309.       if {[lsearch -exact $NoLevel($chan) "invite"] == -1} {
  310.         putquick "PRIVMSG [lindex [split $CSnuh "!"] 0] :invite $chan"
  311.         putserv "JOIN $chan"
  312.         set Sent(invite) [linsert $Sent(invite) end $chan]
  313.       }
  314.       return
  315.     }
  316.  
  317.     putquick "PRIVMSG [lindex [split $CSnuh "!"] 0] :invite $chan"
  318.     putserv "JOIN $chan"
  319.     set Sent(invite) [linsert $Sent(invite) end $chan]
  320.   } elseif {$type == "limit" || $type == "key"} {
  321.     if {[lsearch -exact [array names NoLevel] $chan] != -1} {
  322.       if {[lsearch -exact $NoLevel($chan) "clear"] == -1} {
  323.         putserv "PRIVMSG [lindex [split $CSnuh "!"] 0] :clear $chan modes"
  324.         putserv "JOIN $chan"
  325.         set Sent(Mod) [linsert $Sent(Mod) end $chan]
  326.       }
  327.       return
  328.     }
  329.  
  330.     putserv "PRIVMSG [lindex [split $CSnuh "!"] 0] :clear $chan modes"
  331.     putserv "JOIN $chan"
  332.     set Sent(Mod) [linsert $Sent(Mod) end $chan]
  333.   } elseif {$type == "unban"} {
  334.     if {[lsearch -exact [array names NoLevel] $chan] != -1} {
  335.       if {[lsearch -exact $NoLevel($chan) "unban"] != -1 && [lsearch -exact $NoLevel($chan) "clear"] != -1} {
  336.         return
  337.       } elseif {[lsearch -exact $NoLevel($chan) "clear"] != -1} {
  338.         putquick "PRIVMSG [lindex [split $CSnuh "!"] 0] :unban $chan"
  339.         putserv "JOIN $chan"
  340.         set Sent(unban) 1
  341.       } elseif {[lsearch -exact $NoLevel($chan) "unban"] != -1} {
  342.         putserv "PRIVMSG [lindex [split $CSnuh "!"] 0] :clear $chan bans"
  343.         putserv "PRIVMSG [lindex [split $CSnuh "!"] 0] :clear $chan bans"
  344.         putserv "JOIN $chan"
  345.         set Sent(unban) [linsert $Sent(unban) end $chan]
  346.       } else {
  347.         putserv "PRIVMSG [lindex [split $CSnuh "!"] 0] :unban $chan"
  348.         putquick "PRIVMSG [lindex [split $CSnuh "!"] 0] :unban $chan"
  349.         putserv "JOIN $chan"
  350.         set Sent(unban) [linsert $Sent(unban) end $chan]
  351.       }
  352.       return
  353.     }
  354.  
  355.     putserv "PRIVMSG [lindex [split $CSnuh "!"] 0] :unban $chan"
  356.     putquick "PRIVMSG [lindex [split $CSnuh "!"] 0] :unban $chan"
  357.     putserv "JOIN $chan"
  358.     set Sent(unban) [linsert $Sent(unban) end $chan]
  359.   }
  360. }
  361.  
  362. proc randchangenick {} {
  363.   global botnick ImeNaBota AltImeNaBota nicklength
  364.  
  365.   if {[strlwr $botnick] == [strlwr $ImeNaBota]} {
  366.     puthelp "NICK $AltImeNaBota"
  367.   } else {
  368.     if {[string length $AltImeNaBota] > [expr $nicklength - 3]} {
  369.       puthelp "NICK [string range $AltImeNaBota 0 12][randstring 3]"
  370.     } else {
  371.       puthelp "NICK $AltImeNaBota[randstring 3]"
  372.     }
  373.   }
  374. }
  375.  
  376. # TODO
  377. # bota kato go bannat da prowerqwa dali e ot CS bana
Add Comment
Please, Sign In to add comment