All pastes #934867 Raw Edit

Mine

public text v1 · immutable
·published 2008-03-09 03:55 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} {
		set target [core:disp $chan $nick $text]
		regsub -nocase {!} $text { } text 
		regsub -nocase {@} $text { } text
		if {[isop $nick $ikadminchan] == 1} { 
			set text [lrange $text 1 end]
			set com [lindex $text 0]
			switch $com {        
				channels { ik:channels $nick $chan $userhost $handle $target $text $com }
				part { ik:part $nick $chan $userhost $handle $target $text $com [lindex $text "1"] }
				join { ik:join $nick $chan $userhost $handle $target $text $com [lindex $text "1"] }
				ccount { ik:ccount $nick $chan $userhost $handle $target $text $com } 
				ucheck { ik:ucheck $nick $chan $userhost $handle $target $text $com }
				help { ik:help $nick $chan $userhost $handle $target $text $com }
				msg { ik:msg $nick $chan $userhost $handle $target $text $com [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 {nick chan userhost handle target text com} { puthelp "$target :Help Doc Information" }
proc ik:channels {nick chan userhost handle target text com} { putserv "$target :Currently on: [channels]" }
proc ik:msg {nick chan userhost handle target text com sendchan message} { putserv "PRIVMSG $sendchan :$message" }
proc ik:ucheck {nick chan userhost handle target text com} {
	global ikadminchan botnick
	foreach line [channels] {
		if {[llength [chanlist $line]] < 4} {
			event:part $botnick $com "[llength [chanlist $line]] Users"
		}
	}
}
proc ik:ccount {nick chan userhost handle target text com} {
	global ikadminchan
	set usercount 0
	foreach line [channels] { incr usercount [llength [chanlist $line]] } 
	putserv "$target :I am in [llength [channels]] channels with $usercount users."
}
proc ik:part {nick chan userhost handle target text com chanp} {
	global botnick
	event:part $botnick $chanp "Part command used by $nick"
}
proc ik:join {nick chan userhost handle target text com chanj} {
	global botnick
	event:join $botnick $chanj "Join command used by $nick"
}
proc core:disp {chan nick text} {
	global iktag botnick
        if {[regexp -nocase "(^(All|$iktag|$botnick)!(.*?))" $text] == 1} { return "NOTICE $nick" }
        if {[regexp -nocase "(^(All|$iktag|$botnick)@(.*?))" $text] == 1} { return "PRIVMSG $chan" }
}