bind notc - * battle:noticekick
bind pubm - * battle:mainchan
bind time - "00 * * * *" battle:unsetwarn
array set warned {}
proc battle:noticekick {nick uhost handle text dest} {
if {[validchan $dest]} {
set dest [string tolower $dest]
if {[string equal $dest "#century0"] && ![matchattr $handle D]} {
putquick "PRIVMSG Chanserv :#century0 addtimedban $nick 3m Please for the love all that’s holy and rocky don’t do that. Trust us if we want the channel to make a large beeping sound…..we can do it ourselves. \[3 minute ban\]"
}
}
}
proc battle:warnnick {nick host hand chan text} {
putserv "NOTICE $nick :You almost stepped on a landmine there Mr. Rockstar. Check out @rockrules and @advertising"
}
proc battle:mainchan {nick host hand chan text} {
global warned
set chan [string tolower $chan]
if {[string equal $chan "#century0"]} {
set text [stripcodes bcr $text]
if {[string match -nocase "*hotrockplanet*" $text] || [string match -nocase "*egln*" $text]} {
return 0
} elseif {[string match -nocase "*#*" $text] || [string match -nocase "*www*" $text] || [string match -nocase "*.com*" $text] || [string match -nocase "*.net*" $text] || [string match -nocase "*.org*" $text] || [string match -nocase "*http*" $text]} {
if {$warned($nick) == 1} {
putserv "PRIVMSG Chanserv :#century0 addtimedban $nick 3m Advertising is not permitted in #hotrockplanet. Please read @advertising and @rockrules when you return. \[3 minute ban\]"
set warned($nick) 0
} else {
set warned($nick) 1
battle:warnnick nick host hand chan text
}
} else {
return 0
}
}
}
proc battle:unsetwarn { min hour day month year } {
global warned
foreach nick [array names warned] {
if {$warned($nick) == 1} {
set $warned($nick) 0
}
}
}
[22:18] #Century0# set errorInfo
Currently: can't read "warned(Ging_sleepTIME)": no such element in array
Currently: while executing
Currently: "if {$warned($nick) == 1} {
Currently: putserv "PRIVMSG Chanserv :#cent ury0 addtimedban $nick 3m Advertising is not permitted in #hotrockplanet. Please read ..."
Currently: (procedure "battle:mainchan" line 9)
Currently: invoked from within
Currently: "battle:mainchan $_pubm1 $_pubm2 $_pubm3 $_pubm4 $_pubm5"
if {$warned($nick) == 1} {
putserv "PRIVMSG Chanserv :#century0 addtimedban $nick 3m Advertising is not permitted in #hotrockplanet. Please read @advertising and @rockrules when you return. \[3 minute ban\]"
set warned($nick) 0
You test the var before ever setting it elsewhere (line 9 of the proc)..
You're testing {$nick == $botnick} first, so of course the part where the array is being set, is not going to be set unless the nick is the botnick..
You probably want to do {foreach nick [chanlist #century0]} {if {$nick != $botnick} and so on, so that the arrays are set for each nick except botnick...But, actually, that will only work on existing names in the channel, and not when they join/part/quit. It would be more reasonable to test for some condition that you're trying to warn for, set the array var for the nick, then execute whatever warning/punishment..
The logic and intention of your original script is not very clear, so it's difficult to make suggestions..
Instead of a foreach loop to catch all the users on the channel and setting them in an array, why not check if the variable for the user exists then set it if not.
proc battle:mainchan {nick host hand chan text} {
global warned
set chan [string tolower $chan]
if {[string equal $chan "#century0"]} {
if {![info exists warned($nick)]} {
set warned($nick) "0"
return
}
..... rest of code here ......
}
Also maybe put all of those string match's into one simple regexp.