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.

My 'Excessive ASCII Codes Kick' Script is not working!

Old posts that have not been replied to for several years.
Locked
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

My 'Excessive ASCII Codes Kick' Script is not working!

Post by awyeah »

Hello,

I have built this script from seeing other scripts.
I have a same detto type of script for EXCESSIVE CONTROL CODES
which includes bold, color, reverse, inverse and plain. That script
works fine and has no problem.

This is alike it based on the same algorithm only the search words/keys
are changed as these are ascii not control codes.

When I execute this script, My bot doesn't kick on excessive ascii codes.
I check in DCC with the BOT, it doesn't give any error while executing this script as well, infact I get no msg while the script executes.

I don't know what is happening, I get no result output from the bot.
Do you think that eggdrops ignore ASCII in TCL?

I have no idea... what is happening and why doesn't this script work.
Please help me.


HERE IS THE SCRIPT:

###########################################
## ------------------------------------- ##
## 25. Excessive ASCII Codes Kick Script ##
## ------------------------------------- ##
###########################################


# This variable is used to determine MAXIMUM VALUES allowed for ASCII codes.
# If the maximum value of control codes detected in a text/action is great than or equal to
# this variable then the script will kick/ban that user.
set ascii_maxchar 20


######### Please don't edit anything below unless you know what you are doing ;) #########

bind pub - * asciicodes
bind pubm - * asciicodes
bind ctcp - ACTION ctcp_asciicodes

proc asciicodes {nick uhost hand chan text} {
global botnick ascii_maxchar ascii_chans
set file [open $::kickno r]
set tilnow "[gets $file]"
catch {close $file}
set totalkicks [expr $tilnow]
if {[isbotnick $nick]} {return 0}
if {[string match \[^!-ÿ\] $text]} {
set asciibanhost1 "*!*@[lindex [split $uhost @] 1]"
set asciibanhost2 "*!*$uhost"
set asciilength [string length $text]
set ascii1 0; set ascii2 0; set ascii3 0; set ascii4 0; set ascii5 0; set ascii6 0; set ascii7 0; set ascii8 0; set ascii9 0; set ascii10 0
set ascii11 0; set ascii12 0; set ascii13 0; set ascii14 0; set ascii15 0; set ascii16 0; set ascii17 0; set ascii18 0; set ascii19 0; set ascii20 0
set ascii21 0; set ascii22 0; set ascii23 0; set ascii24 0; set ascii25 0; set ascii26 0; set ascii27 0; set ascii28 0; set ascii29 0; set ascii30 0
set ascii31 0; set ascii32 0; set ascii33 0; set ascii34 0; set ascii35 0; set ascii36 0; set ascii37 0; set ascii38 0; set ascii39 0; set ascii40 0
set ascii41 0; set ascii42 0; set ascii43 0; set ascii44 0; set ascii45 0; set ascii46 0; set ascii47 0; set ascii48 0; set ascii49 0; set ascii50 0
set ascii51 0; set ascii52 0; set ascii53 0; set ascii54 0; set ascii55 0; set ascii56 0; set ascii57 0; set ascii58 0; set ascii59 0; set ascii60 0
set ascii61 0; set ascii62 0; set ascii63 0; set ascii64 0; set ascii65 0; set ascii66 0; set ascii67 0; set ascii68 0; set ascii69 0; set ascii70 0
set ascii71 0; set ascii72 0; set ascii73 0; set ascii74 0; set ascii75 0; set ascii76 0; set ascii77 0; set ascii78 0
for {set j 0} {$j < $asciilength} {incr j} {
if {[string index $text $j] == "€"} {incr ascii1}
if {[string index $text $j] == "ƒ"} {incr ascii2}
if {[string index $text $j] == "†"} {incr ascii3}
if {[string index $text $j] == "Š"} {incr ascii4}
if {[string index $text $j] == "Œ"} {incr ascii5}
if {[string index $text $j] == "š"} {incr ascii6}
if {[string index $text $j] == "œ"} {incr ascii7}
if {[string index $text $j] == "Ÿ"} {incr ascii8}
if {[string index $text $j] == "¢"} {incr ascii9}
if {[string index $text $j] == "£"} {incr ascii10}
if {[string index $text $j] == "¥"} {incr ascii11}
if {[string index $text $j] == "§"} {incr ascii12}
if {[string index $text $j] == "©"} {incr ascii13}
if {[string index $text $j] == "®"} {incr ascii14}
if {[string index $text $j] == "µ"} {incr ascii15}
if {[string index $text $j] == "¶"} {incr ascii16}
if {[string index $text $j] == "À"} {incr ascii17}
if {[string index $text $j] == "Á"} {incr ascii18}
if {[string index $text $j] == "Â"} {incr ascii19}
if {[string index $text $j] == "Ã"} {incr ascii20}
if {[string index $text $j] == "Ä"} {incr ascii21}
if {[string index $text $j] == "Å"} {incr ascii22}
if {[string index $text $j] == "Æ"} {incr ascii23}
if {[string index $text $j] == "Ç"} {incr ascii24}
if {[string index $text $j] == "È"} {incr ascii25}
if {[string index $text $j] == "É"} {incr ascii26}
if {[string index $text $j] == "Ê"} {incr ascii27}
if {[string index $text $j] == "Ë"} {incr ascii28}
if {[string index $text $j] == "Ì"} {incr ascii29}
if {[string index $text $j] == "Í"} {incr ascii30}
if {[string index $text $j] == "Î"} {incr ascii31}
if {[string index $text $j] == "Ï"} {incr ascii32}
if {[string index $text $j] == "Ð"} {incr ascii33}
if {[string index $text $j] == "Ñ"} {incr ascii34}
if {[string index $text $j] == "Ò"} {incr ascii35}
if {[string index $text $j] == "Ó"} {incr ascii36}
if {[string index $text $j] == "Ô"} {incr ascii37}
if {[string index $text $j] == "Õ"} {incr ascii38}
if {[string index $text $j] == "Ö"} {incr ascii39}
if {[string index $text $j] == "Ø"} {incr ascii40}
if {[string index $text $j] == "Ù"} {incr ascii41}
if {[string index $text $j] == "Ú"} {incr ascii42}
if {[string index $text $j] == "Û"} {incr ascii43}
if {[string index $text $j] == "Ü"} {incr ascii44}
if {[string index $text $j] == "Ý"} {incr ascii45}
if {[string index $text $j] == "Þ"} {incr ascii46}
if {[string index $text $j] == "ß"} {incr ascii47}
if {[string index $text $j] == "à"} {incr ascii48}
if {[string index $text $j] == "á"} {incr ascii49}
if {[string index $text $j] == "â"} {incr ascii50}
if {[string index $text $j] == "ã"} {incr ascii51}
if {[string index $text $j] == "ä"} {incr ascii52}
if {[string index $text $j] == "å"} {incr ascii53}
if {[string index $text $j] == "æ"} {incr ascii54}
if {[string index $text $j] == "ç"} {incr ascii55}
if {[string index $text $j] == "è"} {incr ascii56}
if {[string index $text $j] == "é"} {incr ascii57}
if {[string index $text $j] == "ê"} {incr ascii58}
if {[string index $text $j] == "ë"} {incr ascii59}
if {[string index $text $j] == "ì"} {incr ascii60}
if {[string index $text $j] == "í"} {incr ascii61}
if {[string index $text $j] == "î"} {incr ascii62}
if {[string index $text $j] == "ï"} {incr ascii63}
if {[string index $text $j] == "ð"} {incr ascii64}
if {[string index $text $j] == "ñ"} {incr ascii65}
if {[string index $text $j] == "ò"} {incr ascii66}
if {[string index $text $j] == "ó"} {incr ascii67}
if {[string index $text $j] == "ô"} {incr ascii68}
if {[string index $text $j] == "õ"} {incr ascii69}
if {[string index $text $j] == "ö"} {incr ascii70}
if {[string index $text $j] == "ø"} {incr ascii71}
if {[string index $text $j] == "ù"} {incr ascii72}
if {[string index $text $j] == "ú"} {incr ascii73}
if {[string index $text $j] == "û"} {incr ascii74}
if {[string index $text $j] == "ü"} {incr ascii75}
if {[string index $text $j] == "ý"} {incr ascii76}
if {[string index $text $j] == "þ"} {incr ascii77}
if {[string index $text $j] == "ÿ"} {incr ascii78}
}
set totalascii_codes [expr $ascii1 + $ascii2 + $ascii3 + $ascii4 + $ascii5 + $ascii6 + $ascii7 + $ascii8 + $ascii9 + $ascii10 + $ascii11 + $ascii12 + $ascii13 + $ascii14 + $ascii15 + $ascii16 + $ascii17 + $ascii18 + $ascii19 + $ascii20 + $ascii21 + $ascii22 + $ascii23 + $ascii24 + $ascii25 + $ascii26 + $ascii27 + $ascii28 + $ascii29 + $ascii30 + $ascii31 + $ascii32 + $ascii33 + $ascii34 + $ascii35 + $ascii36 + $ascii37 + $ascii38 + $ascii39 + $ascii40 + $ascii41 + $ascii42 + $ascii43 + $ascii44 + $ascii45 + $ascii46 + $ascii47 + $ascii48 + $ascii49 + $ascii50 + $ascii51 + $ascii52 + $ascii53 + $ascii54 + $ascii55 + $ascii56 + $ascii57 + $ascii58 + $ascii59 + $ascii60 + $ascii61 + $ascii62 + $ascii63 + $ascii64 + $ascii65 + $ascii66 + $ascii67 + $ascii68 + $ascii69 + $ascii70 + $ascii71 + $ascii72 + $ascii73 + $ascii74 + $ascii75 + $ascii76 + $ascii77 + $ascii78]
if {([botisop $chan]) && (![isop $nick $chan]) && (![isvoice $nick $chan]) && (![matchattr $hand mnf|mnf $chan]) && ($totalascii_codes >= $ascii_maxchar)} {
putquick "MODE $chan -o+bb $nick $asciibanhost2 $asciibanhost1"
putquick "KICK $chan $nick :0,1 Excessive ASCII Codes Kick 12,0- Your 2text/action 12exceeded2 $ascii_maxchar ascii code characters. 12Total 2Ascii codes 12detected:2 $totalascii_codes. 12Please 2*do not* use ascii codes 12to display as a2 text or action 12in this channel, because they are2 difficult to read.2 - (Kick #$totalkicks)"
timer 30 "putserv \"mode $chan -bb $asciibanhost2 $asciibanhost1\""
return 0
}
}
}


proc ctcp_asciicodes {nick uhost hand chan keyword rest} {
asciicodes $nick $uhost $hand $chan $rest
}
[/quote]
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

I suspect you're having a problem with the encoding used when reading your script in (try '.tcl info body yourproc' in dcc and check what those "forbidden" chars look like)
Try something like this instead (all chars represented by escape sequences)

Code: Select all

proc asciicodes {nick uhost hand chan text} {
	# do these checks first as there's no point in doing all that work
	# if you end up not kicking them over this :P
	if {[botisop $chan]&&![isop $nick $chan]&&![isvoice $nick $chan]&&![matchattr $hand mnf|mnf $chan]} {
		# use "\[\x80-\xFF\]" here if you want the entire high range:
		set num [regexp -all "\[\x80\x83\x86\x8A\x8C\x9A\x9C\x9F\xA2\xA3\xA5\xA7\xA9\xAE\xB5\xB6\xC0-\xD6\xD8-\xF6\xF8-\xFF\]" $text]
		if {$num>$ascii_maxchar} {
			# read the kick counter and kick
		}
	}
}
Also, there's no point in setting both bans like you do...the second one makes the first one redundant.
(btw: everything on irc is ascii codes, so you might aswell use 'string length' to do the counting ;P)
Have you ever read "The Manual"?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Thanks for the script, I'll look into it and notify you if I reach a problem again.

As for the bans I just like a little better style -o+bb, from a script which I saw, makes the bot look a bit more human or like a person using a script, rather than a normal eggdrop.

Secondly yeah stringlength is a good idea to count the total the ascii codes in. The normal addition method is very messy.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Hi, this procecedure is not working.

