Advertisement
Guest User

MCC.tcl

a guest
Apr 27th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 86.16 KB | None | 0 0
  1. # ----------------------------------------------------------
  2. # MCC v2.5 by dirty Inc.
  3. #
  4. # Public Command Script
  5. #
  6. # Contact
  7. # irc.UnderNet.org @ #BotZone
  8. # WwW.BotZone.Tk
  9. #
  10. # -= v1.0 =-
  11. # Standard eggdrop commands made public (no addons)
  12. # -= v2.0 =-
  13. # Rewrite of the code for faster reaction and less CPU usage
  14. # -= v2.1 =-
  15. # Added more configuration options, updates & addons
  16. # -= v2.2 =-
  17. # Added channel service login for:
  18. # GnuWorld - X: UnderNet, ZoomNet.Org, SuprtechNet
  19. # Q9 - Q: QuakeNet
  20. # Added botnet support (bots request op/unban/invite from each other)
  21. # -= v2.3 =-
  22. # Fixed a couple of bugs and edited some small parts of code
  23. # -= v2.3a =-
  24. # Added 3 new commands ssh, dns, ipinfo when +ipinfo channel setting
  25. # -= v2.4 =-
  26. # Moved from MCC main script into separate tcl addons and standalone
  27. #scripts:
  28. # - +ipinfo with ssh, dns & ipinfo commands
  29. # - Channel Service (X/Q) login system.
  30. # -= v2.5 =-
  31. # Fixed bugs discovered by users. Thank you everyone for your feedback.
  32. #
  33. # ----------------------------------------------------------
  34.  
  35. # -------------------------------------
  36. # Global Variables ( SETTINGS )
  37. # -------------------------------------
  38.  
  39. # Write here the special characters that the commands will work with.
  40. # Ex: !op .op `op -op
  41. set mcc(trigger) "."
  42.  
  43. # Write here the name of your console channel (hidden from public)
  44. set mcc(home) "#chan"
  45.  
  46. # Write here the name of your main channel (bot lending channel)
  47. set mcc(home@bl) "#chan1 #chan2 #chan3 etc"
  48.  
  49. # Write here the mask of Hidden Host (/mode +x) if the network uses any.
  50. # Pay attention at the *. before the host
  51. set mcc(regusermask) "*.host"
  52.  
  53. # Do you want the eggdrop to allow anyone to register a user in the database?
  54. # 1 - yes | 0 - no
  55. set mcc(selfreguser) "0"
  56.  
  57. # Set here the global ban reasons for flooders.
  58. # CHANEL Flooder:
  59. set mcc(flood@chan) "Channel Flooder. Get out!"
  60. # CTCP Flooder:
  61. set mcc(flood@ctcp) "CTCP Flooder. Get out!"
  62. # JOIN Flooder:
  63. set mcc(flood@join) "Join/Part Flooder. Get out!"
  64. # DEOP Flooder:
  65. set mcc(flood@deop) "Mass DeOp. Get out!"
  66. # KICK Flooder:
  67. set mcc(flood@kick) "Mass Kick. Get out!"
  68. # NICK Flooder:
  69. set mcc(flood@nick) "Mass Nick Change. Get out!"
  70.  
  71. # ## PLEASE DO NOT EDIT BELOW THIS ## #
  72.  
  73. set mcc(scriptversion) "v2.5"
  74. set ctcp-version "eggdrop[lindex $version 0] :: MCC $mcc(scriptversion) (c) dirty Inc."
  75. unbind msg - hello *msg:hello
  76. unbind msg - ident *msg:ident
  77. unbind msg - addhost *msg:addhost
  78. unbind msg - help *msg:help
  79. unbind msg - whois *msg:whois
  80. unbind msg - who *msg:who
  81. unbind msg - voice *msg:voice
  82. unbind msg - info *msg:info
  83. unbind msg - go *msg:go
  84. unbind msg - halfop *msg:halfop
  85. unbind msg - op *msg:op
  86. unbind msg o|o key *msg:key
  87. unbind msg o|o invite *msg:invite
  88. unbind msg m|- save *msg:save
  89. unbind msg m|- reset *msg:reset
  90. unbind msg m|- rehash *msg:rehash
  91. unbind msg m|- memory *msg:memory
  92. unbind msg m|- jump *msg:jump
  93. unbind msg m|m status *msg:status
  94. unbind msg n|- die *msg:die
  95.  
  96.  
  97. setudef flag debug
  98. setudef str greet-text
  99. setudef flag limit
  100. setudef int limit-int
  101.  
  102. setudef flag autotopic
  103. setudef flag locktopic
  104. setudef str topic-text
  105. setudef flag voicetalk
  106.  
  107. setudef flag anti-voiceidle
  108. setudef flag anti-opidle
  109. setudef flag anti-spam
  110. setudef flag anti-notice
  111. setudef flag anti-ctcp
  112. setudef flag anti-color
  113. setudef flag anti-bold
  114. setudef flag anti-underline
  115. setudef flag anti-caps
  116. setudef flag anti-flyby
  117. setudef flag anti-badword
  118. setudef flag anti-badwhois
  119. setudef flag anti-badpart
  120. setudef flag anti-badchan
  121. setudef str badword-text
  122. setudef str badchan-text
  123.  
  124. channel add $mcc(home) {
  125.     +static +debug
  126.     limit-int 5
  127. }
  128.  
  129. # -------------------------------------
  130. # Other Processes
  131. # -------------------------------------
  132.  
  133. # Detecting TELNET port
  134. foreach portlist [dcclist TELNET] {
  135.     if {([lindex $portlist 1] == "(all)") || ([lindex $portlist 1] == "(users)") || ([lindex $portlist 1] == "(telnet)")} {
  136.         set mcc(telnetport) [lindex [lindex $portlist 4] 1]; break
  137.     }
  138. }
  139.  
  140. # Server side limits
  141. bind raw - 005 mcc:server:limits
  142. proc mcc:server:limits {from idx args} {
  143.     global max-modes max-bans nick-len network mcc
  144.  
  145.     set args [lrange [lindex $args 0] 1 end]
  146.     foreach option $args {
  147.         regsub -all "=" $option " " option
  148.  
  149.         switch [lindex $option 0] {
  150.             MAXCHANNELS { set mcc(srv@maxchan) "11" }
  151.                   MODES { set max-modes [lindex $option 1] }
  152.                 MAXBANS { set max-bans [lindex $option 1] }
  153.                 SILENCE { set mcc(srv@silence) [lindex $option 1] }
  154.                TOPICLEN { set mcc(srv@topiclen) [lindex $option 1] }
  155.                 KICKLEN { set mcc(srv@kicklen) [lindex $option 1] }
  156.                 AWAYLEN { set mcc(srv@awaylen) [lindex $option 1] }
  157.              CHANNELLEN { set mcc(srv@chanlen) [lindex $option 1] }
  158.               CHANTYPES { set mcc(srv@chantypes) [lindex $option 1] }
  159.               CHANMODES { set mcc(srv@chanmodes) [lindex $option 1] }
  160.                 NETWORK { set network [lindex $option 1] }
  161.         }
  162.     }
  163. }
  164.  
  165. # Checks related to server side limits
  166. proc mcc:check:server_limits {type text} {
  167.     global mcc
  168.    
  169.     if {$type == "topic"} {
  170.         if {![info exists mcc(srv@topiclen)]} { return 1 }
  171.         if {[string length $text] > $mcc(srv@topiclen)} { return 0 }
  172.     return 1 }
  173.    
  174.     if {$type == "kick"} {
  175.         if {![info exists mcc(srv@kicklen)]} { return 1 }
  176.         if {[string length $text] > $mcc(srv@kicklen)} { return 0 }
  177.     return 1 }
  178.    
  179.     if {$type == "away"} {
  180.         if {![info exists mcc(srv@awaylen)]} { return 1 }
  181.         if {[string length $text] > $mcc(srv@awaylen)} { return 0 }
  182.     return 1 }
  183.    
  184.     if {$type == "chanlen"} {
  185.         if {![info exists mcc(srv@chanlen)]} { return 1 }
  186.         if {[string length $text] > $mcc(srv@chanlen)} { return 0 }
  187.     return 1 }
  188.    
  189.     if {$type == "chantype"} {
  190.         if {![info exists mcc(srv@chantypes)]} { return 1 }
  191.         if {![string match *[lindex [split $text {}] 0]* $mcc(srv@chantypes)]} { return 0 }
  192.     return 1 }
  193.    
  194.     if {$type == "channels"} {
  195.         if {[llength [channels]] >= $mcc(srv@maxchan)} { return 0 }
  196.     return 1 }
  197.    
  198.     if {$type == "modes"} {
  199.         if {![info exists mcc(srv@chanmodes)]} { return 1 }
  200.         set chanmodes "+ - k l [split [lindex [split $mcc(srv@chanmodes) ,] end] {}]"
  201.         foreach cmode [split $text {}] {
  202.             if {[lsearch -exact $chanmodes $cmode] == "-1"} { return 0 }
  203.         }
  204.     return 1 }
  205. return 0 }
  206.  
  207. # Send debug messages to all +debug channels.
  208. proc mcc:msg:debug {message} {
  209.    
  210.     foreach chan [channels] {
  211.         if {![channel get $chan debug]} { continue }
  212.         putnotc $chan "$message"
  213.     }
  214. }
  215.  
  216. # Split lines bigger then 350 chars (thanks thommey)
  217. proc mcc:check:splitline {string {maxlength 350}} {
  218.     while {[string length $string] > $maxlength} {
  219.         # Where would a hard cut be?
  220.         set hardcut $maxlength
  221.         # search backwards for " "
  222.         for {set cut $hardcut} {$cut >= 0 && [string index $string $cut] != " "} {incr cut -1} { }
  223.         # if not found, use hard cut (long word)
  224.         if {$cut < 0} { set cut $hardcut }
  225.         lappend result [string range $string 0 [expr {$cut-1}]]
  226.         # if it was a soft cut, skip the " "
  227.         if {[string index $string $cut] == " "} { incr cut }
  228.         set string [string range $string $cut end]
  229.     }
  230.     # rest bit
  231.     if {[string length $string]} {
  232.         lappend result $string
  233.     }
  234.     return $result
  235. }
  236.  
  237. # Channel Greet Parser
  238. proc mcc:check:greet {nick host handle channel text} {
  239.     global botnick server
  240.  
  241.     set text [string map [list %nickname $nick] $text]
  242.     set text [string map [list %hostname $host] $text]
  243.     set text [string map [list %channel $channel] $text]
  244.     set text [string map [list %access [mcc:check:level $handle $channel]] $text]
  245.     set text [string map [list %handle $handle] $text]
  246.     set text [string map [list %botnick $botnick] $text]
  247. return $text }
  248.  
  249. # Detect the flags/level of a user
  250. proc mcc:check:level {handle channel} {
  251.        
  252.         if {![validuser $handle]} { return "Unknown" }
  253.         if {[matchattr $handle W]} { return "Network Service" }
  254.         if {[matchattr $handle n]} { return "Global Owner" }
  255.         if {[matchattr $handle m]} { return "Global Master" }
  256.         if {[matchattr $handle o]} { return "Global Op" }
  257.         if {[matchattr $handle &n $channel]} { return "Channel Owner" }
  258.         if {[matchattr $handle &m $channel]} { return "Channel Master" }
  259.         if {[matchattr $handle &o $channel]} { return "Channel Op" }
  260.         if {[matchattr $handle &v $channel]} { return "Channel Voice" }
  261.        
  262. return "No Access" }
  263.  
  264. # Level difference protection
  265. proc mcc:check:leveldiff {hand1 hand2 channel} {
  266.     global owner
  267.    
  268.     set hand1 [string tolower $hand1]
  269.     set hand2 [string tolower $hand2]
  270.    
  271.     if {$channel == ""} {
  272.         if {$hand1 == $hand2} { return 1 }
  273.         if {$hand1 == [string tolower $owner]} { return 0 }
  274.         if {[matchattr $hand1 n] && $hand2 != [string tolower $owner]} { return 0 }
  275.         if {[matchattr $hand1 W] && ![matchattr $hand2 n]} { return 0 }
  276.         if {[matchattr $hand1 b] && ![matchattr $hand2 m]} { return 0 }
  277.         if {[matchattr $hand1 m] && ![matchattr $hand2 n]} { return 0 }
  278.         if {[matchattr $hand1 o] && ![matchattr $hand2 m]} { return 0 }
  279.         if {![matchattr $hand2 o]} { return 0 }
  280.     return 1 } elseif {[validchan $channel]} {
  281.         if {$hand1 == $hand2} { return 1 }
  282.         if {[matchattr $hand1 &n $channel] && ![matchattr $hand2 o]} { return 0 }
  283.         if {[matchattr $hand1 &m $channel] && (![matchattr $hand2 &n $channel] && ![matchattr $hand2 o])} { return 0 }
  284.         if {[matchattr $hand1 &o $channel] && (![matchattr $hand2 &m $channel] && ![matchattr $hand2 o])} { return 0 }
  285.         if {[matchattr $hand1 &v $channel] && (![matchattr $hand2 &o $channel] && ![matchattr $hand2 o])} { return 0 }
  286.         if {![haschanrec $hand2 $channel] && ![matchattr $hand2 o]} { return 0 }
  287.     return 1 }
  288.     mcc:msg:debug "\[\002MCC:CHECK:LEVELDIFF\002\] Error! $hand1 - $hand2 for $channel"
  289. return 0 }
  290.  
  291. # Verify if logged in
  292. proc mcc:check:logged {nick handle uhost} {
  293.     global botnick
  294.    
  295.     if {![matchattr $handle Q]} {
  296.         if {[getuser $handle XTRA PERMIDENT] == "1"} { return 1 }
  297.         puthelp "NOTICE $nick :You are not logged in. ( /msg $botnick login )"
  298.         return 0
  299.     }
  300.     return 1
  301. }
  302.  
  303. # Verify if user has no password
  304. bind cron - "*/30 * * * *" mcc:check:nopass
  305. proc mcc:check:nopass {a b c d e} {
  306.     global mcc
  307.    
  308.     set count "0"
  309.     set list ""
  310.     foreach user [userlist] {
  311.         if {[passwdok $user ""] && ![matchattr $user b]} {
  312.             if {[unixtime] > [getuser $user XTRA NOPASSDEL]} {
  313.                 deluser $user
  314.                 lappend list $user
  315.                 incr count
  316.             }
  317.         }
  318.     }
  319.     if {$count != "0"} {
  320.         mcc:msg:debug "\[\002CleanDB\002\] Automatically deleted $count users: $list"
  321.     }
  322. }
  323.  
  324. # Verify user idle time
  325. bind cron - "*/5 * * * *" mcc:check:idleuser
  326. proc mcc:check:idleuser {a b c d e} {
  327.  
  328.     foreach chan [channels] {
  329.         if {[channel get $chan inactive] || ![botisop $chan]} { continue }
  330.         if {[channel get $chan anti-voiceidle] || [channel get $chan anti-opidle] || [channel get $chan voicetalk]} {
  331.             foreach user [chanlist $chan] {
  332.                 if {[isbotnick $user]} { continue }
  333.                 if {[getchanidle $user $chan] < 20} { continue }
  334.                
  335.                 if {[channel get $chan anti-voiceidle] || [channel get $chan voicetalk]} {
  336.                     if {[isvoice $user $chan]} {
  337.                         pushmode $chan -v $user
  338.                     }
  339.                 }
  340.                
  341.                 if {[channel get $chan anti-opidle]} {
  342.                     if {[isop $user $chan]} {
  343.                         pushmode $chan -o $user
  344.                     }
  345.                 }
  346.             }
  347.         }
  348.     }
  349. }
  350.  
  351. # Protect channel topic
  352. bind topc - * mcc:check:topic
  353. proc mcc:check:topic {nick uhost handle channel text} {
  354.    
  355.     if {[channel get $channel locktopic] && ![isbotnick $nick]} {
  356.         putserv "TOPIC $channel :[join [lrange [split [channel get $channel topic-text]] 1 end]]"
  357.         putserv "NOTICE $nick :Channel topic locked by [lindex [join [channel get $channel topic-text]] 0]"
  358.         return
  359.     }
  360.     if {$text != ""} {
  361.         channel set $channel topic-text "$nick [join [lrange [split $text] 0 end]]"
  362.     }
  363. }
  364.  
  365. # Set channel limit
  366. proc mcc:check:limit {channel} {
  367.    
  368.     set users [llength [chanlist $channel]]
  369.     set limit [channel get $channel limit-int]
  370.     pushmode $channel +l [expr {$users + $limit}]
  371. }
  372.  
  373. # Check if caps
  374. proc mcc:check:isupper {letter} {
  375.     set caps {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
  376.     if {[lsearch -exact $caps $letter] > -1} {  
  377.     return 1 } {
  378.     return 0 }
  379. }
  380.  
  381. # Check for +anti-* protection
  382. proc mcc:check:cs_anti {nick uhost handle channel type text} {
  383.     global mcc_anti botnick
  384.    
  385.     if {[isbotnick $nick] || ![validchan $channel]} { return }
  386.    
  387.     if {![matchattr $handle bfo|fo $channel]} {
  388.         set text [join [lrange [split $text] 0 end]]
  389.         set banreason "You broke the channel rules. See PRV for more information."
  390.         set msgreason ""
  391.         if {[lsearch -exact "pub ctcp notc" $type] > "-1"} {
  392.             if {[channel get $channel anti-spam]} {
  393.                 set spam ""
  394.                 if {[lsearch -all -inline -glob -nocase $text "*http*://*"] != ""} {
  395.                     lappend spam [join [lsearch -all -inline -glob -nocase $text "*http*://*"]]
  396.                 }
  397.                 if {[lsearch -all -inline -glob -nocase $text "*www.*"] != ""} {
  398.                     lappend spam [join [lsearch -all -inline -glob -nocase $text "*www.*"]]
  399.                 }
  400.                 if {[lsearch -all -inline -glob -nocase $text "*#??*"] != ""} {
  401.                     lappend spam [join [lsearch -all -inline -glob -nocase $text "*#??*"]]
  402.                 }
  403.                 if {$spam != ""} {
  404.                     lappend msgreason "Spamming is not allowed in $channel : [join $spam ", "]"
  405.                 }
  406.             }
  407.             if {[channel get $channel anti-notice] && $type == "notc"} {
  408.                 lappend msgreason "Channel noticing is not allowed in $channel"
  409.             }
  410.             if {[channel get $channel anti-ctcp] && $type == "ctcp"} {
  411.                 lappend msgreason "Channel ctcping is not allowed in $channel"
  412.             }
  413.             if {[channel get $channel anti-color] && [string match *\x03* $text]} {
  414.                 lappend msgreason "Using color is not allowed in $channel"
  415.             }
  416.             if {[channel get $channel anti-bold] && [string match *\002* $text]} {
  417.                 lappend msgreason "Using bold is not allowed in $channel"
  418.             }
  419.             if {[channel get $channel anti-underline] && [string match *\037* $text]} {
  420.                 lappend msgreason "Using underline is not allowed in $channel"
  421.             }
  422.             if {[channel get $channel anti-caps]} {
  423.                 set len [string length $text]
  424.                 set cnt 0
  425.                 set capcnt 0
  426.                 while {$cnt < $len} {
  427.                         if {[mcc:check:isupper [string index $text $cnt]]} {
  428.                             incr capcnt
  429.                         }
  430.                         incr cnt
  431.                 }
  432.                 if {$capcnt > 15 && 100*$capcnt/$len > 60} {
  433.                     lappend msgreason "Using CAPS is not allowed in $channel"
  434.                 }
  435.             }
  436.             if {[channel get $channel anti-badword]} {
  437.                 set bword ""
  438.                 foreach word [channel get $channel badword-text] {
  439.                     set wrd [lsearch -all -inline -glob -nocase $text $word]
  440.                     if {$wrd != ""} {
  441.                         lappend bword $wrd
  442.                     }
  443.                 }
  444.                 if {$bword != ""} {
  445.                     lappend msgreason "Swearing is not allowed in $channel : [join $bword ", "]"
  446.                 }
  447.             }
  448.         }
  449.         if {$type == "whois"} {
  450.             if {[channel get $channel anti-badwhois]} {
  451.                 set wnick ""
  452.                 set wident ""
  453.                 foreach word [channel get $channel badword-text] {
  454.                     if {[string match $word $nick]} {
  455.                         lappend msgreason "Please change your nickname before entering $channel again."
  456.                         break
  457.                     }
  458.                     if {[string match $word [lindex [split $uhost @] 0]]} {
  459.                         lappend msgreason "Please change your identd before entering $channel again."
  460.                         break
  461.                     }
  462.                 }
  463.                 if {$wnick != ""} {
  464.                     lappend msgreason "Please change your nickname before entering $channel again."
  465.                 }
  466.                 if {$wident != ""} {
  467.                     lappend msgreason "Please change your identd before entering $channel again."
  468.                 }
  469.             }
  470.             if {[channel get $channel anti-badchan]} {
  471.                 set clist ""
  472.                 foreach chn [channel get $channel badchan-text] {
  473.                     set who [join [lsearch -all -inline -glob -nocase $text $chn]]
  474.                     if {$who != ""} {
  475.                         lappend clist $who
  476.                     }
  477.                 }
  478.                 if {$clist != ""} {
  479.                     lappend msgreason "Leave channels [join $clist ", "] before joining $channel"
  480.                 }
  481.             }
  482.         }
  483.         if {$type == "leave"} {
  484.             if {[channel get $channel anti-badpart]} {
  485.                 set bword ""
  486.                 foreach word [channel get $channel badword-text] {
  487.                     set wrd [lsearch -all -inline -glob -nocase $text $word]
  488.                     if {$wrd != ""} {
  489.                         lappend bword $wrd
  490.                     }
  491.                 }
  492.                 if {$bword != ""} {
  493.                     lappend msgreason "Never part $channel saying: [join $bword ", "]"
  494.                 }
  495.             }
  496.             if {[channel get $channel anti-flyby]} {
  497.                 if {[info exists mcc_anti(flyby@$nick)]} {
  498.                     lappend msgreason "Banned for fast join/part on $channel"
  499.                 }
  500.             }
  501.         }
  502.         if {$type == "quit"} {
  503.             if {[channel get $channel anti-badpart]} {
  504.                 foreach word [channel get $channel badword-text] {
  505.                     if {[lsearch -all -inline -glob -nocase $text $word] > "-1"} {
  506.                         newchanban $channel [maskhost "$nick!$uhost" [channel get $channel ban-type]] $botnick $banreason [channel get $channel ban-time]
  507.                         return 1
  508.                     }
  509.                 }
  510.             }
  511.         }
  512.         if {$msgreason != ""} {
  513.             newchanban $channel [maskhost "$nick!$uhost" [channel get $channel ban-type]] $botnick $banreason [channel get $channel ban-time]
  514.             foreach msg $msgreason {
  515.                 putserv "PRIVMSG $nick :$msg"
  516.             }
  517.             return 1
  518.         }
  519.     }
  520.     if {[channel get $channel voicetalk] && ![isop $nick $channel] && ![isvoice $nick $channel] && [botisop $channel]} {
  521.         pushmode $channel +v $nick
  522.     }
  523. }
  524.  
  525. # MaskHost Proc
  526. proc mcc:proc:maskhost {uhost} {
  527.     global mcc
  528.    
  529.     if {[string match -nocase $mcc(regusermask) $uhost]} {
  530.         return "*!*@[lindex [split $uhost @] 1]"
  531.     }
  532.     return "*!$uhost"
  533. }
  534.  
  535. # New BotNick Proc
  536. proc mcc:proc:newnick {newnick} {
  537.     global nick
  538.    
  539.     set nick $newnick
  540. }
  541.  
  542. # Server Quit Proc
  543. bind sign - * mcc:proc:quit
  544. proc mcc:proc:quit {nick uhost handle channel text} {
  545.    
  546.     mcc:check:cs_anti $nick $uhost $handle $channel "quit" $text
  547.     if {[validuser $handle]} {
  548.         chattr $handle -Q
  549.     }
  550. }
  551.  
  552. # Channel Joins Proc
  553. bind join - * mcc:proc:join
  554. proc mcc:proc:join {nick uhost handle channel} {
  555.     global mcc mcc_anti
  556.    
  557.     if {[isbotnick $nick]} { return }
  558.    
  559.     if {[channel get $channel anti-flyby]} {
  560.         set mcc_anti(flyby@$nick) $channel
  561.         utimer 10 [list unset -nocomplain mcc_anti(flyby@$nick)]
  562.     }
  563.     if {[channel get $channel autotopic] && [channel get $channel topic-text] != "" && [topic $channel] == ""} {
  564.         putserv "TOPIC $channel :[join [lrange [split [channel get $channel topic-text]] 1 end]]"
  565.     }
  566.     if {[channel get $channel anti-badchan]} {
  567.         putserv "WHOIS $nick"
  568.         set mcc(whois@$nick) $channel
  569.     }
  570.     if {[channel get $channel greet] && [channel get $channel greet-text] != "" && ![matchattr $handle b]} {
  571.         foreach line [channel get $channel greet-text] {
  572.             putserv "NOTICE $nick :[mcc:check:greet $nick $uhost $handle $channel $line]"
  573.         }
  574.     }
  575.     if {[channel get $channel limit]} { mcc:check:limit $channel }
  576.     if {[channel get $channel autovoice]} { pushmode $channel +v $nick }
  577. }
  578.  
  579. # Channel Part Proc
  580. bind part - * mcc:proc:part
  581. proc mcc:proc:part {nick uhost handle channel text} {
  582.    
  583.     if {[isbotnick $nick]} { return }
  584.    
  585.     if {[channel get $channel limit]} { mcc:check:limit $channel }
  586.     mcc:check:cs_anti $nick $uhost $handle $channel "leave" $text
  587. }
  588.  
  589. # Channel Modes Proc
  590. bind mode - * mcc:proc:mode
  591. proc mcc:proc:mode {nick uhost handle channel mode target} {
  592.     global mcc botname
  593.    
  594.     switch -- $mode {
  595.         "+s" - "+p" {
  596.             channel set $channel +secret
  597.         }
  598.         "-s" - "-p" {
  599.             channel set $channel -secret
  600.         }
  601.     }
  602. }
  603.  
  604. # Nick Change Proc
  605. bind nick - * mcc:proc:nick
  606. proc mcc:proc:nick {nick uhost handle channel newnick} {
  607.    
  608.     mcc:check:cs_anti $newnick $uhost $handle $channel "whois" ""
  609. }
  610.  
  611. # PUBM Proc
  612. bind pubm - * mcc:proc:pubm
  613. proc mcc:proc:pubm {nick uhost handle channel text} {
  614.  
  615.     mcc:check:cs_anti $nick $uhost $handle $channel "pub" $text
  616. }
  617.  
  618. # CTCP Proc
  619. bind ctcp - * mcc:proc:ctcp
  620. proc mcc:proc:ctcp {nick uhost handle dest keyword text} {
  621.    
  622.     if {$keyword != "ACTION"} {
  623.         mcc:check:cs_anti $nick $uhost $handle $dest "ctcp" $text
  624.     }
  625. }
  626.  
  627. # NOTC Proc
  628. bind notc - * mcc:proc:notc
  629. proc mcc:proc:notc {nick uhost handle text dest} {
  630.    
  631.     mcc:check:cs_anti $nick $uhost $handle $dest "notc" $text
  632. }
  633.  
  634. # BotNet Proc
  635. bind link - * mcc:proc:link
  636. proc mcc:proc:link {bot via} {
  637.    
  638.     mcc:msg:debug "\[\002BOTNET\002\] Linked to $bot via $via."
  639. }
  640. bind disc - * mcc:proc:unlink
  641. proc mcc:proc:unlink {bot} {
  642.    
  643.     mcc:msg:debug "\[\002BOTNET\002\] Unlinked from $bot."
  644. }
  645.  
  646. # RAW Proc
  647. bind raw - 319 mcc:proc:raw:whois
  648. proc mcc:proc:raw:whois {from key chans} {
  649.     global mcc
  650.    
  651.     set nick [lindex [join $chans] 1]
  652.     set chans [join [lrange [split $chans] 2 end]]
  653.     set text ""
  654.     if {[info exists mcc(whois@$nick)]} {
  655.         foreach chan $chans {
  656.             lappend text [string trimleft $chan ":@+"]
  657.         }
  658.         mcc:check:cs_anti $nick [getchanhost $nick $mcc(whois@$nick)] [nick2hand $nick] $mcc(whois@$nick) "whois" $text
  659.         unset -nocomplain mcc(whois@$nick)
  660.     }
  661. }
  662.  
  663. # Custom Flood Handler Proc
  664. bind flud - * mcc:proc:flood_handler
  665. proc mcc:proc:flood_handler {nick uhost handle type channel} {
  666.     global botnick mcc
  667.    
  668.     if {[matchattr $handle bfo|f $channel]} { return 1 }
  669.    
  670.     switch $type {
  671.         "msg" {
  672.             newignore "*!*@[lindex [split $uhost @] 1]" $botnick "MSG FLOOD" 60
  673.             mcc:msg:debug "\[\002FLOOD\002\] $nick!$uhost ignored. (MSG FLOOD)"
  674.             return 1
  675.         }
  676.         "pub" {
  677.             newchanban $channel [maskhost "$nick!$uhost" [channel get $channel ban-type]] $botnick $mcc(flood@chan) [channel get $channel ban-time]
  678.             return 1
  679.         }
  680.         "ctcp" {
  681.             newignore "*!*@[lindex [split $uhost @] 1]" $botnick "CTCP FLOOD" 60
  682.             foreach chan [channels] {
  683.                 newchanban $chan [maskhost "$nick!$uhost" [channel get $chan ban-type]] $botnick $mcc(flood@ctcp) [channel get $chan ban-time]
  684.             }
  685.             mcc:msg:debug "\[\002FLOOD\002\] $nick!$uhost ignored and banned. (CTCP FLOOD)"
  686.             return 1
  687.         }
  688.         "join" {
  689.             newchanban $channel [maskhost "$nick!$uhost" [channel get $channel ban-type]] $botnick $mcc(flood@join) [channel get $channel ban-time]
  690.             if {[botisop $channel]} {
  691.                 putserv "NOTICE $channel :Join flood detected setting channel to +i"
  692.                 putnow "MODE $channel +i"
  693.                 timer 2 [list pushmode $channel -i]
  694.             }
  695.             return 1
  696.         }
  697.         "deop" {
  698.             newchanban $channel [maskhost "$nick!$uhost" [channel get $channel ban-type]] $botnick $mcc(flood@deop) [channel get $channel ban-time]
  699.             return 1
  700.         }
  701.         "kick" {
  702.             newchanban $channel [maskhost "$nick!$uhost" [channel get $channel ban-type]] $botnick $mcc(flood@kick) [channel get $channel ban-time]
  703.             return 1
  704.         }
  705.         "nick" {
  706.             newchanban $channel [maskhost "$nick!$uhost" [channel get $channel ban-type]] $botnick $mcc(flood@nick) [channel get $channel ban-time]
  707.             return 1
  708.         }
  709.     }
  710. }
  711.  
  712. # Custom Need Handler Proc
  713. bind need - * mcc:proc:need
  714. proc mcc:proc:need {channel type} {
  715.     global mcc botnick network
  716.    
  717.     switch -- $type {
  718.         "op" {
  719.             putallbots "MCC-BOTNET $network op $channel"
  720.             return
  721.         }
  722.         "unban" {
  723.             putallbots "MCC-BOTNET $network unban $channel"
  724.             return
  725.         }
  726.         "invite" {
  727.             putallbots "MCC-BOTNET $network invite $channel"
  728.             return
  729.         }
  730.         "limit" {
  731.             mcc:proc:need $channel "invite"
  732.         }
  733.         "key" {
  734.             mcc:proc:need $channel "invite"
  735.         }
  736.     }
  737. }
  738.  
  739. # BOTNET Need Respond Porc
  740. bind bot - MCC-BOTNET mcc:proc:need_botnet
  741. proc mcc:proc:need_botnet {bot key text} {
  742.     global network
  743.    
  744.     set net [lindex [split $text] 0]
  745.     if {[string tolower $network] != [string tolower $net]} { return }
  746.     set req [lindex [split $text] 1]
  747.     set chn [lindex [split $text] 2]
  748.     if {![validchan $chn]} { return }
  749.     if {![botisop $chn]} { return }
  750.    
  751.     switch -- $req {
  752.         "op" {
  753.             pushmode $chn +o [hand2nick $bot]
  754.             return
  755.         }
  756.         "unban" {
  757.             set bhost "[hand2nick $bot]![getchanhost [hand2nick $bot]]"
  758.             foreach ban [chanbans $chn] {
  759.                 set host [lindex $ban 0]
  760.                 if {[string match -nocase $host $bhost]} {
  761.                     pushmode $chn -b $host
  762.                 }
  763.             }
  764.             foreach ban [banlist $chn] {
  765.                 set host [lindex $ban 0]
  766.                 if {[string match -nocase $host $bhost]} {
  767.                     killchanban $chn $host
  768.                     return
  769.                 }
  770.             }
  771.             foreach ban [banlist] {
  772.                 set host [lindex $ban 0]
  773.                 if {[string match -nocase $host $bhost]} {
  774.                     killban $host
  775.                     return
  776.                 }
  777.             }
  778.             return
  779.         }
  780.         "invite" {
  781.             mcc:proc:need_botnet $bot $key "$net unban $chn"
  782.             putserv "INVITE [hand2nick $bot] $chn"
  783.             return
  784.         }
  785.     }
  786. }
  787.  
  788. # -------------------------------------
  789. # User Registration
  790. # -------------------------------------
  791. bind msg - hello mcc:cmd:msg_hello
  792. bind msg - reguser mcc:cmd:msg_hello
  793. proc mcc:cmd:msg_hello {nick uhost handle text} {
  794.     global mcc botnick lastbind handlen network
  795.    
  796.     if {$mcc(selfreguser) != "1" && [userlist] != ""} { return }
  797.     if {[validuser $handle]} {
  798.         puthelp "NOTICE $nick :You can not register a new user. You are recognized as \002$handle\002."
  799.         puthelp "NOTICE $nick :If this is not you join $mcc(home@bl) and contact a staff member. Thank You."
  800.         return
  801.     }
  802.    
  803.     set username [lindex [join $text] 0]
  804.     set password [lindex [join $text] 1]
  805.    
  806.     if {$username == "" || $password == ""} {
  807.         puthelp "NOTICE $nick :Error. Usage: /msg $botnick $lastbind <username> <password>"
  808.         return
  809.     }
  810.     set usernamepb [regsub -all -nocase {[a-z0-9]} $username ""]
  811.     if {[string length $username] < 2 || [string length $username] > $handlen || $usernamepb != ""} {
  812.         puthelp "NOTICE $nick :Error. Username must be \002BETWEEN\002 2 and $handlen characters long and can contain \002ONLY\002 letters and numbers."
  813.         return
  814.     }
  815.     if {[validuser $username]} {
  816.         puthelp "NOTICE $nick :Error. Username is unavailable. Please choose another one."
  817.         return
  818.     }
  819.     if {[string length $password] < 6} {
  820.         puthelp "NOTICE $nick :Error. Password must be \002AT LEAST\002 6 characters long for security reasons."
  821.         return
  822.     }
  823.    
  824.     set hostname [mcc:proc:maskhost $uhost]
  825.    
  826.     if {[adduser $username $hostname]} {
  827.         setuser $username PASS $password
  828.         puthelp "NOTICE $nick :You have been registered as \002$username\002 with password \002$password\002."
  829.         puthelp "NOTICE $nick :Before anything else login using \002/msg $botnick login\002"
  830.         puthelp "NOTICE $nick :You can change your password at any time using \002/msg $botnick newpass\002"
  831.         mcc:msg:debug "\[\002REGUSER\002\] $nick registered as $username ($hostname)"
  832.     } else {
  833.         puthelp "NOTICE $nick :Registration error! Please join $mcc(home@bl) and contact a staff member. Thank You."
  834.         mcc:msg:debug "\[\002REGUSER\002\] Error. $nick ($uhost) tried to register $username with $password"
  835.     }
  836.     if {[userlist] == $username} {
  837.         chattr $username +hjlmnoptvx
  838.         puthelp "NOTICE $nick :***POOF*** You are now the owner of this bot!"
  839.     }
  840. }
  841.  
  842. # -------------------------------------
  843. # New Password
  844. # -------------------------------------
  845. bind msg - newpass mcc:cmd:msg_newpass
  846. proc mcc:cmd:msg_newpass {nick uhost handle text} {
  847.     global botnick
  848.  
  849.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  850.    
  851.     set password [lindex [join $text] 0]
  852.     set newpassword [lindex [join $text] 1]
  853.    
  854.     if {$password == "" || $newpassword == ""} {
  855.         puthelp "NOTICE $nick :Error. Usage: /msg $botnick newpass <old password> <new password>"
  856.         return
  857.     }
  858.     if {![passwdok $handle $password]} {
  859.         puthelp "NOTICE $nick :Error. Old password dose not match database."
  860.         return
  861.     }
  862.     if {[string length $newpassword] < 6} {
  863.         puthelp "NOTICE $nick :Error. Password must be \002AT LEAST\002 6 characters long for security reasons."
  864.         return
  865.     }
  866.     setuser $handle PASS $newpassword
  867.     puthelp "NOTICE $nick :Password set to: \002$newpassword\002"
  868.     mcc:msg:debug "\[\002NEWPASS\002\] $nick/\002$handle\002 succesfully changed his password."
  869. }
  870.  
  871. # -------------------------------------
  872. # Log In
  873. # -------------------------------------
  874. bind msg - auth mcc:cmd:msg_login
  875. bind msg - login mcc:cmd:msg_login
  876. proc mcc:cmd:msg_login {nick uhost handle text} {
  877.     global botnick mcc
  878.    
  879.     if {[validuser $handle] && [matchattr $handle Q]} {
  880.         puthelp "NOTICE $nick :You are already logged in as \002$handle\002."
  881.         puthelp "NOTICE $nick :If this is not you join $mcc(home@bl) and contact a staff member. Thank You."
  882.         return
  883.     }
  884.    
  885.     set username [lindex [join $text] 0]
  886.     set password [lindex [join $text] 1]
  887.    
  888.     if {$username == "" || $password == ""} {
  889.         puthelp "NOTICE $nick :Error. Usage: /msg $botnick login <username> <password>"
  890.         return
  891.     }
  892.     if {![validuser $username]} {
  893.         puthelp "NOTICE $nick :Error. Unknown username \002$username\002."
  894.         return
  895.     }
  896.     if {![passwdok $username $password]} {
  897.         puthelp "NOTICE $nick :Error. Wrong password."
  898.         return
  899.     }
  900.    
  901.     set hostname [mcc:proc:maskhost $uhost]
  902.    
  903.     setuser $username HOSTS $hostname
  904.     chattr $username +Q
  905.     puthelp "NOTICE $nick :Authentication successful!"
  906.     puthelp "NOTICE $nick :Do not give out your password to anyone and remember that no administrator of this bot will ever ask you for it."
  907.     mcc:msg:debug "\[\002LOGIN\002\] Authentication successful $nick/\002$username\002!"
  908. }
  909.  
  910. # -------------------------------------
  911. # Main Script Command List
  912. # -------------------------------------
  913.  
  914. # Catch BotNick and send the command to the correct bind
  915. bind pubm - "% *" mcc:cmd:botnick_reroute
  916. proc mcc:cmd:botnick_reroute {nick uhost handle channel text} {
  917.     global mcc
  918.    
  919.     set sh [string tolower [lindex [split $text] 0]]
  920.    
  921.     if {![isbotnick $sh]} { return }
  922.    
  923.     set cmd [string tolower [lindex [split $text] 1]]
  924.     set rest [join [lrange [split $text] 2 end]]
  925.    
  926.     if {[catch {mcc:cmd:$cmd $nick $uhost $handle $channel $rest}]} { return }
  927. }
  928.  
  929. # Catch all msgs and send the command to the correct bind
  930. bind msgm - * mcc:cmd:msg_reroute
  931. proc mcc:cmd:msg_reroute {nick uhost handle text} {
  932.     global mcc lastbind botnick
  933.    
  934.     set cmd [string tolower [lindex [split $text] 0]]
  935.     set chan [string tolower [lindex [split $text] 1]]
  936.    
  937.     set exepts "pass login auth newpass hello reguser notes"
  938.     if {[lsearch -exact $exepts $cmd] != "-1"} { return }
  939.    
  940.     if {$chan == ""} {
  941.         puthelp "PRIVMSG $nick :Error. Usage: /msg $botnick [lindex [split $text] 0] <#channel> \[options\]"
  942.         return
  943.     }
  944.     if {![validchan $chan]} {
  945.         puthelp "PRIVMSG $nick :Error. I`m not monitoring channel: $chan"
  946.         return
  947.     }
  948.    
  949.     set rest [join [lrange [split $text] 2 end]]
  950.    
  951.     if {[catch {mcc:cmd:$cmd $nick $uhost $handle $chan $rest}]} { return }
  952. }
  953.  
  954. #
  955. # Commands Level: NONE (-)
  956. #
  957.  
  958. # HELP Command
  959. bind pub -|- $mcc(trigger)help mcc:cmd:help
  960. proc mcc:cmd:help {nick uhost handle channel text} {
  961.     global mcc
  962.    
  963.     putserv "NOTICE $nick :Go to http://BotZone.Tk for more help or use $mcc(trigger)commands"
  964. }
  965.  
  966. # COMMANDS Command
  967. bind pub -|- $mcc(trigger)commands mcc:cmd:commands
  968. proc mcc:cmd:commands {nick uhost handle channel text} {
  969.     global mcc
  970.    
  971.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  972.    
  973.     putserv "NOTICE $nick :No Access    (-|-): help commands dbcount uptime version date channels whois set ssh dns ipinfo"
  974.     putserv "NOTICE $nick :ChanVoice    (-|v): voice devoice users del"
  975.     putserv "NOTICE $nick :ChanOp       (-|o): op deop invite chaninfo topic kick ban unban banlist mode add"
  976.     putserv "NOTICE $nick :ChanMaster   (-|m): chanset cycle"
  977.     putserv "NOTICE $nick :ChanOwner    (-|n): say act join part greet"
  978.     putserv "NOTICE $nick :GlobalOp     (o|-): ignore unignore ignorelist host broadcast"
  979.     putserv "NOTICE $nick :GlobalMaster (m|-): msg"
  980.     putserv "NOTICE $nick :GlobalOwner  (n|-): rehash save restart jump"
  981.     putserv "NOTICE $nick :BotOwner       (n): nick botnet die"
  982. }
  983.  
  984. # DBCOUNT Command
  985. bind pub -|- $mcc(trigger)dbcount mcc:cmd:dbcount
  986. proc mcc:cmd:dbcount {nick uhost handle channel text} {
  987.    
  988.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  989.    
  990.     putserv "NOTICE $nick :Monitoring a total of [countusers] users in my database. \( [llength [userlist o]] Global Users \)"
  991. }
  992.  
  993. # UPTIME Command
  994. bind pub -|- $mcc(trigger)uptime mcc:cmd:uptime
  995. proc mcc:cmd:uptime {nick uhost handle channel text} {
  996.     global uptime server-online
  997.    
  998.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  999.    
  1000.     putserv "NOTICE $nick :Started [lrange [duration [expr [unixtime] - $uptime]] 0 3] ago and OnLine for [lrange [duration [expr [unixtime] - ${server-online}]] 0 3]"
  1001. }
  1002.  
  1003. # VERSION Command
  1004. bind pub -|- $mcc(trigger)version mcc:cmd:version
  1005. proc mcc:cmd:version {nick uhost handle channel text} {
  1006.     global version mcc
  1007.    
  1008.     putserv "NOTICE $nick :eggdrop[lindex $version 0] :: MCC $mcc(scriptversion) (c) dirty Inc."
  1009. }
  1010.  
  1011. # DATE Command
  1012. bind pub -|- $mcc(trigger)date mcc:cmd:date
  1013. proc mcc:cmd:date {nick uhost handle channel text} {
  1014.    
  1015.     putserv "NOTICE $nick :Today is [strftime "%d %b %Y" [unixtime]] and the time is [strftime "%H:%M" [unixtime]]"
  1016. }
  1017.  
  1018. # CHAT Command
  1019. bind pub -|- $mcc(trigger)chat mcc:cmd:chat
  1020. proc mcc:cmd:chat {nick uhost handle channel text} {
  1021.     global mcc nat-ip my-ip
  1022.    
  1023.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1024.    
  1025.     if {![matchattr $handle p]} {
  1026.         putserv "NOTICE $nick :I don`t wanna chat with you."
  1027.         return
  1028.     }
  1029.     if {[hand2idx $handle] != "-1" } {
  1030.         putserv "NOTICE $nick :You are already in the partyline."
  1031.         return
  1032.     }
  1033.     if {$mcc(telnetport) < "1024"} {
  1034.         putserv "NOTICE $nick :Sorry, your host isn't reachable at this time."
  1035.         return
  1036.     }
  1037.     if {${nat-ip} == ""} {
  1038.         set ip ${my-ip}
  1039.     } else {
  1040.         set ip ${nat-ip}
  1041.     }
  1042.     if {$ip == ""} {
  1043.         set ip [format %u [eval format 0x%02x%02x%02x%02x [split "127.0.0.1" .]]]
  1044.     } else {
  1045.         set ip [format %u [eval format 0x%02x%02x%02x%02x [split $ip .]]]
  1046.     }
  1047.     putserv "PRIVMSG $nick :\001DCC CHAT chat $ip $mcc(telnetport)\001"
  1048.     putserv "NOTICE $nick :DCC Chat - Initializing.."
  1049. }
  1050.  
  1051. # CHANNELS Command
  1052. bind pub -|- $mcc(trigger)channels mcc:cmd:channels
  1053. proc mcc:cmd:channels {nick uhost handle channel text} {
  1054.     global mcc
  1055.    
  1056.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1057.    
  1058.     set chanlist "Monitoring [llength [channels]] channels: "
  1059.     foreach chn [channels] {
  1060.         if {![matchattr $handle o] && [channel get $chn secret]} { continue }
  1061.         set chanstatus ""
  1062.         if {[channel get $chn inactive]} {
  1063.             append chanstatus "i"
  1064.         }
  1065.         if {[channel get $chn secret]} {
  1066.             append chanstatus "s"
  1067.         }
  1068.         if {![botisop $chn]} {
  1069.             append chanstatus "\0034@\003"
  1070.         }
  1071.         if {$chanstatus != ""} {
  1072.             append chanlist "\[$chanstatus\]"
  1073.         }
  1074.         if {![botonchan $chn] && ![channel get $chn inactive]} {
  1075.             append chanlist "\002\0034$chn\003\002 "
  1076.         } else {
  1077.             append chanlist "$chn "
  1078.         }
  1079.     }
  1080.     putserv "NOTICE $nick :$chanlist"
  1081. }
  1082.  
  1083. # WHOIS Command
  1084. bind pub -|- $mcc(trigger)whois mcc:cmd:whois
  1085. proc mcc:cmd:whois {nick uhost handle channel text} {
  1086.    
  1087.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1088.    
  1089.     set who [lindex [join $text] 0]
  1090.    
  1091.     if {$who == ""} {
  1092.         set who $handle
  1093.     }
  1094.     if {[onchan $who $channel]} {
  1095.         set who [nick2hand $who]
  1096.     }
  1097.     if {![validuser $who]} {
  1098.         putserv "NOTICE $nick :Unknow user in the database."
  1099.         return
  1100.     }
  1101.     set automode "None"
  1102.     if {[matchattr $who &g $channel]} {
  1103.         set automode "Voice"
  1104.     }
  1105.     if {[matchattr $who &a $channel]} {
  1106.         set automode "Op"
  1107.     }
  1108.     if {[getuser $who XTRA PERMIDENT] == "1"} {
  1109.         set permident "On"
  1110.     } else {
  1111.         set permident "Off"
  1112.     }
  1113.     putserv "NOTICE $nick :\002Handle\002: $who \002Access\002: [mcc:check:level $who $channel] ([chattr $who $channel])"
  1114.     putserv "NOTICE $nick :\002PermIdent\002: $permident \002AutoMode\002: $automode"
  1115.     if {[matchattr $handle o]} {
  1116.         set laston [getuser $who LASTON]
  1117.         if {$laston == ""} {
  1118.             set laston "No Records"
  1119.         } else {
  1120.             set laston "[strftime "%d %b %Y %H:%M" [lindex [split $laston] 0]] [lindex [split $laston] 1]"
  1121.         }
  1122.         putserv "NOTICE $nick :\002Last Seen\002: $laston \002Hosts\002: [getuser $who HOSTS]"
  1123.     }
  1124. }
  1125.  
  1126. # SET Command
  1127. bind pub -|- $mcc(trigger)set mcc:cmd:set
  1128. proc mcc:cmd:set {nick uhost handle channel text} {
  1129.     global mcc
  1130.    
  1131.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1132.    
  1133.     set who [lindex [join $text] 0]
  1134.     set why [lindex [join $text] 1]
  1135.     set whyy [join [lrange [split $text] 1 end]]
  1136.    
  1137.     switch -- [string tolower $who] {
  1138.         "lang" {
  1139.             putserv "NOTICE $nick :This function is not available."
  1140.             return
  1141.         }
  1142.         "output" - "reply" {
  1143.             putserv "NOTICE $nick :This function is not available."
  1144.             return
  1145.         }
  1146.         "permident" {
  1147.             if {[string tolower $why] == "on"} {
  1148.                 setuser $handle XTRA PERMIDENT "1"
  1149.                 putserv "NOTICE $nick :Permanent Identification is now ON."
  1150.                 return
  1151.             }
  1152.             if {[string tolower $why] == "off"} {
  1153.                 setuser $handle XTRA PERMIDENT "0"
  1154.                 putserv "NOTICE $nick :Permanent Identification is now OFF."
  1155.                 return
  1156.             }
  1157.             putserv "NOTICE $nick :Error. Usage: $mcc(trigger)set permident <on|off>"
  1158.             return
  1159.         }
  1160.         "automode" {
  1161.             if {[string tolower $why] == "op"} {
  1162.                 if {![matchattr $handle &o $channel]} {
  1163.                     putserv "NOTICE $nick :Error. You don`t have enough access."
  1164.                     return
  1165.                 }
  1166.                 chattr $handle -|+a-g $channel
  1167.                 putserv "NOTICE $nick :Set AutoMode to OP on channel $channel"
  1168.                 return
  1169.             }
  1170.             if {[string tolower $why] == "voice"} {
  1171.                 if {![matchattr $handle &v $channel]} {
  1172.                     putserv "NOTICE $nick :Error. You don`t have enough access."
  1173.                     return
  1174.                 }
  1175.                 chattr $handle -|+g-a $channel
  1176.                 putserv "NOTICE $nick :Set AutoMode to VOICE on channel $channel"
  1177.                 return
  1178.             }
  1179.             if {[string tolower $why] == "none"} {
  1180.                 if {![matchattr $handle &v $channel]} {
  1181.                     putserv "NOTICE $nick :Error. You don`t have enough access."
  1182.                     return
  1183.                 }
  1184.                 chattr $handle -|-ga $channel
  1185.                 putserv "NOTICE $nick :Set AutoMode to NONE on channel $channel"
  1186.                 return
  1187.             }
  1188.             putserv "NOTICE $nick :Error. Usage: $mcc(trigger)set automode <none|voice|op>"
  1189.             return
  1190.         }
  1191.         "modify" {
  1192.             putserv "NOTICE $nick :This function is not available."
  1193.             return
  1194.         }
  1195.         "handle" {
  1196.             if {$why == ""} {
  1197.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)set handle <new handle>"
  1198.                 return
  1199.             }
  1200.             if {[string length $why] < 2} {
  1201.                 putserv "NOTICE $nick :Error. New handle must be atlist 2 characters."
  1202.                 return
  1203.             }
  1204.             if {[validuser $why]} {
  1205.                 putserv "NOTICE $nick :Error. New handle $why is already in use."
  1206.                 return
  1207.             }
  1208.             if {[chhandle $handle $why]} {
  1209.                 putserv "NOTICE $nick :Your new handle is now \002$why\002."
  1210.                 return
  1211.             }
  1212.             putserv "NOTICE $nick :Error. Could not change your handle. Please contact $mcc(home@bl) staff for help."
  1213.             mcc:msg:debug "\[\002SET\002\] Error changing handle from $handle to $why for $nick."
  1214.             return
  1215.         }
  1216.     }
  1217.     putserv "NOTICE $nick :Error. Usage: $mcc(trigger)set <lang|output|permident|automode|modify|handle> <option>"
  1218. }
  1219.  
  1220. #
  1221. # Commands Level: CHANNEL VOICE (-|v)
  1222. #
  1223.  
  1224. # VOICE Commands
  1225. bind pub o|v $mcc(trigger)voice mcc:cmd:voice
  1226. proc mcc:cmd:voice {nick uhost handle channel text} {
  1227.    
  1228.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1229.     if {![matchattr $handle o|v $channel]} { return }
  1230.    
  1231.     set who [join [lrange [split $text] 0 end]]
  1232.    
  1233.     if {$who == ""} {
  1234.         pushmode $channel +v $nick
  1235.     } else {
  1236.         foreach user $who {
  1237.             pushmode $channel +v $user
  1238.         }
  1239.     }
  1240. }
  1241.  
  1242. # DEVOICE Command
  1243. bind pub o|v $mcc(trigger)devoice mcc:cmd:devoice
  1244. proc mcc:cmd:devoice {nick uhost handle channel text} {
  1245.    
  1246.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1247.     if {![matchattr $handle o|v $channel]} { return }
  1248.    
  1249.     set who [join [lrange [split $text] 0 end]]
  1250.    
  1251.     if {$who == ""} {
  1252.         pushmode $channel -v $nick
  1253.     } else {
  1254.         foreach user $who {
  1255.             pushmode $channel -v $user
  1256.         }
  1257.     }
  1258. }
  1259.  
  1260. # USERS Command
  1261. bind pub o|v $mcc(trigger)users mcc:cmd:users
  1262. proc mcc:cmd:users {nick uhost handle channel text} {
  1263.    
  1264.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1265.     if {![matchattr $handle o|v $channel]} { return }
  1266.    
  1267.     set users ""
  1268.     set usersv ""
  1269.     set userso ""
  1270.     set usersm ""
  1271.     set usersn ""
  1272.     set usertot "0"
  1273.     set useron "0"
  1274.     foreach user [userlist &v $channel] {
  1275.         if {[matchattr $user &n $channel]} {
  1276.             if {[onchan [hand2nick $user] $channel]} {
  1277.                 lappend usersn "$user/\002[hand2nick $user]\002"
  1278.                 incr useron
  1279.             } else {
  1280.                 lappend usersn "$user"
  1281.             }
  1282.             incr usertot
  1283.             continue
  1284.         }
  1285.         if {[matchattr $user &m $channel]} {
  1286.             if {[onchan [hand2nick $user] $channel]} {
  1287.                 lappend usersm "$user/\002[hand2nick $user]\002"
  1288.                 incr useron
  1289.             } else {
  1290.                 lappend usersm "$user"
  1291.             }
  1292.             incr usertot
  1293.             continue
  1294.         }
  1295.         if {[matchattr $user &o $channel]} {
  1296.             if {[onchan [hand2nick $user] $channel]} {
  1297.                 lappend userso "$user/\002[hand2nick $user]\002"
  1298.                 incr useron
  1299.             } else {
  1300.                 lappend userso "$user"
  1301.             }
  1302.             incr usertot
  1303.             continue
  1304.         }
  1305.         if {[matchattr $user &v $channel]} {
  1306.             if {[onchan [hand2nick $user] $channel]} {
  1307.                 lappend usersv "$user/\002[hand2nick $user]\002"
  1308.                 incr useron
  1309.             } else {
  1310.                 lappend usersv "$user"
  1311.             }
  1312.             incr usertot
  1313.             continue
  1314.         }
  1315.     }
  1316.     if {$usersn != ""} {
  1317.         lappend users "\[\002\037ChanOwner\002\037\] $usersn"
  1318.     }
  1319.     if {$usersm != ""} {
  1320.         lappend users "\[\002\037ChanMaster\002\037\] $usersm"
  1321.     }
  1322.     if {$userso != ""} {
  1323.         lappend users "\[\002\037ChanOp\002\037\] $userso"
  1324.     }
  1325.     if {$usersv != ""} {
  1326.         lappend users "\[\002\037ChanVoice\002\037\] $usersv"
  1327.     }
  1328.     if {$users == ""} {
  1329.         putserv "NOTICE $nick :Channel $channel has no users."
  1330.         return
  1331.     }
  1332.     putserv "NOTICE $nick :Detected a total of $usertot users \[$useron in the channel\]"
  1333.     foreach line [mcc:check:splitline [join $users]] {
  1334.         putserv "NOTICE $nick :USERS: $line"
  1335.     }
  1336. }
  1337.  
  1338. # DEL Command
  1339. bind pub o|v $mcc(trigger)del mcc:cmd:del
  1340. proc mcc:cmd:del {nick uhost handle channel text} {
  1341.     global mcc owner
  1342.    
  1343.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1344.     if {![matchattr $handle o|v $channel]} { return }
  1345.    
  1346.     set user [lindex [join $text] 0]
  1347.     set glob [lindex [join $text] 1]
  1348.    
  1349.     if {$user == ""} {
  1350.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)del <nick|handle> \[-global|-perm\]"
  1351.         return
  1352.     }
  1353.     if {[onchan $user $channel]} {
  1354.         set user [nick2hand $user $channel]
  1355.     }
  1356.     if {$user == "" || $user == "*"} {
  1357.         putserv "NOTICE $nick :Error. User [lindex [join $text] 0] is not logged in."
  1358.         return
  1359.     }
  1360.     if {$glob == "-global"} {
  1361.         if {[string tolower $user] == [string tolower $owner]} {
  1362.             putserv "NOTICE $nick :Error. Can not delete a BOT OWNER."
  1363.             return
  1364.         }
  1365.         if {[chattr $user] == "-"} {
  1366.             putserv "NOTICE $nick :Error. User $user dosn`t have any global access."
  1367.             return
  1368.         }
  1369.         if {[mcc:check:leveldiff $user $handle ""]} {
  1370.             chattr $user -[chattr $user]
  1371.             putserv "NOTICE $nick :Deleted $user`s global access."
  1372.             return
  1373.         }
  1374.     }
  1375.     if {$glob == "-perm"} {
  1376.         if {[string tolower $user] == [string tolower $owner]} {
  1377.             putserv "NOTICE $nick :Error. Can not delete a BOT OWNER."
  1378.             return
  1379.         }
  1380.         if {![matchattr $handle n]} { return }
  1381.         if {[mcc:check:leveldiff $user $handle ""]} {
  1382.             deluser $user
  1383.             putserv "NOTICE $nick :Deleted $user from database."
  1384.             return
  1385.         }
  1386.     }
  1387.     if {![haschanrec $user $channel]} {
  1388.         putserv "NOTICE $nick :Error. User $user dosn`t have any channel access."
  1389.         return
  1390.     }
  1391.     if {[mcc:check:leveldiff $user $handle $channel]} {
  1392.         delchanrec $user $channel
  1393.         putserv "NOTICE $nick :Deleted $user`s channel access."
  1394.         return
  1395.     }
  1396.     putserv "NOTICE $nick :Error. Can not delete a user with lower or equal access then yours."
  1397. }
  1398.  
  1399. #
  1400. # Commands Level: CHANNEL OP (-|o)
  1401. #
  1402.  
  1403. # OP Commands
  1404. bind pub o|o $mcc(trigger)op mcc:cmd:op
  1405. proc mcc:cmd:op {nick uhost handle channel text} {
  1406.    
  1407.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1408.     if {![matchattr $handle o|o $channel]} { return }
  1409.    
  1410.     set who [join [lrange [split $text] 0 end]]
  1411.    
  1412.     if {$who == ""} {
  1413.         pushmode $channel +o $nick
  1414.     } else {
  1415.         foreach user $who {
  1416.             pushmode $channel +o $user
  1417.         }
  1418.     }
  1419. }
  1420.  
  1421. # DEOP Command
  1422. bind pub o|o $mcc(trigger)deop mcc:cmd:deop
  1423. proc mcc:cmd:deop {nick uhost handle channel text} {
  1424.    
  1425.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1426.     if {![matchattr $handle o|o $channel]} { return }
  1427.    
  1428.     set who [join [lrange [split $text] 0 end]]
  1429.    
  1430.     if {$who == ""} {
  1431.         pushmode $channel -o $nick
  1432.     } else {
  1433.         foreach user $who {
  1434.             pushmode $channel -o $user
  1435.         }
  1436.     }
  1437. }
  1438.  
  1439. # INVITE Command
  1440. bind pub o|o $mcc(trigger)invite mcc:cmd:invite
  1441. proc mcc:cmd:invite {nick uhost handle channel text} {
  1442.     global mcc
  1443.    
  1444.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1445.     if {![matchattr $handle o|o $channel]} { return }
  1446.    
  1447.     set who [join [lrange [split $text] 0 end]]
  1448.    
  1449.     if {$who == ""} {
  1450.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)invite <nick(s)>"
  1451.         return
  1452.     }
  1453.     if {[llength $who] > 6} {
  1454.         putserv "NOTICE $nick :Error. You can not invite more then 6 people at a time."
  1455.         return
  1456.     }
  1457.     set invited ""
  1458.     foreach user $who {
  1459.         if {[onchan $user $channel]} { continue }
  1460.         putserv "INVITE $user $channel"
  1461.         lappend invited $user
  1462.     }
  1463.     if {$invited != ""} {
  1464.         putserv "NOTICE $nick :Invited $invited to $channel"
  1465.     } else {
  1466.         putserv "NOTICE $nick :No invite sent. Already in the channel."
  1467.     }
  1468. }
  1469.  
  1470. # CHANINFO Command
  1471. bind pub o|o $mcc(trigger)chaninfo mcc:cmd:chaninfo
  1472. proc mcc:cmd:chaninfo {nick uhost handle channel text} {
  1473.    
  1474.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1475.     if {![matchattr $handle o|o $channel]} { return }
  1476.    
  1477.     set sets ""
  1478.     putserv "NOTICE $nick :\002Channel Information\002"
  1479.     if {[matchattr $handle &m $channel] || [matchattr $handle o]} {
  1480.         append sets "\002Enforce-Mode\002: [channel get $channel chanmode] "
  1481.         append sets "\002ChanLimit\002: [channel get $channel limit-int] "
  1482.         append sets "\002Idle-Kick\002: [channel get $channel idle-kick] "
  1483.         append sets "\002StopNetHack-Mode\002: [channel get $channel stopnethack-mode] "
  1484.         append sets "\002Revenge-Mode\002: [channel get $channel revenge-mode] "
  1485.         append sets "\002AOP-Delay\002: [channel get $channel aop-delay] "
  1486.         append sets "\002Ban-Type\002: [channel get $channel ban-type] "
  1487.         append sets "\002Ban-Time\002: [channel get $channel ban-time] "
  1488.         append sets "\002Flood-Chan\002: [channel get $channel flood-chan] "
  1489.         append sets "\002Flood-Ctcp\002: [channel get $channel flood-ctcp] "
  1490.         append sets "\002Flood-Join\002: [channel get $channel flood-join] "
  1491.         append sets "\002Flood-Kick\002: [channel get $channel flood-kick] "
  1492.         append sets "\002Flood-DeOp\002: [channel get $channel flood-deop] "
  1493.         append sets "\002Flood-Nick\002: [channel get $channel flood-nick]"        
  1494.         putserv "NOTICE $nick :$sets"
  1495.     }
  1496.     if {[matchattr $handle o|n $channel]} {
  1497.         set badwords [channel get $channel badword-text]
  1498.         set badchans [channel get $channel badchan-text]
  1499.         if {$badwords != ""} {
  1500.             putserv "NOTICE $nick :\002BadWord Masks\002: [join $badwords]"
  1501.         }
  1502.         if {$badchans != ""} {
  1503.             putserv "NOTICE $nick :\002BadChan Masks\002: [join $badchans]"
  1504.         }
  1505.     }
  1506.     foreach line [mcc:check:splitline [join [lsearch -all -inline -glob [lrange [channel info $channel] 1 end] +*]]] {
  1507.         putserv "NOTICE $nick :\002Settings Enabled\002: $line"
  1508.     }
  1509.     if {[matchattr $handle &m $channel] || [matchattr $handle o]} {
  1510.         foreach line [mcc:check:splitline [join [lsearch -all -inline -glob [lrange [channel info $channel] 1 end] -*]]] {
  1511.             putserv "NOTICE $nick :\002Settings Disabled\002: $line"
  1512.         }
  1513.     }
  1514.     if {[userlist &n $channel] == ""} {
  1515.         putserv "NOTICE $nick :\002ChanOwner\002: NO CHANNEL OWNER!"
  1516.     } else {
  1517.         foreach co [userlist &n $channel] {
  1518.             putserv "NOTICE $nick :\002ChanOwner\002: $co (LastSeen: [ctime [lindex [getuser $co LASTON $channel] 0]])"
  1519.         }
  1520.     }
  1521.     putserv "NOTICE $nick :\002End of channel information\002"
  1522. }
  1523.  
  1524. # TOPIC Command
  1525. bind pub o|o $mcc(trigger)topic mcc:cmd:topic
  1526. proc mcc:cmd:topic {nick uhost handle channel text} {
  1527.     global mcc
  1528.    
  1529.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1530.     if {![matchattr $handle o|o $channel]} { return }
  1531.    
  1532.     set topic [join [lrange [split $text] 0 end]]
  1533.    
  1534.     if {$topic == ""} {
  1535.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)topic <topic>"
  1536.         return
  1537.     }
  1538.     if {![botisop $channel]} {
  1539.         putserv "NOTICE $nick :Error. I`m not opped in $channel"
  1540.         return
  1541.     }
  1542.     if {![mcc:check:server_limits topic $topic]} {
  1543.         putserv "NOTICE $nick :Error. My current IRC server restricts topics to maximum $mcc(srv@topiclen) characters."
  1544.         return
  1545.     }
  1546.     if {[channel get $channel locktopic]} {
  1547.         putserv "NOTICE $nick :Error. Channel topic locked by [lindex [join [channel get $channel topic-text]] 0]"
  1548.         return
  1549.     }
  1550.     putserv "TOPIC $channel :$topic"
  1551. }
  1552.  
  1553. # KICK Command
  1554. bind pub o|o $mcc(trigger)kick mcc:cmd:kick
  1555. proc mcc:cmd:kick {nick uhost handle channel text} {
  1556.     global mcc
  1557.    
  1558.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1559.     if {![matchattr $handle o|o $channel]} { return }
  1560.    
  1561.     set user [lindex [join $text] 0]
  1562.     set reas [join [lrange [split $text] 1 end]]
  1563.    
  1564.     if {$user == ""} {
  1565.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)kick <nick> \[reason\]"
  1566.         return
  1567.     }
  1568.     if {![botisop $channel]} {
  1569.         putserv "NOTICE $nick :Error. I`m not opped in $channel"
  1570.         return
  1571.     }
  1572.     if {![onchan $user $channel]} {
  1573.         putserv "NOTICE $nick :Error. User $user is not in the channel."
  1574.         return
  1575.     }
  1576.     if {[isbotnick $user] || [matchattr $user b]} {
  1577.         putkick $channel $nick "hah.. funny."
  1578.         return
  1579.     }
  1580.     if {![mcc:check:server_limits kick $reas]} {
  1581.         putserv "NOTICE $nick :Error. My current IRC server restricts kick/ban reason to maximum $mcc(srv@kicklen) characters."
  1582.         return
  1583.     }
  1584.     putkick $channel $user $reas
  1585. }
  1586.  
  1587. # BAN Command
  1588. bind pub o|o $mcc(trigger)ban mcc:cmd:ban
  1589. proc mcc:cmd:ban {nick uhost handle channel text} {
  1590.     global mcc botname
  1591.    
  1592.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1593.     if {![matchattr $handle o|o $channel]} { return }
  1594.    
  1595.     set user [lindex [join $text] 0]
  1596.    
  1597.     if {$user == ""} {
  1598.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)ban <nick|host> \[time\] \[-sticky\] \[-global\] \[reason\]"
  1599.         return
  1600.     }
  1601.     if {![botisop $channel]} {
  1602.         putserv "NOTICE $nick :Error. I`m not opped in $channel"
  1603.         return
  1604.     }
  1605.     if {[isbotnick $user] || [matchattr $user b]} {
  1606.         putkick $channel $nick "hah.. funny."
  1607.         return
  1608.     }
  1609.     if {[string match -nocase $user $botname]} {
  1610.         putkick $channel $nick "hah.. funny."
  1611.         return
  1612.     }
  1613.     if {[onchan $user $channel]} {
  1614.         set user [maskhost "$user![getchanhost $user $channel]" [channel get $channel ban-type]]
  1615.     }
  1616.     set time [lindex [join $text] 1]
  1617.     if {[isnumber $time]} {
  1618.         set reas [join [lrange [split $text] 2 end]]
  1619.     } else {
  1620.         set reas [join [lrange [split $text] 1 end]]
  1621.         set time [channel get $channel ban-time]
  1622.     }
  1623.     set sticky "none"
  1624.     if {[lsearch -exact $reas -sticky] != "-1"} {
  1625.         set where [lsearch -exact $reas -sticky]
  1626.         set reas [lreplace $reas $where $where]
  1627.         set sticky "sticky"
  1628.     }
  1629.     if {[lsearch -exact $reas -global] != "-1" && [matchattr $handle m]} {
  1630.         set where [lsearch -exact $reas -global]
  1631.         set reas [lreplace $reas $where $where]
  1632.         set global "yes"
  1633.     }
  1634.     if {![mcc:check:server_limits kick $reas]} {
  1635.         putserv "NOTICE $nick :Error. My current IRC server restricts kick/ban reason to maximum $mcc(srv@kicklen) characters."
  1636.         return
  1637.     }
  1638.     if {[info exists global]} {
  1639.         newban $user $handle $reas $time $sticky
  1640.         putserv "NOTICE $nick :Added $user to global banlist."
  1641.         mcc:msg:debug "\[\002BAN\002\] Added $user to global banlist."
  1642.     } else {
  1643.         newchanban $channel $user $handle $reas $time $sticky
  1644.         putserv "NOTICE $nick :Added $user to channel banlist."
  1645.     }
  1646. }
  1647.  
  1648. # UNBAN Command
  1649. bind pub o|o $mcc(trigger)unban mcc:cmd:unban
  1650. proc mcc:cmd:unban {nick uhost handle channel text} {
  1651.     global mcc
  1652.    
  1653.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1654.     if {![matchattr $handle o|o $channel]} { return }
  1655.    
  1656.     set user [lindex [join $text] 0]
  1657.     set glob [lindex [join $text] 1]
  1658.    
  1659.     if {$user == ""} {
  1660.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)unban <hostmask> \[-global\]"
  1661.         return
  1662.     }
  1663.     set banlist ""
  1664.     set bbannr "0"
  1665.     set cbannr "0"
  1666.     if {$glob == "-global"} {
  1667.         if {![matchattr $handle o]} {
  1668.             putserv "NOTICE $nick :Error. You do not have access to remove global bans."
  1669.             return
  1670.         }
  1671.         foreach ban [banlist] {
  1672.             set banmask [lindex [join $ban] 0]
  1673.             set banuser [lindex [join $ban] 5]
  1674.             if {[string match -nocase $user $banmask] && [mcc:check:leveldiff $banuser $handle ""]} {
  1675.                 killban $banmask
  1676.                 lappend banlist $banmask
  1677.                 incr bbannr
  1678.             }
  1679.         }
  1680.         putserv "NOTICE $nick :Removed $bbannr bans matching $user"
  1681.         if {$banlist != ""} {
  1682.             foreach line [mcc:check:splitline [join $banlist]] {
  1683.                 mcc:msg:debug "\[\002UNBAN\002\] $nick/\002$handle\002: $line"
  1684.             }
  1685.         }
  1686.         return
  1687.     }
  1688.     foreach ban [banlist $channel] {
  1689.         set banmask [lindex [join $ban] 0]
  1690.         set banuser [lindex [join $ban] 5]
  1691.         if {[string match -nocase $user $banmask] && [mcc:check:leveldiff $banuser $handle $channel]} {
  1692.             killchanban $channel $banmask
  1693.             lappend banlist $banmask
  1694.             incr bbannr
  1695.         }
  1696.     }
  1697.     foreach ban [chanbans $channel] {
  1698.         set banmask [lindex [join $ban] 0]
  1699.         if {[string match -nocase $user $banmask]} {
  1700.             pushmode $channel -b $banmask
  1701.             incr cbannr
  1702.         }
  1703.     }
  1704.     putserv "NOTICE $nick :Removed $cbannr channel & $bbannr bot bans matching $user"
  1705. }
  1706.  
  1707. # BANLIST Command
  1708. bind pub o|o $mcc(trigger)banlist mcc:cmd:banlist
  1709. proc mcc:cmd:banlist {nick uhost handle channel text} {
  1710.     global mcc
  1711.    
  1712.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1713.     if {![matchattr $handle o|o $channel]} { return }
  1714.    
  1715.     set mask [lindex [join $text] 0]
  1716.     set glob [lindex [join $text] 1]
  1717.    
  1718.     set banlist ""
  1719.     if {$mask == "" || $mask == "-global"} {
  1720.         if {$mask == "-global"} {
  1721.             set thelist [banlist]
  1722.         } else {
  1723.             set thelist [banlist $channel]
  1724.         }
  1725.         foreach ban $thelist {
  1726.             lappend banlist [lindex [join $ban] 0]
  1727.         }
  1728.         if {$banlist == ""} {
  1729.             putserv "NOTICE $nick :Banlist is empty."
  1730.             return
  1731.         }
  1732.         foreach line [mcc:check:splitline [join $banlist]] {
  1733.             putserv "NOTICE $nick :Banlist: $line"
  1734.             return
  1735.         }
  1736.     }
  1737.    
  1738.     set bannr "0"
  1739.     if {$glob == "-global"} {
  1740.         set thelist [banlist]
  1741.     } else {
  1742.         set thelist [banlist $channel]
  1743.     }
  1744.     putserv "NOTICE $nick :Searching ban list.."
  1745.     foreach ban $thelist {
  1746.         set banmask [lindex [join $ban] 0]
  1747.         if {[string match -nocase $mask $banmask]} {
  1748.             set banreas [lindex $ban 1]
  1749.             set banexpr [lindex $ban 2]
  1750.             set banuser [lindex $ban 5]
  1751.             if {$banexpr == "0"} {
  1752.                 set banexpr "Never"
  1753.             } else {
  1754.                 set banexpr [lrange [duration [expr {[lindex $ban 2] - [unixtime]}]] 0 3]
  1755.             }
  1756.             putserv "NOTICE $nick :\002Mask\002: $banmask \002Creator\002: $banuser \002Expire\002: $banexpr \002Reason\002: $banreas"
  1757.             incr bannr
  1758.         }
  1759.     }
  1760.     putserv "NOTICE $nick :Found a total of $bannr bans matching $mask"
  1761. }
  1762.  
  1763. # MODE Command
  1764. bind pub o|o $mcc(trigger)mode mcc:cmd:mode
  1765. proc mcc:cmd:mode {nick uhost handle channel text} {
  1766.     global mcc
  1767.    
  1768.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1769.     if {![matchattr $handle o|o $channel]} { return }
  1770.    
  1771.     set mode [lindex [join $text] 0]
  1772.     set key [lindex [join $text] 1]
  1773.    
  1774.     if {$mode == ""} {
  1775.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)mode <+|-mode>"
  1776.         return
  1777.     }
  1778.     if {![botisop $channel]} {
  1779.         putserv "NOTICE $nick :Error. I`m not opped in $channel"
  1780.         return
  1781.     }
  1782.     if {[lsearch -exact [split $mode ""] "k"] != "-1" && $key == ""} {
  1783.         putserv "NOTICE $nick :Error. Please specify a channel key."
  1784.         return
  1785.     }
  1786.     if {[lsearch -exact [split $mode ""] "l"] != "-1" && $key == ""} {
  1787.         putserv "NOTICE $nick :Error. Please specify the channel limit."
  1788.         return
  1789.     }
  1790.     if {![mcc:check:server_limits modes $mode]} {
  1791.         putserv "NOTICE $nick :Error. My current IRC server only supports these channel modes: \0036$mcc(srv@chanmodes)"
  1792.         return
  1793.     }
  1794.     pushmode $channel $mode $key
  1795. }
  1796.  
  1797. # ADD Command
  1798. bind pub o|o $mcc(trigger)add mcc:cmd:add
  1799. proc mcc:cmd:add {nick uhost handle channel text} {
  1800.     global mcc botnick owner
  1801.    
  1802.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1803.     if {![matchattr $handle o|o $channel]} { return }
  1804.    
  1805.     set user [lindex [join $text] 0]
  1806.     set level [string tolower [lindex [join $text] 1]]
  1807.     set levels "ChanVoice ChanOp ChanMaster ChanOwner GlobalOp GlobalMaster GlobalOwner"
  1808.    
  1809.     if {[lsearch -exact [string tolower $levels] $level] == "-1"} {
  1810.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)add <nick> <level>"
  1811.         putserv "NOTICE $nick :Levels: [join $levels ", "]"
  1812.         return
  1813.     }
  1814.     if {![onchan $user $channel]} {
  1815.         putserv "NOTICE $nick :Error. User $user needs to be in the channel."
  1816.         return
  1817.     }
  1818.    
  1819.     set newuser [nick2hand $user $channel]
  1820.    
  1821.     if {![validuser $newuser]} {
  1822.         set userr $user
  1823.         if {![adduser $userr [mcc:proc:maskhost [getchanhost $user $channel]]]} {
  1824.             set iuser "0"
  1825.             while {![info exists okuser]} {
  1826.                 set userr $user$iuser
  1827.                 if {![validuser $userr]} {
  1828.                     set okuser "1"
  1829.                 } else {
  1830.                     incr iuser
  1831.                 }
  1832.             }
  1833.             adduser $userr [mcc:proc:maskhost [getchanhost $user $channel]]
  1834.             setuser $userr XTRA NOPASSDEL [clock add [unixtime] 2 hours]
  1835.         }
  1836.         putserv "NOTICE $user :You have been added as \002$userr\002 to my database."
  1837.         putserv "NOTICE $user :Please set a password (/msg $botnick pass) to avoid getting automaticaly deleted."
  1838.         set newuser $userr
  1839.     } else {
  1840.         if {[matchattr $newuser b]} {
  1841.             putserv "NOTICE $nick :Error. User $user/\002$newuser\002 is a bot."
  1842.             return
  1843.         }
  1844.         set chanlvl "chanvoice chanop chanmaster chanowner"
  1845.         if {[lsearch -exact $chanlvl $level] != "-1" && [matchattr $newuser nmof $channel]} {
  1846.             putserv "NOTICE $nick :Error. User $user/\002$newuser\002 ([mcc:check:level $newuser $channel]) already has access."
  1847.             return
  1848.         }
  1849.         set globlvl "globalop globalmaster globalowner"
  1850.         if {[lsearch -exact $globlvl $level] != "-1" && [matchattr $newuser nmov]} {
  1851.             putserv "NOTICE $nick :Error. User $user/\002$newuser\002 ([mcc:check:level $newuser $channel]) already has access."
  1852.             return
  1853.         }
  1854.     }
  1855.     if {[matchattr $handle o|o $channel] && $level == "chanvoice" } {
  1856.         chattr $newuser -|+fv $channel
  1857.         putserv "NOTICE $nick :Added $user/\002$newuser\002 as ChanVoice."
  1858.         putserv "NOTICE $user :You have been added as ChanVoice of $channel"
  1859.         return
  1860.     }
  1861.     if {[matchattr $handle o|m $channel] && $level == "chanop" } {
  1862.         chattr $newuser -|+flov $channel
  1863.         putserv "NOTICE $nick :Added $user/\002$newuser\002 as ChanOp."
  1864.         putserv "NOTICE $user :You have been added as ChanOp of $channel"
  1865.         return
  1866.     }
  1867.     if {[matchattr $handle o|n $channel] && $level == "chanmaster" } {
  1868.         chattr $newuser -|+flmov $channel
  1869.         putserv "NOTICE $nick :Added $user/\002$newuser\002 as ChanMaster."
  1870.         putserv "NOTICE $user :You have been added as ChanMaster of $channel"
  1871.         return
  1872.     }
  1873.     if {[matchattr $handle o] && $level == "chanowner" } {
  1874.         chattr $newuser -|+flmnov $channel
  1875.         putserv "NOTICE $nick :Added $user/\002$newuser\002 as ChanOwner."
  1876.         putserv "NOTICE $user :You have been added as ChanOwner of $channel"
  1877.         return
  1878.     }
  1879.     if {[matchattr $handle m] && $level == "globalop" } {
  1880.         chattr $newuser +flov
  1881.         putserv "NOTICE $nick :Added $user/\002$newuser\002 as GlobalOp."
  1882.         putserv "NOTICE $user :You have been added as GlobalOp."
  1883.         mcc:msg:debug "\[\002ADD\002\] $nick/\002$handle\002 added $user/\002$newuser\002 as GlobalOp"
  1884.         return
  1885.     }
  1886.     if {[matchattr $handle n] && $level == "globalmaster" } {
  1887.         chattr $newuser +flmov
  1888.         putserv "NOTICE $nick :Added $user/\002$newuser\002 as GlobalMaster."
  1889.         putserv "NOTICE $user :You have been added as GlobalMaster."
  1890.         mcc:msg:debug "\[\002ADD\002\] $nick/\002$handle\002 added $user/\002$newuser\002 as GlobalMaster"
  1891.         return
  1892.     }
  1893.     if {[string tolower $handle] == [string tolower $owner] && $level == "globalowner"} {
  1894.         chattr $newuser +flmnov
  1895.         putserv "NOTICE $nick :Added $user/\002$newuser\002 as GlobalOwner."
  1896.         putserv "NOTICE $user :You have been added as GlobalOwner."
  1897.         mcc:msg:debug "\[\002ADD\002\] $nick/\002$handle\002 added $user/\002$newuser\002 as GlobalOwner"
  1898.         return
  1899.     }
  1900.     putserv "NOTICE $nick :Error. You can`t add someone with level equal or bigger then yours."
  1901. }
  1902.  
  1903. #
  1904. # Commands Level: CHANNEL MASTER (-|m)
  1905. #
  1906.  
  1907. # CHANSET Command
  1908. bind pub o|m $mcc(trigger)chanset mcc:cmd:chanset
  1909. proc mcc:cmd:chanset {nick uhost handle channel text} {
  1910.     global mcc
  1911.    
  1912.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  1913.     if {![matchattr $handle o|m $channel]} { return }
  1914.    
  1915.     set cmd [lindex [join $text] 0]
  1916.     set who [lindex [join $text] 1]
  1917.     set why [lindex [join $text] 2]
  1918.     set whyy [join [lrange [split $text] 1 end]]
  1919.    
  1920.     if {$cmd == ""} {
  1921.         putserv "NOTICE $nick :Error. No settings specified. Use \002$mcc(trigger)chaninfo\002 for a list of channel settings."
  1922.         return
  1923.     }
  1924.    
  1925.     switch -- [string tolower $cmd] {
  1926.         "enforce-mode" {
  1927.             if {$who == ""} {
  1928.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <channel modes>"
  1929.                 return
  1930.             }
  1931.             if {![mcc:check:server_limits modes $who]} {
  1932.                 putserv "NOTICE $nick :Error. My current IRC server only supports these channel modes: \0036$mcc(srv@chanmodes)"
  1933.                 return
  1934.             }
  1935.             channel set $channel chanmode $whyy
  1936.             putserv "NOTICE $nick :Enforce-Mode set to: [channel get $channel chanmode]"
  1937.             return
  1938.         }
  1939.         "chanlimit" {
  1940.             if {![isnumber $who] || $who < 0} {
  1941.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <limit>"
  1942.                 return
  1943.             }
  1944.             channel set $channel limit-int $who
  1945.             putserv "NOTICE $nick :ChanLimit set to: [channel get $channel limit-int]"
  1946.             return
  1947.         }
  1948.         "idle-kick" {
  1949.             if {![isnumber $who] || $who < 0} {
  1950.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <minutes>"
  1951.                 return
  1952.             }
  1953.             channel set $channel idle-kick $who
  1954.             putserv "NOTICE $nick :Idle-Kick set to: [channel get $channel idle-kick]"
  1955.             return
  1956.         }
  1957.         "stopnethack-mode" {
  1958.             if {![isnumber $who] || $who < 0 || $who > 6} {
  1959.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <type>"
  1960.                 return
  1961.             }
  1962.             channel set $channel stopnethack-mode $who
  1963.             putserv "NOTICE $nick :StopNetHack-Mode set to: [channel get $channel stopnethack-mode]"
  1964.             return
  1965.         }
  1966.         "revenge-mode" {
  1967.             if {![isnumber $who] || $who < 0 || $who > 3} {
  1968.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <type>"
  1969.                 return
  1970.             }
  1971.             channel set $channel revenge-mode $who
  1972.             putserv "NOTICE $nick :Revenge-Mode set to: [channel get $channel revenge-mode]"
  1973.             return
  1974.         }
  1975.         "need-op" {
  1976.             putserv "NOTICE $nick :Need-Op: Channel setting disabled."
  1977.             return
  1978.         }
  1979.         "need-invite" {
  1980.             putserv "NOTICE $nick :Need-Invite: Channel setting disabled."
  1981.             return
  1982.         }
  1983.         "need-key" {
  1984.             putserv "NOTICE $nick :Need-Key: Channel setting disabled."
  1985.             return
  1986.         }
  1987.         "need-unban" {
  1988.             putserv "NOTICE $nick :Need-UnBan: Channel setting disabled."
  1989.             return
  1990.         }
  1991.         "need-limit" {
  1992.             putserv "NOTICE $nick :Need-Limit: Channel setting disabled."
  1993.             return
  1994.         }
  1995.         "aop-delay" {
  1996.             if {![isnumber $who] || ![isnumber $why]} {
  1997.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <seconds> <seconds>"
  1998.                 return
  1999.             }
  2000.             if {$who == 0} {
  2001.                 channel set $channel aop-delay $who:0
  2002.             } else {
  2003.                 channel set $channel aop-delay $who:$why
  2004.             }
  2005.             putserv "NOTICE $nick :AOP-Delay set to: [channel get $channel aop-delay]"
  2006.             return
  2007.         }
  2008.         "ban-type" {
  2009.             if {![isnumber $who] || $who < 0 || $who > 29} {
  2010.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <type>"
  2011.                 return
  2012.             }
  2013.             channel set $channel ban-type $who
  2014.             putserv "NOTICE $nick :Ban-Type set to: [channel get $channel ban-type]"
  2015.             return
  2016.         }
  2017.         "ban-time" {
  2018.             if {![isnumber $who] || $who < 0} {
  2019.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <type>"
  2020.                 return
  2021.             }
  2022.             channel set $channel ban-time $who
  2023.             putserv "NOTICE $nick :Ban-Time set to: [channel get $channel ban-time]"
  2024.             return
  2025.         }
  2026.         "exempt-time" {
  2027.             putserv "NOTICE $nick :Exempt-Time: Channel setting disabled."
  2028.             return
  2029.         }
  2030.         "invite-time" {
  2031.             putserv "NOTICE $nick :Invite-Time: Channel setting disabled."
  2032.             return
  2033.         }
  2034.         "flood-*" {
  2035.             putserv "NOTICE $nick :Flood-*: Channel setting not available yet."
  2036.             return
  2037.         }
  2038.         "flood-chan" {
  2039.             if {![isnumber $who] || ![isnumber $why]} {
  2040.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <lines> <seconds>"
  2041.                 return
  2042.             }
  2043.             if {$who == 0} {
  2044.                 channel set $channel flood-chan $who:0
  2045.             } else {
  2046.                 channel set $channel flood-chan $who:$why
  2047.             }
  2048.             putserv "NOTICE $nick :Flood-Chan set to: [channel get $channel flood-chan]"
  2049.             return
  2050.         }
  2051.         "flood-ctcp" {
  2052.             if {![isnumber $who] || ![isnumber $why]} {
  2053.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <ctcps> <seconds>"
  2054.                 return
  2055.             }
  2056.             if {$who == 0} {
  2057.                 channel set $channel flood-ctcp $who:0
  2058.             } else {
  2059.                 channel set $channel flood-ctcp $who:$why
  2060.             }
  2061.             putserv "NOTICE $nick :Flood-Ctcp set to: [channel get $channel flood-ctcp]"
  2062.             return
  2063.         }
  2064.         "flood-join" {
  2065.             if {![isnumber $who] || ![isnumber $why]} {
  2066.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <joins> <seconds>"
  2067.                 return
  2068.             }
  2069.             if {$who == 0} {
  2070.                 channel set $channel flood-join $who:0
  2071.             } else {
  2072.                 channel set $channel flood-join $who:$why
  2073.             }
  2074.             putserv "NOTICE $nick :Flood-Join set to: [channel get $channel flood-join]"
  2075.             return
  2076.         }
  2077.         "flood-kick" {
  2078.             if {![isnumber $who] || ![isnumber $why]} {
  2079.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <kicks> <seconds>"
  2080.                 return
  2081.             }
  2082.             if {$who == 0} {
  2083.                 channel set $channel flood-kick $who:0
  2084.             } else {
  2085.                 channel set $channel flood-kick $who:$why
  2086.             }
  2087.             putserv "NOTICE $nick :Flood-Kick set to: [channel get $channel flood-kick]"
  2088.             return
  2089.         }
  2090.         "flood-deop" {
  2091.             if {![isnumber $who] || ![isnumber $why]} {
  2092.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <deops> <seconds>"
  2093.                 return
  2094.             }
  2095.             if {$who == 0} {
  2096.                 channel set $channel flood-deop $who:0
  2097.             } else {
  2098.                 channel set $channel flood-deop $who:$why
  2099.             }
  2100.             putserv "NOTICE $nick :Flood-DeOp set to: [channel get $channel flood-deop]"
  2101.             return
  2102.         }
  2103.         "flood-nick" {
  2104.             if {![isnumber $who] || ![isnumber $why]} {
  2105.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)chanset $cmd <nick changes> <seconds>"
  2106.                 return
  2107.             }
  2108.             if {$who == 0} {
  2109.                 channel set $channel flood-nick $who:0
  2110.             } else {
  2111.                 channel set $channel flood-nick $who:$why
  2112.             }
  2113.             putserv "NOTICE $nick :Flood-Nick set to: [channel get $channel flood-nick]"
  2114.             return
  2115.         }
  2116.         "badword" {
  2117.             if {$who == "add" && $why != ""} {
  2118.                 set badwords [channel get $channel badword-text]
  2119.                 lappend badwords $why
  2120.                 channel set $channel badword-text $badwords
  2121.                 putserv "NOTICE $nick :Added $why to BadWord list."
  2122.                 return
  2123.             }
  2124.             if {$who == "del" && $why != ""} {
  2125.                 set badwords [channel get $channel badword-text]
  2126.                 set where [lsearch -exact $badwords $why]
  2127.                 set badwords [lreplace $badwords $where $where]
  2128.                 if {$where == "-1"} {
  2129.                     putserv "NOTICE $nick :BadWord $why not found."
  2130.                 } else {
  2131.                     putserv "NOTICE $nick :Deleted $why from BadWord list."
  2132.                     channel set $channel badword-text $badwords
  2133.                 }
  2134.                 return
  2135.             }
  2136.             putserv "NOTICE $nick :Usage: $mcc(trigger)chanset badword <add|del> <word mask>"
  2137.             if {[channel get $channel badword-text] == ""} {
  2138.                 putserv "NOTICE $nick :BadWord list is empty."
  2139.             } else {
  2140.                 putserv "NOTICE $nick :BadWord Masks: [join [channel get $channel badword-text]]"
  2141.             }
  2142.             return
  2143.         }
  2144.         "badchan" {
  2145.             if {$who == "add" && $why != ""} {
  2146.                 set badchans [channel get $channel badchan-text]
  2147.                 lappend badchans $why
  2148.                 channel set $channel badchan-text $badchans
  2149.                 putserv "NOTICE $nick :Added $why to BadChan list."
  2150.                 return
  2151.             }
  2152.             if {$who == "del" && $why != ""} {
  2153.                 set badchans [channel get $channel badchan-text]
  2154.                 set where [lsearch -exact $badchans $why]
  2155.                 set badchans [lreplace $badchans $where $where]
  2156.                 if {$where == "-1"} {
  2157.                     putserv "NOTICE $nick :BadChan $why not found."
  2158.                 } else {
  2159.                     putserv "NOTICE $nick :Deleted $why from BadChan list."
  2160.                     channel set $channel badchan-text $badchans
  2161.                 }
  2162.                 return
  2163.             }
  2164.             putserv "NOTICE $nick :Usage: $mcc(trigger)chanset badchan <add|del> <chan mask>"
  2165.             if {[channel get $channel badchan-text] == ""} {
  2166.                 putserv "NOTICE $nick :BadChan list is empty."
  2167.             } else {
  2168.                 putserv "NOTICE $nick :BadChan Masks: [join [channel get $channel badchan-text]]"
  2169.             }
  2170.             return
  2171.         }
  2172.     }
  2173.     set goodmodes ""
  2174.     set badmodes ""
  2175.     foreach mode "$cmd $whyy" {
  2176.         if {[string match -nocase "?debug" $mode] && ![matchattr $handle n]} {
  2177.             lappend badmodes $mode
  2178.             continue
  2179.         }
  2180.         if {[string match -nocase "?statuslog" $mode] && ![matchattr $handle n]} {
  2181.             lappend badmodes $mode
  2182.             continue
  2183.         }
  2184.         if {[string match -nocase "?static" $mode] && ![matchattr $handle n]} {
  2185.             lappend badmodes $mode
  2186.             continue
  2187.         }
  2188.         if {[string match -nocase "?inactive" $mode] && ![matchattr $handle m]} {
  2189.             lappend badmodes $mode
  2190.             continue
  2191.         }
  2192.         if {([string match -nocase "+autotopic" $mode] || [string match -nocase "+locktopic" $mode]) && [topic $channel] == ""} {
  2193.             lappend badmodes $mode
  2194.             continue
  2195.         }
  2196.         if {([string match -nocase "+autotopic" $mode] || [string match -nocase "+locktopic" $mode]) && [topic $channel] != ""} {
  2197.             channel set $channel topic-text "$nick [topic $channel]"
  2198.         }
  2199.         if {[string match -nocase "+limit" $mode]} {
  2200.             mcc:check:limit $channel
  2201.         }
  2202.         if {[catch {channel set $channel $mode} fid]} {
  2203.             lappend badmodes $mode
  2204.         } else {
  2205.             lappend goodmodes $mode
  2206.         }
  2207.     }
  2208.     if {$goodmodes != ""} {
  2209.         putserv "NOTICE $nick :Setting channel to $goodmodes"
  2210.     }
  2211.     if {$badmodes != ""} {
  2212.         putserv "NOTICE $nick :Bad Settings: $badmodes"
  2213.     }
  2214.     return
  2215. }
  2216.  
  2217. # CYCLE Command
  2218. bind pub o|m $mcc(trigger)cycle mcc:cmd:cycle
  2219. proc mcc:cmd:cycle {nick uhost handle channel text} {
  2220.    
  2221.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2222.     if {![matchattr $handle o|m $channel]} { return }
  2223.    
  2224.     set time [lindex [join $text] 0]
  2225.    
  2226.     if {![isnumber $time]} {
  2227.         putserv "PART $channel :Cycling at the request of $nick/\002$handle\002"
  2228.         return
  2229.     }
  2230.     putserv "PART $channel :Cycling at the request of $nick/\002$handle\002 for $time seconds"
  2231.     channel set $channel +inactive
  2232.     utimer $time [list channel set $channel -inactive]
  2233. }
  2234.  
  2235. #
  2236. # Commands Level: CHANNEL OWNER (-|n)
  2237. #
  2238.  
  2239. # SAY Command
  2240. bind pub o|n $mcc(trigger)say mcc:cmd:say
  2241. proc mcc:cmd:say {nick uhost handle channel text} {
  2242.     global mcc
  2243.    
  2244.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2245.     if {![matchattr $handle o|n $channel]} { return }
  2246.    
  2247.     set text [join [lrange [split $text] 0 end]]
  2248.    
  2249.     if {$text == ""} {
  2250.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)say <text>"
  2251.         return
  2252.     }
  2253.     putserv "PRIVMSG $channel :$text"
  2254. }
  2255.  
  2256. # ACT Command
  2257. bind pub o|n $mcc(trigger)act mcc:cmd:act
  2258. proc mcc:cmd:act {nick uhost handle channel text} {
  2259.     global mcc
  2260.    
  2261.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2262.     if {![matchattr $handle o|n $channel]} { return }
  2263.    
  2264.     set text [join [lrange [split $text] 0 end]]
  2265.    
  2266.     if {$text == ""} {
  2267.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)act <text>"
  2268.         return
  2269.     }
  2270.     putserv "PRIVMSG $channel :\001ACTION $text\001"
  2271. }
  2272.  
  2273. # JOIN Command
  2274. bind pub -|- $mcc(trigger)join mcc:cmd:join
  2275. proc mcc:cmd:join {nick uhost handle channel text} {
  2276.     global mcc
  2277.    
  2278.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2279.     set chan [lindex [split $text] 0]
  2280.    
  2281.     if {$chan == ""} {
  2282.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)join <#channel>"
  2283.         return
  2284.     }
  2285.     if {![matchattr $handle o|n $chan]} { return }
  2286.        
  2287.     if {![mcc:check:server_limits chanlen $chan]} {
  2288.         putserv "NOTICE $nick :Error. My current IRC server restricts channel names to $mcc(srv@chanlen) characters."
  2289.         return
  2290.     }
  2291.     if {![mcc:check:server_limits chantype $chan]} {
  2292.         putserv "NOTICE $nick :Error. My current IRC server restricts channel types to [split $mcc(srv@chantypes) ""]"
  2293.         return
  2294.     }
  2295.     if {![mcc:check:server_limits channels $chan]} {
  2296.         putserv "NOTICE $nick :Error. I have reached my maximum channel capacity."
  2297.         return
  2298.     }
  2299.     if {[validchan $chan]} {
  2300.         if {[channel get $chan inactive]} {
  2301.             channel set $chan -inactive
  2302.             putserv "NOTICE $nick :Rejoining $chan"
  2303.             return
  2304.         }
  2305.         if {[botonchan $chan]} {
  2306.             putserv "NOTICE $nick :I am already in $chan"
  2307.             return
  2308.         }
  2309.         putserv "JOIN $chan"
  2310.         return
  2311.     }
  2312.     if {[matchattr $handle m]} {
  2313.         channel add $chan {
  2314.             limit-int 5
  2315.         }
  2316.         putserv "NOTICE $nick :Adding channel $chan to database."
  2317.         mcc:msg:debug "\[\002JOIN\002\] $nick added $chan to database."
  2318.     }
  2319. }
  2320.  
  2321. # PART Command
  2322. bind pub o|n $mcc(trigger)part mcc:cmd:part
  2323. proc mcc:cmd:part {nick uhost handle channel text} {
  2324.     global mcc
  2325.    
  2326.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2327.    
  2328.     set chan [lindex [join $text] 0]
  2329.    
  2330.     if {![matchattr $handle o|n $chan]} { return }
  2331.    
  2332.     if {$chan == ""} {
  2333.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)part <#channel>"
  2334.         putserv "NOTICE $nick :NOTE: This will delete the channel and all access records."
  2335.         return
  2336.     }
  2337.     if {![validchan $chan]} {
  2338.         putserv "NOTICE $nick :Error. Channel $chan is not in my database."
  2339.         return
  2340.     }
  2341.     if {[channel get $chan static] && [matchattr $handle n]} {
  2342.         putserv "NOTICE $nick :Error. Channel $chan is +static"
  2343.         return
  2344.     }
  2345.     putserv "PART $chan :Channel purged by $nick/\002$handle\002"
  2346.     channel remove $chan
  2347.     mcc:msg:debug "\[\002PART\002\] $nick/\002$handle\002 purged $chan"
  2348.     putserv "NOTICE $nick :Channel $chan has been purged."
  2349. }
  2350.  
  2351. # GREET Command
  2352. bind pub o|n $mcc(trigger)greet mcc:cmd:greet
  2353. proc mcc:cmd:greet {nick uhost handle channel text} {
  2354.     global mcc
  2355.    
  2356.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2357.     if {![matchattr $handle o|n $channel]} { return }
  2358.    
  2359.     set cmd [lindex [join $text] 0]
  2360.     set txt [join [lrange [split $text] 1 end]]
  2361.    
  2362.     switch -- [string tolower $cmd] {
  2363.         "add" {
  2364.             if {$txt == ""} {
  2365.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)greet add <text>"
  2366.                 putserv "NOTICE $nick :NOTE: Parsers available for dynamic information are: %nickname %hostname %handle %channel %botnick %access"
  2367.                 return
  2368.             }
  2369.             if {[llength [channel get $channel greet-text]] > 3} {
  2370.                 putserv "NOTICE $nick :Error. Maximum number of 4 greets reached."
  2371.                 putserv "NOTICE $nick :NOTE: Remove one of the current greets before trying to add a new one."
  2372.                 return
  2373.             }
  2374.             set greet [channel get $channel greet-text]
  2375.             lappend greet $txt
  2376.             channel set $channel greet-text $greet
  2377.             putserv "NOTICE $nick :New channel greet has been added."
  2378.             return
  2379.         }
  2380.         "del" {
  2381.             if {![isnumber $txt]} {
  2382.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)greet del <id>"
  2383.                 return
  2384.             }
  2385.             set nr [expr {$txt - 1}]
  2386.             set greet [channel get $channel greet-text]
  2387.             set greet [lreplace $greet $nr $nr]
  2388.             channel set $channel greet-text $greet
  2389.             putserv "NOTICE $nick :Greet ID $txt deleted."
  2390.             return
  2391.         }
  2392.         "list" {
  2393.             set greetlist [channel get $channel greet-text]
  2394.             if {$greetlist == ""} {
  2395.                 putserv "NOTICE $nick :Greet is empty."
  2396.                 return
  2397.             }
  2398.             set nr "1"
  2399.             foreach greet $greetlist {
  2400.                 putserv "NOTICE $nick :\[\002ID $nr\002\] $greet"
  2401.                 incr nr
  2402.             }
  2403.             return
  2404.         }
  2405.     }
  2406.     putserv "NOTICE $nick :Error. Usage: $mcc(trigger)greet <add|del|list> \[text\]"
  2407.     putserv "NOTICE $nick :NOTE: Parsers available for dynamic information are: %nickname %hostname %handle %channel %botnick %access"
  2408. }
  2409.  
  2410. #
  2411. # Commands Level: GLOBAL OP (o|-)
  2412. #
  2413.  
  2414. # IGNORE Command
  2415. bind pub o $mcc(trigger)ignore mcc:cmd:ignore
  2416. proc mcc:cmd:ignore {nick uhost handle channel text} {
  2417.     global mcc ignore-time
  2418.    
  2419.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2420.     if {![matchattr $handle o]} { return }
  2421.    
  2422.     set host [lindex [join $text] 0]
  2423.    
  2424.     if {$host == ""} {
  2425.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)ignore <hostmask> \[time\] <reason>"
  2426.         return
  2427.     }
  2428.     if {[isnumber [lindex [join $text] 1]]} {
  2429.         set time [lindex [join $text] 1]
  2430.         set reas [join [lrange [split $text] 2 end]]
  2431.     } else {
  2432.         set time ${ignore-time}
  2433.         set reas [join [lrange [split $text] 1 end]]
  2434.     }
  2435.     newignore $host $handle $reas $time
  2436.     putserv "NOTICE $nick :Hostmask $host added to ignore list."
  2437.     mcc:msg:debug "\[\002IGNORE\002\] $nick/\002$handle\002 added $host to ignore list."
  2438. }
  2439.  
  2440. # UNIGNORE Command
  2441. bind pub o $mcc(trigger)unignore mcc:cmd:unignore
  2442. proc mcc:cmd:unignore {nick uhost handle channel text} {
  2443.     global mcc
  2444.    
  2445.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2446.     if {![matchattr $handle o]} { return }
  2447.    
  2448.     set host [lindex [join $text] 0]
  2449.    
  2450.     if {$host == ""} {
  2451.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)unignore <hostmask>"
  2452.         return
  2453.     }
  2454.     set ignorenr "0"
  2455.     foreach ignore [ignorelist] {
  2456.         set ihost [lindex $ignore 0]
  2457.         if {[string match -nocase $host $ihost]} {
  2458.             killignore $ihost
  2459.             incr ignorenr
  2460.         }
  2461.     }
  2462.     putserv "NOTICE $nick :Removed $ignorenr ingores matching $host"
  2463.     mcc:msg:debug "\[\002IGNORE\002\] $nick/\002$handle\002 removed $ignorenr ignores matching $host"
  2464. }
  2465.  
  2466. # IGNORELIST Command
  2467. bind pub o $mcc(trigger)ignorelist mcc:cmd:ignorelist
  2468. proc mcc:cmd:ignorelist {nick uhost handle channel text} {
  2469.    
  2470.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2471.     if {![matchattr $handle o]} { return }
  2472.    
  2473.     set host [lindex [join $text] 0]
  2474.    
  2475.     set ignorelist [ignorelist]
  2476.     if {$ignorelist == ""} {
  2477.         putserv "NOTICE $nick :Ignore list is empty."
  2478.         return
  2479.     }
  2480.     set igns ""
  2481.     if {$host == "" || ![matchattr $handle o]} {
  2482.         foreach ignore $ignorelist {
  2483.             lappend igns [lindex $ignore 0]
  2484.         }
  2485.         foreach line [mcc:check:splitline [join $igns]] {
  2486.             putserv "NOTICE $nick :IgnoreList: $line"
  2487.         }
  2488.         return
  2489.     }
  2490.     set ignr "0"
  2491.     putserv "NOTICE $nick :Searching ignore list.."
  2492.     foreach ignore $ignorelist {
  2493.         set ignhost [lindex $ignore 0]
  2494.         if {[string match -nocase $host $ignhost]} {
  2495.             set ignuser [lindex $ignore 4]
  2496.             set ignreas [lindex $ignore 1]
  2497.             set igntime [lindex $ignore 2]
  2498.             if {$igntime == "0"} {
  2499.                 set igntime "Never"
  2500.             } else {
  2501.                 set igntime [lrange [duration [expr {[lindex $ignore 2] - [unixtime]}]] 0 3]
  2502.             }
  2503.             putserv "NOTICE $nick :\002Mask\002: $ignhost \002Creator\002: $ignuser \002Expire\002: $igntime \002Reason\002: $ignreas"
  2504.             incr ignr
  2505.         }
  2506.     }
  2507.     putserv "NOTICE $nick :Found $ignr ignores matching $host"
  2508. }
  2509.  
  2510. # HOST Command
  2511. bind pub o $mcc(trigger)host mcc:cmd:host
  2512. proc mcc:cmd:host {nick uhost handle channel text} {
  2513.     global mcc
  2514.    
  2515.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2516.     if {![matchattr $handle o]} { return }
  2517.    
  2518.     set cmd [lindex [join $text] 0]
  2519.     set who [lindex [join $text] 1]
  2520.     set why [lindex [join $text] 2]
  2521.    
  2522.     switch -- [string tolower $cmd] {
  2523.         "add" {
  2524.             if {$why == ""} {
  2525.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)host add <handle> <hostname>"
  2526.                 return
  2527.             }
  2528.             if {![validuser $who]} {
  2529.                 putserv "NOTICE $nick :Error. Invalid handle."
  2530.                 return
  2531.             }
  2532.             setuser $who HOSTS $why
  2533.             putserv "NOTICE $nick :Added $why as $who`s hostname."
  2534.             return
  2535.         }
  2536.         "del" {
  2537.             if {$why == ""} {
  2538.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)host del <handle> <hostname>"
  2539.                 return
  2540.             }
  2541.             if {![validuser $who]} {
  2542.                 putserv "NOTICE $nick :Error. Invalid handle."
  2543.                 return
  2544.             }
  2545.             if {[delhost $who $why]} {
  2546.                 putserv "NOTICE $nick :Deleted host $why from $who`s hostlist."
  2547.             } else {
  2548.                 putserv "NOTICE $nick :Hostname $why not found on $who`s hostlist."
  2549.             }
  2550.             return
  2551.         }
  2552.         "list" {
  2553.             if {$who == ""} {
  2554.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)host list <handle>"
  2555.                 return
  2556.             }
  2557.             if {![validuser $who]} {
  2558.                 putserv "NOTICE $nick :Error. Invalid handle."
  2559.                 return
  2560.             }
  2561.             putserv "NOTICE $nick :$who Hosts: [getuser $who HOSTS]"
  2562.             return
  2563.         }
  2564.         "search" {
  2565.             if {$who == ""} {
  2566.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)host search <hostmask>"
  2567.                 return
  2568.             }
  2569.             putserv "NOTICE $nick :Searching.."
  2570.             set userlist ""
  2571.             set usernr "0"
  2572.             foreach user [userlist] {
  2573.                 if {[lsearch -glob [getuser $user HOSTS] $who] != "-1"} {
  2574.                     lappend userlist $user
  2575.                     incr usernr
  2576.                 }
  2577.             }
  2578.             if {$userlist != ""} {
  2579.                 foreach line [mcc:check:splitline [join $userlist]] {
  2580.                     putserv "NOTICE $nick :UserList: $line"
  2581.                 }
  2582.             }
  2583.             putserv "NOTICE $nick :Found $usernr users matching $who"
  2584.             return
  2585.         }
  2586.     }
  2587.     putserv "NOTICE $nick :Error. Usage: $mcc(trigger)host <add|del|list|search> <handle|hostmask>"
  2588. }
  2589.  
  2590. # BROADCAST Command
  2591. bind pub o $mcc(trigger)broadcast mcc:cmd:broadcast
  2592. proc mcc:cmd:broadcast {nick uhost handle channel text} {
  2593.     global mcc
  2594.    
  2595.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2596.     if {![matchattr $handle o]} { return }
  2597.    
  2598.     set txt [join [lrange [split $text] 0 end]]
  2599.    
  2600.     if {$txt == ""} {
  2601.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)broadcast <text>"
  2602.         return
  2603.     }
  2604.     foreach chan [channels] {
  2605.         if {![botonchan $chan]} { continue }
  2606.         putserv "PRIVMSG $chan :\[\002BROADCAST\002\] $txt"
  2607.     }
  2608. }
  2609.  
  2610. #
  2611. # Commands Level: GLOBAL MASTER (m|-)
  2612. #
  2613.  
  2614. # MSG Command
  2615. bind pub m $mcc(trigger)msg mcc:cmd:msg
  2616. proc mcc:cmd:msg {nick uhost handle channel text} {
  2617.     global mcc
  2618.    
  2619.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2620.     if {![matchattr $handle m]} { return }
  2621.    
  2622.     set user [lindex [join $text] 0]
  2623.     set txt [join [lrange [split $text] 1 end]]
  2624.    
  2625.     if {$txt == ""} {
  2626.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)msg <nick> <text>"
  2627.         return
  2628.     }
  2629.     putserv "PRIVMSG $user :$txt"
  2630.     putserv "NOTICE $nick :Message sent to $user."
  2631. }
  2632.  
  2633. #
  2634. # Commands Level: GLOBAL OWNER (n|-)
  2635. #
  2636.  
  2637. # REHASH Command
  2638. bind pub n $mcc(trigger)rehash mcc:cmd:rehash
  2639. proc mcc:cmd:rehash {nick uhost handle channel text} {
  2640.    
  2641.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2642.     if {![matchattr $handle n]} { return }
  2643.    
  2644.     putserv "NOTICE $nick :Rehashing.."
  2645.     mcc:msg:debug "\[\002REHASH\002\] $nick/\002$handle\002 rehashing.."
  2646.     rehash
  2647. }
  2648.  
  2649. # SAVE Command
  2650. bind pub n $mcc(trigger)save mcc:cmd:save
  2651. proc mcc:cmd:save {nick uhost handle channel text} {
  2652.    
  2653.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2654.     if {![matchattr $handle n]} { return }
  2655.    
  2656.     putserv "NOTICE $nick :Saving.."
  2657.     mcc:msg:debug "\[\002SAVE\002\] $nick/\002$handle\002 saving.."
  2658.     save
  2659. }
  2660.  
  2661. # RESTART Command
  2662. bind pub n $mcc(trigger)restart mcc:cmd:restart
  2663. proc mcc:cmd:restart {nick uhost handle channel text} {
  2664.    
  2665.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2666.     if {![matchattr $handle n]} { return }
  2667.    
  2668.     putserv "NOTICE $nick :Restarting.."
  2669.     mcc:msg:debug "\[\002RESTART\002] $nick/\002$handle\002 restarting.."
  2670.     utimer 5 [list restart]
  2671. }
  2672.  
  2673. # JUMP Command
  2674. bind pub n $mcc(trigger)jump mcc:cmd:jump
  2675. proc mcc:cmd:jump {nick uhost handle channel text} {
  2676.     global mcc
  2677.    
  2678.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2679.     if {![matchattr $handle n]} { return }
  2680.    
  2681.     set server [lindex [join $text] 0]
  2682.    
  2683.     if {$server == ""} {
  2684.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)jump <server>"
  2685.         return
  2686.     }
  2687.     jump $server
  2688. }
  2689.  
  2690. #
  2691. # Commands Level: BOT OWNER (n)
  2692. #
  2693.  
  2694. # DIE Command
  2695. bind pub n $mcc(trigger)die mcc:cmd:die
  2696. proc mcc:cmd:die {nick uhost handle channel text} {
  2697.     global owner
  2698.    
  2699.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2700.     if {![matchattr $handle n]} { return }
  2701.     if {[string tolower $handle] != [string tolower $owner]} { return }
  2702.     save
  2703.     utimer 5 [list die "010000100111100101100101"]
  2704. }
  2705.  
  2706. # NICK Command
  2707. bind pub n $mcc(trigger)nick mcc:cmd:nick
  2708. proc mcc:cmd:nick {nick uhost handle channel text} {
  2709.     global mcc owner
  2710.    
  2711.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2712.     if {![matchattr $handle n]} { return }
  2713.     if {[string tolower $handle] != [string tolower $owner]} { return }
  2714.    
  2715.     set bnick [lindex [join $text] 0]
  2716.    
  2717.     if {$bnick == ""} {
  2718.         putserv "NOTICE $nick :Error. Usage: $mcc(trigger)nick <nick>"
  2719.         return
  2720.     }
  2721.     mcc:proc:newnick $bnick
  2722.     putserv "NOTICE $nick :Changing my nick to $bnick."
  2723.     mcc:msg:debug "\[\002NICK\002\] $nick/\002$handle\002 changed my nick to $bnick"
  2724. }
  2725.  
  2726. # BOTNET Command
  2727. bind pub n $mcc(trigger)botnet mcc:cmd:botnet
  2728. proc mcc:cmd:botnet {nick uhost handle channel text} {
  2729.     global mcc botnet-nick my-ip owner nat-ip
  2730.    
  2731.     if {![mcc:check:logged $nick $handle $uhost]} { return }
  2732.     if {![matchattr $handle n]} { return }
  2733.     if {[string tolower $handle] != [string tolower $owner]} { return }
  2734.    
  2735.     set cmd [lindex [join $text] 0]
  2736.     set netnick [lindex [join $text] 1]
  2737.     set netip [lindex [join $text] 2]
  2738.     set netport [lindex [join $text] 3]
  2739.     set netflag [lindex [join $text] 4]
  2740.    
  2741.     switch -- [string tolower $cmd] {
  2742.         "info" {
  2743.             if {${nat-ip} == ""} {
  2744.                 set ip ${my-ip}
  2745.             } else {
  2746.                 set ip ${nat-ip}
  2747.             }
  2748.             putserv "NOTICE $nick :\002BotNet-Nick\002: ${botnet-nick} \002Telnet IP\002: ${ip} \002Telnet Port\002: $mcc(telnetport)"
  2749.             return
  2750.         }
  2751.         "list" {
  2752.             set blist ""
  2753.             foreach bot [userlist b] {
  2754.                 if {[string tolower $bot] == [string tolower ${botnet-nick}]} { continue }
  2755.                 if {[islinked $bot]} {
  2756.                     lappend blist $bot
  2757.                 } else {
  2758.                     lappend blist \0034$bot\003
  2759.                 }
  2760.             }
  2761.             if {$blist == ""} {
  2762.                 putserv "NOTICE $nick :BotList is empty."
  2763.                 return
  2764.             }
  2765.             foreach line [mcc:check:splitline [join $blist]] {
  2766.                 putserv "NOTICE $nick :BotList: $line"
  2767.             }
  2768.             return
  2769.         }
  2770.         "addhub" {
  2771.             if {$netport == ""} {
  2772.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)botnet addhub <botnet nick> <telnet ip> <telnet port> \[bot flags\]"
  2773.                 return
  2774.             }
  2775.             if {[validuser $netnick]} {
  2776.                 putserv "NOTICE $nick :Error. Handle \002$netnick\002 is not available."
  2777.                 return
  2778.             }
  2779.             addbot $netnick $netip:$netport
  2780.             botattr $netnick +h$netflag
  2781.             chattr $netnick +b
  2782.             putserv "NOTICE $nick :Added \002$netnick\002 as HUB Bot."
  2783.             if {[onchan $netnick $channel]} {
  2784.                 setuser $netnick HOSTS [getchanhost $netnick $channel]
  2785.             } else {
  2786.                 putserv "NOTICE $nick :Could not detect \002$netnick\002`s hostname. Use: $mcc(trigger)host add $netnick <hostname>"
  2787.             }
  2788.             return
  2789.         }
  2790.         "addleaf" {
  2791.             if {$netport == ""} {
  2792.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)botnet addleaf <botnet nick> <telnet ip> <telnet port> \[bot flags\]"
  2793.                 return
  2794.             }
  2795.             if {[validuser $netnick]} {
  2796.                 putserv "NOTICE $nick :Error. Handle \002$netnick\002 is not available."
  2797.                 return
  2798.             }
  2799.             addbot $netnick $netip:$netport
  2800.             botattr $netnick +l$netflag
  2801.             chattr $netnick +b
  2802.             putserv "NOTICE $nick :Added \002$netnick\002 as LEAF Bot."
  2803.             if {[onchan $netnick $channel]} {
  2804.                 setuser $netnick HOSTS [getchanhost $netnick $channel]
  2805.             } else {
  2806.                 putserv "NOTICE $nick :Could not detect \002$netnick\002`s hostname. Use: $mcc(trigger)host add $netnick <hostname>"
  2807.             }
  2808.             return
  2809.         }
  2810.         "link" {
  2811.             if {$netnick == ""} {
  2812.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)botnet link <botnet nick>"
  2813.                 return
  2814.             }
  2815.             if {![validuser $netnick] || ![matchattr $netnick b]} {
  2816.                 putserv "NOTICE $nick :Error. Could not find bot \002$netnick\002. See: $mcc(trigger)botnet list"
  2817.                 return
  2818.             }
  2819.             if {[islinked $netnick]} {
  2820.                 putserv "NOTICE $nick :Error. Bot \002$netnick\002 is linked."
  2821.                 return
  2822.             }
  2823.             link $netnick
  2824.             putserv "NOTICE $nick :Starting link with \002$netnick\002.."
  2825.             return
  2826.         }
  2827.         "unlink" {
  2828.             if {$netnick == ""} {
  2829.                 putserv "NOTICE $nick :Error. Usage: $mcc(trigger)botnet unlink <botnet nick>"
  2830.                 return
  2831.             }
  2832.             if {![validuser $netnick] || ![matchattr $netnick b]} {
  2833.                 putserv "NOTICE $nick :Error. Could not find bot \002$netnick\002. See $mcc(trigger)botnet list"
  2834.                 return
  2835.             }
  2836.             if {![islinked $netnick]} {
  2837.                 putserv "NOTICE $nick :Error. Bot \002$netnick\002 is not linked."
  2838.                 return
  2839.             }
  2840.             unlink $netnick
  2841.             putserv "NOTICE $nick :Closing link with \002$netnick\002.."
  2842.             return
  2843.         }
  2844.     }
  2845.     putserv "NOTICE $nick :Error. Usage: $mcc(trigger)botnet <info|list|addhub|addleaf|link|unlink|chat> \[BotNet Nick\] \[Telnet Ip\] \[Telnet Port\] \[Bot Flags\]"
  2846. }
  2847.  
  2848. putlog "MCC $mcc(scriptversion) by dirty Inc. Loaded."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement