This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Problem with guard.tcl - Illegal channel: *

Old posts that have not been replied to for several years.
Locked
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

Problem with guard.tcl - Illegal channel: *

Post by Aron »

Although it seems to be a pretty harmless error, it is pretty annoying:

Every time someone messages the bot, it will trigger. It is a problem with guard101.tcl, but i cant seem to figure it out. Here are the two procedures that are causing the error (i think):

The msg_guard procedure:

Code: Select all

bind msgm - "*" msg_guard
proc msg_guard {nick uhost hand text} {
 global guard
 guard $nick $uhost $hand "*" $text
 guard_inc msg $guard(msg) $guard(msgtime)
}
...and the actual guard procedure:

Code: Select all

proc guard {nick uhost hand desc text} {
global guard guardn

if {![botisop $desc]} { return 0 }

subst -nobackslashes -nocommands -novariables text
if {([matchattr $hand b])} {return 0}
if {([matchattr $hand o])} {return 0}
if {([matchattr $hand f])} {return 0}
if {($desc != "*") && ([string index $desc 0] == "#")} {
 if {([matchchanattr $hand |o $desc])} {return 0}
 if {([matchchanattr $hand |f $desc])} {return 0}
 if {[isop $nick $desc]} {return 0}
                  }
regsub -all {\{} $text "?" text
regsub -all {\(} $text "?" text
regsub -all {\"} $text "?" text
regsub -all {\[} $text "?" text
regsub -all {\]} $text "?" text

set rtext $text
if {[llength $text] == 1} {set text [lindex $text 0]}
set text [string tolower $text]

set lnick [string tolower $nick]
set sitemask "*!*[string trimleft [maskhost $uhost] *!]"
if {![info exists guardn($lnick)]} {set guardn($lnick) "0 0 0 0 0 0 0 [unixtime] $text"
                                    append guardn(nicks) "$lnick "
                                   }

 set g_repeat [lindex $guardn($lnick) 0]
 set g_sflood [lindex $guardn($lnick) 1]
 set g_aflood [lindex $guardn($lnick) 2]
 set g_1flood [lindex $guardn($lnick) 3]
 set g_cc [lindex $guardn($lnick) 4]
 set g_caps [lindex $guardn($lnick) 5]
 set g_spaces [lindex $guardn($lnick) 6]
 set g_time [lindex $guardn($lnick) 7]
 set g_text [lrange $guardn($lnick) 8 end]

 set caps 0
 set spaces 0
 set gloop 0; set CC 0
 while {$gloop < [string length $text]} {
  if {[string match "*[string index $rtext $gloop]*" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]} {incr caps 1}
  if {[string index $text $gloop] == "\003"} {incr CC 1}
  if {[string index $text $gloop] == " "} {incr spaces 1}
  incr gloop 1
                                        }
if {([guardchan $desc $guard(nocolors)]) && ($CC >> $guard(color_max))} {incr g_cc 1} else {set g_cc 0}
set totc [string length $rtext]
if {$text != ""} {set capsp [expr (${caps}.0 / ${totc}.0) * 100]} else {set capsp 0}
if {($totc > $guard(caps_min)) && ($capsp > $guard(caps_per))} {incr g_caps 1} else {set g_caps 0}
if {($totc > $guard(spaces_min)) && ($spaces == 0)} {incr g_spaces 1} else {set g_spaces 0}

#repeat flood
 if {$g_text == $text} {incr g_repeat 1} else {set g_repeat 0}
# Add char flood
if {[string range $text 0 [expr [string length $text] - 2]] == $g_text} {incr g_aflood} else {set g_aflood 0}
# Sub char flood
if {[string range $g_text 0 [expr [string length $g_text] - 2]] == $text} {incr g_sflood} else {set g_sflood 0}

if {[string length $text] == 1} {incr g_1flood} else {set g_1flood 0}
#if ([$strlen($Rtext)] == 1) {@SCcnt = SCcnt + 1}{@SCcnt = 1}

# if {$g_cc == $guard(color_warn)} {guardsay $nick $desc "$nick: $guard(color_reason)"}
# if {$g_cc == $guard(color_kick)} {guardkick $nick $desc $guard(color_reason)}
# if {$g_cc == $guard(color_ban)} {guardban $nick $sitemask $desc $guard(color_reason)}

# if {$g_spaces == $guard(spaces_warn)} {guardsay $nick $desc "$nick: $guard(color_spaces)"}
# if {$g_spaces == $guard(spaces_kick)} {guardkick $nick $desc $guard(spaces_reason)}
# if {$g_spaces == $guard(spaces_ban)} {guardban $nick $sitemask $desc $guard(spaces_reason)}


 if {$g_caps == $guard(caps_warn)} {guardsay $nick $desc "$nick: $guard(caps_reason)"}
 if {$g_caps == $guard(caps_kick)} {guardkick $nick $desc "$guard(caps_reason)"}
 if {$g_caps == $guard(caps_ban)} {guardban $nick $sitemask $desc "$guard(caps_reason)"}

 if {$g_1flood == $guard(scflood_ban)} {set g_1flood 0; guardban $nick $sitemask $desc $guard(scflood_reason)}
 if {$g_sflood == $guard(subflood_ban)} {set g_sflood 0; guardban $nick $sitemask $desc $guard(subflood_reason)}
 if {$g_aflood == $guard(addflood_ban)} {set g_aflood 0; guardban $nick $sitemask $desc $guard(addflood_reason)}
 if {$g_repeat == $guard(repeat_warn)} {guardsay $nick $desc "$nick: Please do not repeat"}
 if {$g_repeat == $guard(repeat_kick)} {guardkick $nick $desc "$nick: Please do not repeat. Last warning."}
 if {$g_repeat == $guard(repeat_ban)} {guardban $nick $sitemask $desc "Don't Repeat! Don't Repeat! Don't Repeat! Don't Repeat!"}

 set guardn($lnick) "$g_repeat $g_sflood $g_aflood $g_1flood $g_cc $g_caps $g_spaces [unixtime] $text"
 return 0
}
Thanks in advance.

-Aron
The best way to start learning is to start helping.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

The first proc is handeling msgs to the bot, and has nothing to do with channels. Then "*" is sent as a channelname to the next proc, which is covering channels, and not msgs!
You have to set a channelname in the first proc...
something like this.... ofc then it will only work in one channel =)

Code: Select all

guard $nick $uhost $hand "#somechannelname" $text 
Elen sila lúmenn' omentielvo
Locked