proc asciicodes {nick uhost hand chan text} {
global botnick maxascii
set num [regexp -all "\[\x80-\xFF\]" $text]
set asciicodes [string length $num]
if {[botisop $chan] && (![isop $nick $chan]) && (![isvoice $nick $chan]) && (![matchattr $hand mnf|mnf $chan]) && [onchan $nick $chan] && [$asciicodes > $maxascii]} {

I cound't get this script working.
The string length for the ascii code count $asciicodes retrieves output like 1 always or 2 sometimes thats it.

How can I make it to count all the ascii codes in the string and make it like a numerical value, like if there 100 lines in the text, 20 are normal text, 80 are ascii codes, i want it to count the 80 ascii codes in string length and assign it to a variable.

Then I can compare with my defined variable if they are excessive or not then I can kick/ban that person for doing so.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

The regexp returns the number of what you call "ascii codes", so there's no need for 'string length'. My comment about 'string length' was just a joke. Read my code one more time...all you need to do is add the kicking code and import that global variable i'm comparing $num to :)
Have you ever read "The Manual"?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Thanks sir, I will look into it.

Here is a link I foud for the conversion of ascii codes
from html format into into aplha. numerical, codes.
You can see this link, and view the second last table
on the page.

http://www.torsten-horn.de/techdocs/ascii.htm

Can I also use &iexcl, &yen, &copy, &aring, etc bla bla in the other two
tables (from 160-255) as well and include them into these variables, such as

"\[\x80\x83\x86\x8A\x8C\x9A\x9C\x9F\xA2\xA3\xA5\xA7\xA9\xAE\xB5\xB6\xC0-\xD6\xD8-\xF6\xF8-\xFF\iexcl\yen\reg\deg\acute\micro\]"

Would this code work as well? and would detect them?
Logically I think it should, if possible?
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Have you ever read "The Manual"?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Hi,

I found these listed problems from the eggdrop.tar.gz file
in the app-problems.html file. This might be the reason:
High-bit characters are being filtered from channel names. This is a fault of the Tcl interpreter, and not Eggdrop. The Tcl interpreter filters the characters when it reads a file for interpreting. Update your Tcl to version 8.1 or higher.

Version 8.1 of Tcl doesn't support unicode characters, for example, è. If those characters are handled in a script as text, you run into errors. Eggdrop can't handle these errors at the moment.
I guess so, lots of admins use the latest ver of tcl which is 8.1 and I guess so that maybe causing a problem as well.

So, I guess I'll leave the ascii codes script alone.
The one you gave me as well to work, says "0" invalid integer/number etc.
And doesn't work, if I use the exact same one you pasted.

This wasn't really worth it as well I guess.
Mostly people dont use ASCII, as they dont know the codes, only maybe in scripts.

Thanks anyways!
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

It works!

Post by awyeah »

I had been busy with other scripts, so I didn't had
time for this one, as I had given up hope, but I finally
thought that I will do this, and I will make it work!

Well, finally it did, and I tested it to see it was working perfect.

As they say, "Everything which has a problem, has a solution!"
But, sometimes the solution is very hard, harder than the problem itself.

I think I found the problem.
And that filtering thing was just a hoax.
Eggdrops doesn't filter ASCII Codes in TEXTS/ACTIONS or even NOTICES.

There was a problem with the slashes "\" and the brackets needed
to be used as I saw multiple search items when you need to use
with regexp like control codes you need to enlist them in { } brackets
rather than quotation marks.

Well anyway the script is absolutely fine, and working terrific now.
Here is the code for each and everyone of you who would want to
use it, feel free:

Code: Select all

#Settings

# In what file do you want the kick number records 
# to be stored? (Shows how many kicks have been done
# withs this script)
set kickno "kicknum.dat" 

#Set the channels to activate excessive ascii text kick on
set asciichans "#chatzone #funchat #giggles"

#On how much maximum ascii chars will the person be 
#kicked/banned on
set maxascii 30

#Set the bantime, for how long should the person be
#banned for (in mins)
set asciibantime 30


########## Don't edit anything below this ##########

bind pubm - * ascii:pubmsg

proc ascii:pubmsg {nick uhost hand chan text} {
  global botnick asciichans maxascii asciibantime
    set asciiban "*!*@[lindex [split $uhost @] 1]"
    set file [open $::kickno r]
    set tilnow "[gets $file]"
    catch {close $file}
    set totalkicks [expr $tilnow]
  if {(([lsearch -exact [string tolower $asciichans] [string tolower $chan]] != -1) || ($asciichans == "*"))} {
    set arg [ctrl:filter $text]
    set asciitext [regexp -all {[\x21\x23-\x26\x2A\x2B\x2D\x3F\x40\x5E\x7E\x80\x81\x83\x86-\x90\x95-\x9F\xA1-\xAC\xAE-\xB3\xB5-\xFF]} $arg]
   if {([botisop $chan]) && (![isop $nick $chan]) && (![isvoice $nick $chan]) && (![matchattr $hand mnof|mnof $chan]) && ([onchan $nick $chan]) && ($asciitext > $maxascii)} {
	putquick "MODE $chan +b $asciiban"
	putquick "KICK $chan $nick :0,1 Excessive ASCII Text Flood Kick 12,0 - You exceeded the limit of2 $maxascii ascii characters, 12by typing a 12text of2 *$asciitext* 12ascii characters. 12It would be 2appreciated 12if you would use normal characters, and 2not ASCII codes.2 - (Kick #$totalkicks)"
      timer $asciibantime "pushmode $chan -b $asciiban"
      return 0
      }
   } 
}

## Thanks to ppslim for this filter
proc ctrl:filter {str} {
  regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026} $str "" str
  return $str
}
(I have set the ascii code matching values for regexp, according to my needs, it should be the best matching ones I could find)

Note: If you would like to edit the matching ascii codes, yourself (i.e. personalize which codes you want to be listed as ascii in the dectector) if you know tcl, in the REGEXP command you can mention more codes or remove more codes.

http://www.torsten-horn.de/techdocs/ascii.htm

Here is the weblink, where you can find the ascii, html hex conversions (like x80 = €, A3 = £ etc.) for the ascii text codes, so you can edit them in the script according to your needs if you want to.

Or if you simply want only the full ASCII full range then
replace this line:

Code: Select all

    set asciitext [regexp -all {[\x21\x23-\x26\x2A\x2B\x2D\x3F\x40\x5E\x7E\x80\x81\x83\x86-\x90\x95-\x9F\xA1-\xAC\xAE-\xB3\xB5-\xFF]} $arg]
with this line:

Code: Select all

    set asciitext [regexp -all {[\x80-\xFF]} $arg]
That should do it.
Now you will have the full range.

Thanks everyone for your help!
Especially the mysterious "user".
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked