trigserv.disabled (3621B)
1 sendUid $::sock($::cs(netname)) "T" "trigserv" "services." "services." 37 "Channel Spam Reduction and Trigger Services" 2 #putmode $::sock($::cs(netname)) 37 "T" "-d" "" "" 3 foreach {chan is} [nda get "trigserv/regchan"] { 4 if {1!=$is} {continue} 5 putjoin $::sock($::cs(netname)) 37 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"] 6 tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock($::cs(netname)))/ts"] 7 } 8 bind request "t" "-" trigservjoin 9 bind request "trigserv" "-" trigservjoin 10 #bind join "-" "-" trigservup 11 #bind part "-" "-" trigservdown 12 bind pub "-" "!addtrig" trigservdochan 13 bind evnt "-" "chanmsg" trigservtest 14 15 proc ndaenc {n} { 16 return [string map {/ [} [::base64::encode [string tolower $n]]] 17 } 18 19 proc ndadec {n} { 20 return [::base64::decode [string map {[ /} $n]] 21 } 22 23 proc trigservjoin {chan msg} { 24 set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]] 25 putjoin $::sock($::cs(netname)) 37 $chan [nda get "regchan/$ndacname/ts"] 26 nda set "trigserv/regchan/$ndacname" 1 27 } 28 29 proc trigservdochan {cname msg} { 30 set chan [string map {/ [} [::base64::encode [string tolower $cname]]] 31 set from [lindex $msg 0 0] 32 set trigname [lindex $msg 1 0] 33 set trigtype [lindex $msg 1 1] 34 set trigcriteria [lindex $msg 1 2] 35 set trigaction [lrange [lindex $msg 1] 3 end] 36 if {200>[nda get "regchan/$chan/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]} { 37 privmsg $::sock($::cs(netname)) 37 $cname "You must be at least op to set a trigger on the channel." 38 return 39 } 40 nda set "trigserv/trig/$chan/[ndaenc $trigtype]/[ndaenc $trigname]/[ndaenc $trigcriteria]" $trigaction 41 } 42 43 proc trigservdecay {target} { 44 tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$::netname($::sock($::cs(netname)))/$::netname($::sock($::cs(netname)))/$target"] - 1}] 45 } 46 47 proc trigservincr {target} { 48 tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$::netname($::sock($::cs(netname)))/$::netname($::sock($::cs(netname)))/$target"] + 1}] 49 } 50 51 proc trigservtest {cname msg} { 52 set chan [string map {/ [} [::base64::encode [string tolower $cname]]] 53 set from [lindex $msg 0 0] 54 set trigcmd [lindex $msg 1 0] 55 set trigline [join [lrange [lindex $msg 1] 0 end] " "] 56 foreach {type _} [nda get "trigserv/trig/$chan"] { 57 foreach {tname _} [nda get "trigserv/trig/$chan/$type"] { 58 foreach {criterion action} [nda get "trigserv/trig/$chan/$type/$tname"] { 59 set crit [split [ndadec $criterion] ":"] 60 trigservcriterion $chan $type $tname $crit $action $trigcmd $trigline $from 61 } 62 } 63 } 64 } 65 66 proc trigservcriterion {chan type tname criterion action trigcmd trigline from} { 67 switch -nocase -- [lindex $criterion 0] { 68 "flood" { 69 trigservincr $chan 70 puts stdout [tnda get "trigserv/flood/$::netname($::sock($::cs(netname)))/$chan"] 71 after [expr {[lindex $criterion 2] * 1000}] trigservdecay $chan 72 if {[tnda get "trigserv/flood/$::netname($::sock($::cs(netname)))/$chan"] >= [lindex $criterion 1]} { 73 privmsg $::sock($::cs(netname)) 37 [ndadec $chan] "Message flood detected; setting +mi for 60 seconds" 74 putmode $::sock($::cs(netname)) 37 [ndadec $chan] "+mi" "" [tnda get "channels/$chan/$::netname($::sock($::cs(netname)))/ts"] 75 after 60000 {putmode $::sock($::cs(netname)) 37 [ndadec $chan] "-mi" "" [tnda get "channels/$chan/$::netname($::sock($::cs(netname)))/ts"]} 76 } 77 } 78 "cmd" { 79 if {$trigcmd == [lindex $criterion 1]} { 80 privmsg $::sock($::cs(netname)) 37 [ndadec $chan] [join [list "\002[tnda get "nick/$::netname($::sock($::cs(netname)))/$from"]\002:" $action] " "] 81 } 82 } 83 } 84 }