All pastes #934717 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-09 00:53 UTC
rendered paste body
package require http
bind pubm - "*" bind:pubm
proc bind:pubm {nick userhost handle chan text} {
  global botnick iktag ikadminchan
  if {[regexp -nocase "(^(All|$iktag|$botnick)(!|@)(.*?))" $text] == 1} {
     if {[regexp -nocase "(^(All|$iktag|$botnick)!(.*?))" $text] == 1} { set target "NOTICE $nick" } elseif {[regexp -nocase "(^(All|$iktag|$botnick)@(.*?))" $text] == 1} { set target "PRIVMSG $chan" }
     regsub -all -nocase {!} $text { } text 
     regsub -all -nocase {@} $text { } text
     if {[isop $nick $ikadminchan] == 1} {      
      set text [lrange $text 1 end]
      set com [lindex $text 0]
      switch $com {        
        channels { ik:channels $target }
        part { ik:part $nick $target [lindex $text "1"] }
        join { ik:join $nick $target [lindex $text "1"] }
        ccount { ik:ccount $target } 
        ucheck { ik:ucheck $target }
        help { ik:help $target }
        msg { ik:msg [lindex $text 1] [lrange $text 2 end] }
      }
    }
  } 
}
proc event:part {nick chan reason} {
  global c1 c2 ikadminchan
  putserv "PRIVMSG $ikadminchan :\[Part\] \003$c1\Parting \003$c2$chan \003$c1\Reason: \003$c2$reason"
  channel remove $chan
}
proc event:join {nick chan reason} {
  global c1 c2 ikadminchan
  putserv "PRIVMSG $ikadminchan :\[Join\] \003$c1\Joining \003$c2$chan \003$c1\Reason: \003$c2$reason"
  channel add $chan
}
proc ik:help {target} { puthelp "$target :Help Doc Information" }
proc ik:channels {target} { putserv "$target :Currently on: [channels]" }
proc ik:msg {target message} { putserv "PRIVMSG $target :$message" }
proc ik:ucheck {target} {
   global ikadminchan botnick
   foreach com [channels] {
     if {[llength [chanlist $com]] < 4} { 
       event:part $botnick $com "[llength [chanlist $com]] Users"
    }
  }
}
proc ik:ccount {target} {
   global ikadminchan
   set usercount 0
   foreach com [channels] { incr usercount [llength [chanlist $com]] } 
   putserv "$target :I am in [llength [channels]] channels with $usercount users."
}
proc ik:part {nick target chan} {
  global botnick
  event:part $botnick $chan "Part command used by $nick"
}
proc ik:join {nick target chan} {
  global botnick
  event:join $botnick $chan "Join command used by $nick"
}