; ASCIIBane.mrc v1.1 (c) 2000 by Frank J. Perricone, hawthorn@sover.net ; ; Please feel free to distribute this script at will and use freely. ; Do not modify without my permission; do not claim credit for my work. ; ; This script filters out ASCII art. ; ; History: ; 1.0: initial release, 01-28-2000 ; 1.1: mIRC v5.7 adaptations, released 02-03-2000 ; ; Possible future upgrades: ; Remember if the review window was open and its size, and restore them on startup ; Add a menu to the review window allowing clearing, setting review length, etc. ; I wonder if the whole review buffer should just be the review window, sometimes hidden? ; Allow filtering of burc of items put into the review buffer ; Find a way to filter burc from quit and other lines while still using all to get the scores on 1:load: { ; initial setup during load, including establishment of parameters if ( $version < 5.6 ) { echo This script requires mIRC v5.6 or better. Please download the latest version at http://www.mirc.com/ and then reload it. unload -rs $script halt } if ( %asciibane_enabled == $null ) { ; if there isn't already a configuration set %asciibane_enabled on set %asciibane_warnings on set %asciibane_ignore 0 set %asciibane_color $colour(info) unset %asciibane_review* set %asciibane_reviewmaxcount 10 set %asciibane_reviewcount 0 set %asciibane_threshhold 10 set %asciibane_minlength 5 set %asciibane_wcontrol 15 set %asciibane_wspace 0 set %asciibane_wpunct 1 set %asciibane_wnumbers -1 set %asciibane_wcaps -1 set %asciibane_wlowercase -2 set %asciibane_whighascii 10 set %asciibane_wctrlstart 100 .saveini } echo %asciibane_color -ai5t * Welcome to ASCII Bane! ASCII art will be filtered from channels, according to the settings on the ASCII Bane menu (right-click a nick on the nick list to see it), and you can get Help there. If you have colors being stripped, please read Settings Help to see why you might want to turn them back on to make ASCII Bane work a lot better. } ; the actual filters, which rely on the alias functions below on ^*:TEXT:*:#: { asciibane_evaluate $nick $1- if ( $result > %asciibane_threshhold ) { asciibane_recordfilter $result $nick $1- halt } } on ^*:ACTION:*:#: { asciibane_evaluate $nick $1- if ( $result > %asciibane_threshhold ) { asciibane_recordfilter $result $nick $1- halt } } alias asciibane_evaluate { ; this function evaluates the string passed in and returns its score ; parameters: nick text-line ; it always returns -999 if filtering shouldn't be in effect (hope no one sets the threshhold below that) if ( %asciibane_enabled = off) return -999 if ( asciibane isin $level($1)) return -999 if ( asciibane isin $level($address($1,3))) return -999 if ( $len($2-) <= %asciibane_minlength ) return -999 var %asciibane_score set %asciibane_score 0 var %i 1 var %c 32 var %intext $2- var %len 1 set %len $len(%intext) if ( $asc($left(%intext,1)) = 3 ) inc %asciibane_score %asciibane_wctrlstart :while if (%i > %len ) goto endwhile set %c $asc($mid(%intext,%i,1)) if ( %c < 32 ) inc %asciibane_score %asciibane_wcontrol ; control codes elseif ( %c = 32 ) inc %asciibane_score %asciibane_wspace ; spaces elseif ( %c <= 47 ) inc %asciibane_score %asciibane_wpunct ; ! to / elseif ( %c <= 57 ) inc %asciibane_score %asciibane_wnumbers ; 0 to 9 elseif ( %c <= 64 ) inc %asciibane_score %asciibane_wpunct ; : to @ elseif ( %c <= 90 ) inc %asciibane_score %asciibane_wcaps ; A to Z elseif ( %c <= 96 ) inc %asciibane_score %asciibane_wpunct ; [ to ` elseif ( %c <= 122 ) inc %asciibane_score %asciibane_wlowercase ; a to z elseif ( %c <= 126 ) inc %asciibane_score %asciibane_wpunct ; left-curly-bracket to ~ else inc %asciibane_score %asciibane_whighascii ; everything else inc %i goto while :endwhile return %asciibane_score } alias asciibane_recordfilter { ; this alias records a filtered line on screen and in review buffer as needed ; parameters are score nick text-line ; display the filter if necessary if ( %asciibane_warnings = on ) echo -tbf $chan < $+ $2 $+ > 14[deleted: ASCII art score: $1 $+ ] ; ignore the user if necessary if ( %asciibane_ignore != 0 ) .ignore -cu $+ %asciibane_ignore $2 ; maintain the review buffer if necessary if ( %asciibane_reviewmaxcount > 0 ) { var %i var %j var %k var %l set %i %asciibane_reviewcount inc %i if ( %i > %asciibane_reviewmaxcount ) set %i %asciibane_reviewmaxcount set %asciibane_reviewcount %i :loop if ( %i <= 1 ) goto done set %j % $+ asciibane_review $+ %i set %k %i dec %k set %l % $+ asciibane_review $+ %k set [ [ %j ] ] [ [ %l ] ] dec %i goto loop :done set %asciibane_review1    14[score: $1 $+ ] < $+ $2 $+ > $3- .saveini } if ( $window(@review).state != $null ) { ; if the window is open, add to it echo -l @review    14[score: $1 $+ ] < $+ $2 $+ > $3- } } ctcp *:VERSION:.ctcpreply $nick VERSION ASCII Bane v1.1 (c) 2000 by Frank J. Perricone (hawthorn) menu nicklist,query { ASCII Bane .Permissions ..Grant By Nick: auser -a asciibane $$1 ..Grant By Address: guser -a asciibane $$1 3 ..- ..Remove By Nick:/ruser asciibane $$1 ..Remove By Address:/ruser asciibane $$1 3 ..- ..List:/ulist asciibane .Review ASCII Art: { if ( %asciibane_reviewcount = 0 ) echo %asciibane_color -ai5t * ASCII Bane: No ASCII art has been killed. else { echo %asciibane_color -ai5t * ASCII Bane: Note that spaces have been compressed so this might look even worse than it did originally. echo %asciibane_color -ai5t * ASCII Bane: Last %asciibane_reviewcount lines of ASCII art killed were: var %i var %j set %i %asciibane_reviewcount :loop if ( %i == 0 ) goto done set %j % $+ asciibane_review $+ %i echo -ai5tlbf [ [ %j ] ] dec %i goto loop :done } } .Open Review Window: { if ( %asciibane_reviewcount = 0 ) echo %asciibane_color -ai5t * ASCII Bane: No ASCII art has been killed. else { window +benstx @review 0 0 600 400 echo %asciibane_color -l @review * ASCII Bane: Note that spaces have been compressed so this might look even worse than it did originally. echo %asciibane_color -l @review * ASCII Bane: Last %asciibane_reviewcount lines of ASCII art killed were: var %i var %j set %i %asciibane_reviewcount :loop if ( %i == 0 ) goto done set %j % $+ asciibane_review $+ %i echo -l @review [ [ %j ] ] dec %i goto loop :done } } .- .Enable/Disable: { if ( $?!="Enable ASCII Bane?" = $true ) { set %asciibane_enabled on echo %asciibane_color -ai5t * ASCII Bane: Enabled. } else { set %asciibane_enabled off echo %asciibane_color -ai5t * ASCII Bane: Disabled. } .saveini } .Unload:{ if ( $?!="Unload ASCII Bane?" = $true ) { echo %asciibane_color -ai5t * ASCII Bane: Unloading. Type /load -rs asciibane.mrc to reload. if ( $?!="Unload settings and user list too?" = $true ) { unset %asciibane_* rlevel asciibane } unload -rs $script } } .- .General Settings ..Display Kills: { if ( $?!="Tell you when ASCII art is killed?" = $true ) { set %asciibane_warnings on echo %asciibane_color -ai5t * ASCII Bane: Display Kills on. } else { set %asciibane_warnings off echo %asciibane_color -ai5t * ASCII Bane: Display Kills off. } .saveini } ..Ignore Poster: { var %new_ignore set %new_ignore $?="Seconds to ignore ASCII Art posters (0 for none):" if ( %new_ignore = $null ) halt if ( %new_ignore < 0 || %new_ignore > 86400 ) { echo %asciibane_color -ai5t * ASCII Bane: Invalid ignore time %new_ignore ignored. halt } set %asciibane_ignore %new_ignore if ( %asciibane_ignore = 0 ) { echo %asciibane_color -ai5t * ASCII Bane: Ignore Poster off. } else { echo %asciibane_color -ai5t * ASCII Bane: Ignore posters for %asciibane_ignore seconds. } .saveini } ..Text Color: { asciibane_asknumeric 0 15 $colour(info) %asciibane_color Color for ASCII Bane messages if ( $result = $null ) halt set %asciibane_color $result .saveini } ..Review Buffer Length: { asciibane_asknumeric 0 50 10 %asciibane_reviewmaxcount Number of lines of review buffer if ( $result = $null ) halt set %asciibane_reviewmaxcount $result if ( %asciibane_reviewcount > %asciibane_reviewmaxcount ) { ; remove any excess review buffer entries var %i var %j set %i %asciibane_reviewcount :loop if ( %i <= %asciibane_reviewmaxcount ) goto done set %j % $+ asciibane_review $+ %i set -u0 [ [ %j ] ] dec %i goto loop :done set %asciibane_reviewcount %asciibane_reviewmaxcount } .saveini } ..- ..Set All To Defaults: { if ( $?!="Reset all general settings to defaults?" = $true ) { set %asciibane_warnings on set %asciibane_ignore 0 set %asciibane_color $colour(info) set %asciibane_reviewmaxcount 10 if ( %asciibane_reviewcount > %asciibane_reviewmaxcount ) { ; remove any excess review buffer entries var %i var %j set %i %asciibane_reviewcount :loop if ( %i <= %asciibane_reviewmaxcount ) goto done set %j % $+ asciibane_review $+ %i set -u0 [ [ %j ] ] dec %i goto loop :done set %asciibane_reviewcount %asciibane_reviewmaxcount } echo %asciibane_color -ai5t * ASCII Bane: all general settings restored to defaults. .saveini } } .Weight Settings ..Threshhold: { asciibane_asknumeric -1000 1000 10 %asciibane_threshhold Threshhold for filtering if ( $result = $null ) halt set %asciibane_threshhold $result .saveini } ..Minimum Line Length: { asciibane_asknumeric 0 1000 5 %asciibane_minlength Shortest line to attempt filtering if ( $result = $null ) halt set %asciibane_minlength $result .saveini } ..- ..Control Characters: { asciibane_asknumeric -200 200 15 %asciibane_wcontrol Control character weight if ( $result = $null ) halt set %asciibane_wcontrol $result .saveini } ..Color Starting Line Bonus: { asciibane_asknumeric -200 200 100 %asciibane_wctrlstart Bonus when the line starts with a color if ( $result = $null ) halt set %asciibane_wctrlstart $result .saveini } ..- ..Normal Punctuation: { asciibane_asknumeric -200 200 1 %asciibane_wpunct Normal punctuation weight if ( $result = $null ) halt set %asciibane_wpunct $result .saveini } ..Spaces: { asciibane_asknumeric -200 200 0 %asciibane_wspace Spaces weight if ( $result = $null ) halt set %asciibane_wspace $result .saveini } ..High ASCII Punctuation: { asciibane_asknumeric -200 200 10 %asciibane_whighascii High ASCII punctuation weight if ( $result = $null ) halt set %asciibane_whighascii $result .saveini } ..- ..Lowercase Letters: { asciibane_asknumeric -200 200 -2 %asciibane_wlowercase Lowercase letters weight if ( $result = $null ) halt set %asciibane_wlowercase $result .saveini } ..Uppercase Letters: { asciibane_asknumeric -200 200 -1 %asciibane_wcaps Uppercase letters weight if ( $result = $null ) halt set %asciibane_wcaps $result .saveini } ..Numbers: { asciibane_asknumeric -200 200 -1 %asciibane_wnumbers Numbers weight if ( $result = $null ) halt set %asciibane_wnumbers $result .saveini } ..- ..Set All To Defaults: { if ( $?!="Reset all weight settings to defaults?" = $true ) { set %asciibane_threshhold 10 set %asciibane_minlength 5 set %asciibane_wcontrol 15 set %asciibane_wspace 0 set %asciibane_wpunct 1 set %asciibane_wnumbers -1 set %asciibane_wcaps -1 set %asciibane_wlowercase -2 set %asciibane_whighascii 10 set %asciibane_wctrlstart 100 echo %asciibane_color -ai5t * ASCII Bane: all weight settings restored to defaults. } .saveini } .Show Settings: { echo %asciibane_color -ai5t * ASCII Bane: Settings are: echo %asciibane_color -ai5t     Enabled: %asciibane_enabled echo %asciibane_color -ai5t     Display Kills: %asciibane_warnings if ( %asciibane_ignore = 0 ) { echo %asciibane_color -ai5t     Ignore Poster: off } else { echo %asciibane_color -ai5t     Ignore Poster: %asciibane_ignore seconds } echo %asciibane_color -ai5t     Color: %asciibane_color echo %asciibane_color -ai5t     Review Buffer: %asciibane_reviewmaxcount lines (currently %asciibane_reviewcount lines used) echo %asciibane_color -ai5t     Threshhold: %asciibane_threshhold $+ , minimum line length: %asciibane_minlength echo %asciibane_color -ai5t     Weights: echo %asciibane_color -ai5t         Control Characters: %asciibane_wcontrol (color starting line bonus: %asciibane_wctrlstart $+ ) echo %asciibane_color -ai5t         Punctuation: normal %asciibane_wpunct $+ , space %asciibane_wspace $+ , high ASCII %asciibane_whighascii echo %asciibane_color -ai5t         Text: lowercase %asciibane_wlowercase $+ , uppercase %asciibane_wcaps $+ , numbers %asciibane_wnumbers } .Settings Help: { window +benstx @asciibane_help 0 0 600 400 echo %asciibane_color @asciibane_help The Settings section of the menu controls all parts of ASCII Bane's behavior. In addition to Show Settings (which displays your settings) and Settings Help (you're looking at), it divides all the settings into two groups. echo %asciibane_color @asciibane_help   echo %asciibane_color @asciibane_help General Settings items control how ASCII Bane works: echo %asciibane_color -i5 @asciibane_help   Display Kills: When turned on, ASCII Bane shows a message on your active window when ASCII art has been filtered. Note that often ASCII art consists of many lines, so you'll see strings of these warnings. echo %asciibane_color -i5 @asciibane_help   Ignore Poster: Sets ASCII Bane to automatically do a temporary ignore on anyone who sends ASCII art. Type a number of seconds, or 0 for no ignore. With Display Kills turned on, this prevents the long line of warnings. echo %asciibane_color -i5 @asciibane_help   Text Color: Allows you to change the color of ASCII Bane's informative messages. echo %asciibane_color -i5 @asciibane_help   Review Buffer Length: Controls how many lines of review buffer ASCII Bane uses to record filtered lines. Enter 0 to have no review buffer saved. echo %asciibane_color -i5 @asciibane_help   Set All To Default: Restore all general settings to defaults. echo %asciibane_color @asciibane_help   echo %asciibane_color @asciibane_help Weight Settings items control how ASCII Bane determines which lines are ASCII art: echo %asciibane_color -i5 @asciibane_help   Threshhold: The minimum score a line must earn before being filtered. Increasing this will let more lines through and eliminate false filterings; decreasing it will filter more lines including more lines that aren't really ASCII art. echo %asciibane_color -i5 @asciibane_help   Minimum Line Length: Lines shorter than this won't be filtered no matter what. This prevents a short line with just punctuation (for instance, :) alone on a line) from being filtered. echo %asciibane_color -i5 @asciibane_help   Weights: For each character in the line, the appropriate weight is added into the score. Control characters include formatting like colors and bold, and should be high enough to cancel the numbers and/or commas that often follow them. There's a bonus if the first character on the line is a color code, as these are almost always ASCII art). Don't mess with these unless you're sure what you're doing. echo %asciibane_color -i5 @asciibane_help   Set All To Default: Restore all weight settings to defaults. echo %asciibane_color @asciibane_help   echo %asciibane_color @asciibane_help Important note: ASCII Bane actually works better if you're not stripping color and formatting codes, as it can use them to help recognize ASCII art. } .- .Help: { window +benstx @asciibane_help 0 0 600 400 echo %asciibane_color @asciibane_help ASCII Bane automatically kills ASCII art in channels. It detects ASCII art by comparing the number of numbers and letters to the number of punctuation symbols, high ASCII, and formatting codes. Letters and numbers lower the score, while punctuation and formatting raise the score (by a certain "weight" assigned to each category), and if the result is above a threshhold, the line is considered ASCII art. echo %asciibane_color @asciibane_help   echo %asciibane_color @asciibane_help The default weights and threshhold are very effective at catching ASCII art without catching anything else, but some lines can fool it either way, especially on very short lines (a minimum filter length allows it to not try to filter very short ones) or lines with lots of punctuation (for instance, a greeting like this: "hawthorn!!!!!!!!!!!!!!!!!!!!!!!!!!!"). echo %asciibane_color @asciibane_help   echo %asciibane_color @asciibane_help All functions are controlled by the ASCII Bane menu, found when you right-click a nick on a nick list: echo %asciibane_color @asciibane_help   echo %asciibane_color -i5 @asciibane_help   Permissions: If you'd like to see ASCII art from only some people, use this menu to Grant permission for them to post it without being filtered. You can Remove permission if you change your mind, or List permissions you've granted. You can also use this on people who post lots of exuberant punctuation but don't post ASCII art. echo %asciibane_color -i5 @asciibane_help   Review ASCII Art: Shows filtered ASCII art in case something got filtered incorrectly, or you're just curious. But note that mIRC collapses spaces, and the spacing of some ASCII art is crucial, so it'll likely look even worse. Actions will show the same as text when filtered. echo %asciibane_color -i5 @asciibane_help   Enable/Disable: Turns ASCII Bane's filtering on and off. echo %asciibane_color -i5 @asciibane_help   Unload: Allows you to unload ASCII Bane from your system completely. (The file will still be on your hard drive so you can reload it.) echo %asciibane_color -i5 @asciibane_help   Settings: See the Settings Help for important info about making ASCII Bane work most effectively. echo %asciibane_color -i5 @asciibane_help   Help: You're soaking in it! echo %asciibane_color -i5 @asciibane_help   About: Shows the version, contact information, copyright, and redistribution permissions. echo %asciibane_color @asciibane_help   echo %asciibane_color @asciibane_help This is freeware -- distribute widely, but leave credit for the author: hawthorn@sover.net, 12http://www.sover.net/~hawthorn/, and on IRC, hawthorn on DalNet. } .About: { echo %asciibane_color -ai5 * ASCII Bane v1.1 ( $+ $script $+ ) is (c) 2000 by Frank J. Perricone, hawthorn@sover.net, hawthorn on DalNet, 12http://www.sover.net/~hawthorn/. Please feel free to distribute this script at will and use freely. Do not modify without my permission; do not claim credit for my work. } } menu channel { ASCII Bane .Review ASCII Art: { if ( %asciibane_reviewcount = 0 ) echo %asciibane_color -ai5t * ASCII Bane: No ASCII art has been killed. else { echo %asciibane_color -ai5t * ASCII Bane: Note that spaces have been compressed so this might look even worse than it did originally. echo %asciibane_color -ai5t * ASCII Bane: Last %asciibane_reviewcount lines of ASCII art killed were: var %i var %j set %i %asciibane_reviewcount :loop if ( %i == 0 ) goto done set %j % $+ asciibane_review $+ %i echo -ai5tlbf [ [ %j ] ] dec %i goto loop :done } } .Quick Review: { if ( %asciibane_reviewcount = 0 ) echo %asciibane_color -ai5t * ASCII Bane: No ASCII art has been killed. else echo -ai5tlbf %asciibane_review1 } .Open Review Window: { if ( %asciibane_reviewcount = 0 ) echo %asciibane_color -ai5t * ASCII Bane: No ASCII art has been killed. else { window +benstx @review 0 0 600 400 echo %asciibane_color -l @review * ASCII Bane: Note that spaces have been compressed so this might look even worse than it did originally. echo %asciibane_color -l @review * ASCII Bane: Last %asciibane_reviewcount lines of ASCII art killed were: var %i var %j set %i %asciibane_reviewcount :loop if ( %i == 0 ) goto done set %j % $+ asciibane_review $+ %i echo -l @review [ [ %j ] ] dec %i goto loop :done } } } alias asciibane_asknumeric { ; a generic dialog to ask for a numeric value ; parameters are lowlimit highlimit defaultvalue currentvalue description var %new_value set %new_value $?=" $+ $5- ( $+ $1 to $2 $+ , default $3 $+ , current $4 $+ )?" if ( %new_value = $null ) return $null if ( %new_value < $1 || %new_value > $2 ) { echo %asciibane_color -ai5t * ASCII Bane: Invalid value %new_value ignored. return $null } echo %asciibane_color -ai5t * ASCII Bane: $5- set to %new_value $+ . return %new_value }