| View previous topic :: View next topic |
| Author |
Message |
irate Voice
Joined: 18 Jun 2007 Posts: 8
|
Posted: Thu Jun 21, 2007 11:56 am Post subject: Anti Racism |
|
|
| Code: | set advwords {
"offensive word"
}
### Set Advertising Words that you want the Bot to EXEMPT (Dont count as spam)
set advexemptwords {
"night"
}
### Borrowed from awyeahs tcl scripts (www.awyeah.org) ###
proc ccodes:filter {str} {
regsub -all -- {\003([0-9]{1,2}(,[0-9]{1,2})?)?|\017|\037|\002|\026|\006|\007} $str "" str
return $str
}
## Binding all Public Messages to our Process
bind pubm - * filter_advertisement
## Starting Process
proc filter_advertisement {nick uhost handle channel args} {
global advwords advreason banmask botnick advduration advexemptwords
set args [ccodes:filter $args]
set handle [nick2hand $nick]
foreach advword [string tolower $advwords] {
if {[string match *$advword* [string tolower $args]]} {
foreach advexemptword [string tolower $advexemptwords] {
if {![string match *$advexemptword* [string tolower $args]]} {
if {[matchattr $handle Kooky15]} {
} elseif {[matchattr $handle +o]} {
putserv "PRIVMSG #iratest :The admin $nick used a racist word ($args)."
} else {
putquick "KICK $channel $nick :noob"
}
}
}
}
}
} |
It halts after the second if, if someone could help me fix it, it would be great. Thanks! |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Thu Jun 21, 2007 2:04 pm Post subject: |
|
|
It would be easier to check if the word is protected/excempt before.
Try:
| Code: | proc filter_advertisement {nick uhost handle channel text} {
global advwords advreason banmask botnick advduration advexemptwords
set text [ccodes:filter $text]
set racist 0
foreach word [split $text " "] {
if {![string match -nocase "*$word*" "$advexemptwords"]} {
if {[string match -nocase "*$word*" "$advwords"]} {
set racist 1
break
}
}
}
if {[matchattr $handle o|o $channel] && $racist} {
putserv "PRIVMSG #iratest :An admin $nick used a racist word ($text)."
} elseif {$racist} {
putserv "KICK $channel $nick :noob"
}
}
|
_________________ r0t3n @ #r0t3n @ Quakenet
Last edited by r0t3n on Fri Jun 22, 2007 10:41 am; edited 1 time in total |
|
| Back to top |
|
 |
irate Voice
Joined: 18 Jun 2007 Posts: 8
|
Posted: Thu Jun 21, 2007 5:11 pm Post subject: |
|
|
There's an error still
| Quote: | | Tcl error [filter_racism]: wrong # args: no expression after "if" argument |
Thank you. |
|
| Back to top |
|
 |
irate Voice
Joined: 18 Jun 2007 Posts: 8
|
Posted: Fri Jun 22, 2007 1:19 am Post subject: |
|
|
| Does anyone know what's causing that error? |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Fri Jun 22, 2007 4:07 am Post subject: |
|
|
| irate wrote: | | Does anyone know what's causing that error? |
The conditional statement is incorrect.
Have a closer look.
This might help also: if manual page _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Fri Jun 22, 2007 10:41 am Post subject: |
|
|
I made a typo error (-nocaase) in the second if statement of the forward loop, i've updated the code in the post above. It should work now. _________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
irate Voice
Joined: 18 Jun 2007 Posts: 8
|
Posted: Fri Jun 22, 2007 11:27 am Post subject: |
|
|
| Yeah, I fixed that, and then it showed me that error. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Jun 22, 2007 6:38 pm Post subject: |
|
|
You probably used some editor which added a \n after 'if' or something like that causing it to become erroneous. Use a proper editor (such as notepad on windows) while pasting/editing code. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Sun Jun 24, 2007 7:19 am Post subject: |
|
|
Actually you can use stripcodes in eggdrop v1.6.17 or higher, and remove that strip codes proc.
| Code: |
set args [stripcodes bcruag $args]
|
_________________ ·awyeah·
==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
================================== |
|
| Back to top |
|
 |
|