;== Blacklist v0.14 ==
; Author: mightymouse2 (on DALnet)
; Website: http://geocities.com/mm_scripts
; Contact: mightymouse@australiamail.com
on *:LOAD: {
if ($version < 5.9) { echo $color(info) -a * This script was designed for mIRC 5.9+. You are using mIRC version $version . The script will not function correctly with this version. Please upgrade your mIRC at: http://www.mirc.co.uk/ | unload -rs $script }
echo $color(info) -a *** Loaded: mm Blacklist v0.14 - written by mightymouse2 (on DALnet)
echo $color(info) -a * This script has loaded new menu options in the Menubar which is located at the top of the screen between the words DCC and Window (it should be called 'Commands', but some other scripts rename this to something else). They are in Commands/mm Blacklist. There are also new entries in the Nicklist to Add and Remove users from your blacklist. Enjoy!
if ($exists($scriptdir $+ blistv.ini) == $true) { echo $color(info) -a * Variable file 'blistv.ini' was found. The variables contained in this file will be used, however if you wish to use the defaults, please select the menu option 'Reset Defaults'. }
else { default_vars }
}
menu menubar,channel {
Blacklist
.Settings: {
if ($dialog(blist)) dialog -rv blist blist
else dialog -m blist blist
}
.Help: { run $scriptdir $+ help.txt }
.Reset Defaults: {
if ( $input(Are you sure you wish to reset all script options to default?,8) == $true ) { remvar | default_vars }
}
.Uninstall: {
if ( $input(Are you sure you wish to uninstall this script?,8) == $true ) {
if ( $input(The files used by this script were ' $+ $script $+ ' and 'blistv.ini'. Would you also like to remove these files?,8) == $true ) {
if ( $exists($scriptdir $+ blistv.ini) == $true ) { remove $scriptdir $+ blistv.ini }
else echo $color(info) -a * Error: Variable file 'blistv.ini' not found. You must have deleted or renamed this file.
remove $script
}
echo $color(info) -a * Script Uninstalled.
.unload -rs $script
}
}
}
menu nicklist,query {
mm Blacklist
.Add (default reason): { blacklist.add $$1 $readvar(options_msg) | nicklist.kb # $$1 $readvar(options_msg) }
.Add (specify reason): {
var %s $input(Enter Reason or Info for blacklisting.,1)
blacklist.add $$1 %s | nicklist.kb # $$1 %s
}
.Del:blacklist.del $$1
}
; Variables
alias -l readvar {
var %x $readini $scriptdir $+ blistv.ini vars $1-
return %x
}
alias -l writevar {
if ($2) writeini $scriptdir blistv.ini vars $1 $2-
}
alias -l remvar {
remini $scriptdir blistv.ini vars $1
}
alias -l default_vars {
writevar options_onjoin on | writevar options_ignore on | .enable #blacklist
writevar extra_remignore on | writevar options_banmasks 2 3 9
}
; Display what the script is doing in a custom window
alias -l dc {
if ($readvar(extra_displayscript) == on) && ($1) {
window -n @mm_BlackList | aline -p @mm_BlackList $timestamp * $1-
}
}
; Adding users to blacklist (and ignore list if specified)
; Parameters: /blacklist.add <nick|address> [reason]
alias blacklist.add {
if ($1 == $null) { echo $color(info) -a * Invalid Parameters, Use: /blacklist.add <nick|address> [reason] | return }
if ($1 == *!*@*) { echo $color(info) -a * The mask *!*@* represents every user. This will not be added as it would be hazardous. | return }
/dc 4Call to blacklist.add made ( blacklist.add $1 $2- $+ ).
/dc Testing to see if $1 is an address.
if ( *!*@* iswm $1 ) {
/dc $1 seems to be an address. Adding $1 to blacklist user group.
.auser blacklisted $1 $2-
echo $color(info) -a * Added $1 to blacklist.
if ($readvar(options_ignore) == on) {
/dc Adding $1 to ignore list.
echo $color(info) -a * Added $1 to ignore list.
.ignore $readvar(options_ignoreswitches) $1
}
}
else {
if ($readvar(options_banmasks) == $null) { echo $color(info) -a * Error: No banmasks have been selected! Go to options and select one! | return }
if ($server == $null) { echo $color(info) -a * Error: You're not connected to a server! I can't find $1 $+ 's address through telepathy! | return }
/dc $1 seems to be a nick. Attempting to add $1 to blacklist using the masks specified in options.
var %i 1
while ($gettok($readvar(options_banmasks),%i,32)) {
.guser blacklisted $1 $gettok($readvar(options_banmasks),%i,32) $2-
if ($readvar(options_ignore) == on) {
if ($address($1,-1)) {
.ignore $readvar(options_ignoreswitches) $address($1,$gettok($readvar(options_banmasks),%i,32))
}
else { /dc $1 is not in the IAL. Not added to ignore list. }
}
inc %i
}
}
if ($dialog(blist)) { dialog.update }
}
; Remove users from blacklist (and ignore list if match)
;Params: /blacklist.del <nick|address>
; Removes all matching addresses for nick or address
alias blacklist.del {
if ($1 == $null) { echo $color(info) -a * Invalid Parameters. Use: /blacklist.del <nick|address> | return }
/dc 4Call to blacklist.del made ( $+ blacklist.del $1 $+ ).
if (*!*@* iswm $1) {
/dc Removing all matching addresses from blacklist for $1 $+ .
var %i 1
while ($ulist($1,blacklisted,%i)) {
if ($1 iswm $ulist($1,blacklisted,%i)) {
if ($readvar(extra_remignore) == on) && ($ignore($ulist($1,blacklisted,%i))) {
/dc Removing $ulist($1,blacklisted,%i) from ignore list.
.ignore -r $ignore($ulist($1,blacklisted,%i))
}
/dc Removing $ulist($1,blacklisted,%i) from blacklist.
.ruser blacklisted $ulist($1,blacklisted,%i)
var %i 0
}
inc %i
}
}
else {
if ($server == $null) { echo $color(info) -a * Error: You're not connected to a server! I can't find $1 $+ 's address through telepathy! | return }
/dc Attempting to remove $1 from blacklist using all possible masks.
var %i -1
while (%i <= 9) {
.ruser blacklisted $1 %i
if ($readvar(extra_remignore) == on) { .ignore -r $1 %i }
inc %i
}
}
if ($dialog(blist)) { dialog.update }
}
; Clear all users from blacklist (and ignore list if match)
;Params: /blacklist.clear
alias -l blacklist.clear {
if ($input(Are you sure you wish to remove ALL users from blacklist?,8,Warning) == $true) {
/dc 4blacklist.clear called, clearing all users on blacklist...
if ($readvar(extra_remignore) == on) {
/dc Clearing blacklisted users from ignore list..
var %i 1
while ($ulist(*,blacklisted,%i)) {
.ignore -r $ulist(*,blacklisted,%i)
inc %i
}
}
.rlevel blacklisted
}
if ($dialog(blist)) { dialog.update }
}
#blacklist on
;Deop/Ban/Kick of blacklisted user
;Params: /blacklist.kb <channel> <nick> <matching blacklist address>
alias -l blacklist.kb {
;If banonly == on and the channel is not in the list, or you're not an op on channel, return
if ($readvar(options_banonly) == on) && ($istok($readvar(options_banonlylist),$1,32) != $true) || ($me !isop $1) { return }
/dc 4Call to blacklist.kb made, asking server to deop/ban/kick user from $1 $+ .
if ($readvar(extra_kick) == on) {
if ($readvar(extra_kick_opt) == 1) { raw -q mode $1 -o+b $2 $3 $+ $cr $+ kick $1 $2 : $+ $ulist($3,blacklisted,1).info (Blacklisted) (Kicks: $readvar(kscount)) }
else { raw -q mode $1 -o+b $2 $3 $+ $cr $+ kick $1 $2 : $+ $ulist($3,blacklisted,1).info (Blacklisted) (Kicks: $readvar(kcount)) }
}
else { raw -q mode $1 -o+b $2 $3 $+ $cr $+ kick $1 $2 : $+ $ulist($3,blacklisted,1).info (Blacklisted) }
;** Increase script kick counter
writevar kscount $calc($readvar(kscount) + 1)
}
;Same as above but deop/kban even if user not on blacklist
;This is to put in nicklist popups basically
;Params: /nicklist.kb <channel> <nick> [reason]
alias nicklist.kb {
if ($1 == $null) || ($2 == $null) { echo $color(info) -a * Invalid Parameters, Use: /nicklist.kb <channel> <nick> [reason] }
if ($me !isop $1) { return }
/dc 4Call to nicklist.kb made, asking server to deop/ban/kick $2 from $1 $+ .
if ($readvar(extra_kick) == on) {
if ($readvar(extra_kick_opt) == 1) {
mode $1 -o $2
ban $1 $2 $gettok($readvar(options_banmasks),1,32)
kick $1 $2 $3- (Blacklisted) (Kicks: $readvar(kscount))
}
else {
mode $1 -o $2
ban $1 $2 $gettok($readvar(options_banmasks),1,32)
kick $1 $2 $3- (Blacklisted) (Kicks: $readvar(kcount))
}
}
else {
mode $1 -o $2
ban $1 $2 $gettok($readvar(options_banmasks),1,32)
kick $1 $2 $3- (Blacklisted)
}
;** Increase script kick counter
writevar kscount $calc($readvar(kscount) + 1)
}
;** When a blacklisted user joins:
on blacklisted:JOIN:#: {
/dc 4A blacklisted user (Nick: $nick Matches Address: $maddress $+ ) has joined $chan $+ .
if ($nick == $me) { /dc You are on your own blacklist... baka.. | return }
if ($me !isop $chan) {
if ($readvar(extra_echo) == on) { echo $color(info) -a * mm BlackList: A blacklisted user has joined $chan (Nick: $nick Matching Blacklist Address: $maddress $+ ). }
/dc You're not an op. Nothing will be done... | return
}
blacklist.kb $chan $nick $maddress
}
;** when you get opped in a channel, do a scan for blacklisted users.
on *:OP:#: {
if ($opnick != $me) return
if ($readvar(options_onop) != on) return
/dc 4Opped on $chan $+, updating IAL...
set %temp_who $addtok(%temp_who,$chan,32)
who $chan
}
; When doing a blacklist.scan, the ial must be updated/filled by doing a /who #channel
; Otherwise it won't scan everyone in a channel (only the ones in the ial)
; These raw events stop the status window filling up with server replies while updating the ial
; And only calls the scan after the ial for channel/s has been completely updated
;352 RPL_WHOREPLY
raw 352:*: {
if ($istok(%temp_who,$2,32)) haltdef
}
;315 RPL_ENDOFWHO
raw 315:*: {
if ($istok(%temp_who,$2,32)) {
/dc IAL update on $2 complete.
blacklist.scan $2
if ($remtok(%temp_who,$2,1,32)) { set %temp_who $remtok(%temp_who,$2,1,32) }
else { unset %temp_who }
haltdef
}
}
; Scans channel for users in blacklist, bans any it comes across
; Note: ial should be updated before blacklist.scan called.
; Params /blacklist.scan <channel>
alias -l blacklist.scan {
/dc 4blacklist.scan called... scanning for users in blacklist on $1 $+ .
var %i 1
while ($nick($1,%i)) {
var %s = $ifmatch
if ($ulist($address(%s,-1),blacklisted,1)) {
var %maddress = $ifmatch
/dc %s $+ 's address ( $+ $address(%s,-1) $+ ) matches %maddress which is on the blacklist.
blacklist.kb $1 %s %maddress
}
inc %i
}
/dc Scan complete.
}
#blacklist end
; Increase kick counter
on *:KICK:#: {
if ($nick == $me) { writevar kcount $calc($readvar(kcount + 1)) }
}
on *:EXIT: {
unset %temp_who
}
alias -l dialog.update {
/dc Updating blacklist dialog.
if ($did(blist,9).lines) did -r blist 9
var %i 1
while ($ulist(*,blacklisted,%i)) {
did -a blist 9 $ulist(*,blacklisted,%i) $ulist(*,blacklisted,%i).info
inc %i
}
if ($did(blist,9).lines == 0) {
did -b blist 10,11,14,15
}
elseif ($did(blist,10).enabled == $false) {
did -e blist 10,11,14,15
}
}
dialog blist {
title "mm Blacklist Settings"
size -1 -1 195 188
option dbu
radio "Enable" 2, 5 0 35 10, Group
radio "Disable" 3, 40 0 35 10,
button "OK" 4, 45 175 25 10, Ok
button "Cancel" 5, 80 175 25 10, Cancel
button "Apply" 6, 115 175 25 10,
link "mm BlackList 0.14" 7, 145 0 90 20,
tab "Control" 8, 0 15 195 155
combo 9, 5 45 185 110, tab 8
button "Del Selected" 10, 80 155 35 10, tab 8
button "Clear All" 11, 150 155 35 10, tab 8
text "Blacklist" 12, 5 35 95 10, tab 8
button "Add" 13, 10 155 35 10, tab 8
button "Edit Info" 14, 45 155 35 10, tab 8
button "Del Wildcard" 15, 115 155 35 10, tab 8
tab "Options" 17,
check "Also add to ignore list" 18, 105 65 75 10, tab 17
check "private" 19, 110 75 35 10, tab 17
check "channel" 20, 145 75 35 10, tab 17
check "notice" 21, 110 85 35 10, tab 17
check "ctcp" 22, 145 85 35 10, tab 17
check "invite" 23, 110 95 35 10, tab 17
check "all" 24, 145 95 35 10, tab 17
text "Add to blacklist/ignore list using these masks:" 25, 5 35 80 15, tab 17
check "*!*@host.domain" 26, 10 50 70 10, tab 17
check "*!*user@*.domain" 27, 10 60 70 10, tab 17
check "*!*@*.domain" 28, 10 70 70 10, tab 17
check "nick!*@*.domain" 29, 10 80 70 10, tab 17
combo 30, 10 110 80 40, tab 17
check "" 31, 5 95 10 15, tab 17
button "Add" 32, 20 155 20 10, tab 17
button "Del" 33, 40 155 20 10, tab 17
button "Clr" 34, 60 155 20 10, tab 17
check "" 35, 105 115 10 25, tab 17
text "When you gain ops, perform a scan for users on your blacklist, if any are in the channel, ban them." 36, 115 115 70 25, tab 17
text "Ban users in your blacklist only on these channels:" 38, 15 95 75 15, tab 17
text "Default blacklist message:" 39, 105 35 75 10, tab 17
edit "" 40, 110 45 75 10, AutoHs tab 17
tab "Extra" 41,
check "Display details of what this script is doing in a custom window." 42, 5 35 160 10, tab 41
check "Display kick counter at the end of each kick message." 43, 5 50 160 10, tab 41
radio "Number of kicks performed by this script." 44, 15 60 115 10, group, tab 41
radio "Total number of kicks performed." 45, 15 70 115 10, tab 41
check "" 46, 5 85 10 15, tab 41
text "Echo to active window when a blacklisted user joins a channel which you do not have ops on." 47, 15 85 170 15, tab 41
check "When removing users from blacklist, also remove from ignore list." 48, 5 105 170 10, tab 41
}
; The dialog code was created using Ymar The Leprechaun's Dialog Creator (ldc), downloaded from mircscripts.org.
;save editboxes
;Params saveedit <var> <id>
alias -l saveedit {
if ($did(blist,$2)) writevar $1 $did(blist,$2)
else remvar $1
}
;save checkboxes/radios
;Params savecr <var> <id>
alias -l savecr {
if ($did(blist,$2).state == 1) writevar $1 on
else remvar $1
}
alias -l loadcr { if ($readvar($1) == on) did -c blist $2 }
alias -l loadedit { did -a blist $2 $readvar($1) }
;-- Dialog Initialisation --
on *:dialog:blist:init:0: {
if ($group(#blacklist) == on) { did -c blist 2 }
else did -c blist 3
if ( $istok($readvar(options_banmasks),2,32) == $true ) { did -c blist 26 }
if ( $istok($readvar(options_banmasks),3,32) == $true ) { did -c blist 27 }
if ( $istok($readvar(options_banmasks),4,32) == $true ) { did -c blist 28 }
if ( $istok($readvar(options_banmasks),9,32) == $true ) { did -c blist 29 }
if ($readvar(options_banonlylist)) { didtok blist 30 32 $readvar(options_banonlylist) }
loadedit options_msg 40 | loadcr options_ignore 18 | loadcr options_banonly 31
if ( $readvar(options_ignoreswitches) == $null ) { did -c blist 24 }
else {
if ( p isin $readvar(options_ignoreswitches) ) { did -c blist 19 }
if ( c isin $readvar(options_ignoreswitches) ) { did -c blist 20 }
if ( n isin $readvar(options_ignoreswitches) ) { did -c blist 21 }
if ( t isin $readvar(options_ignoreswitches) ) { did -c blist 22 }
if ( i isin $readvar(options_ignoreswitches) ) { did -c blist 23 }
}
loadcr options_onop 35 | loadcr extra_displayscript 42 | loadcr extra_kick 43
if ($readvar(extra_kick_opt) == 1) { did -c blist 44 }
else did -c blist 45 | loadcr extra_echo 46 | loadcr extra_remignore 48 | dialog.update
}
;-- Save options --
alias -l save_vars {
if ($did(blist,2).state == 1) { .enable #blacklist }
else .disable #blacklist
remvar options_banmasks
if ( $did(blist,26).state == 1 ) { writevar options_banmasks $addtok($readvar(options_banmasks),2,32) }
if ( $did(blist,27).state == 1 ) { writevar options_banmasks $addtok($readvar(options_banmasks),3,32) }
if ( $did(blist,28).state == 1 ) { writevar options_banmasks $addtok($readvar(options_banmasks),4,32) }
if ( $did(blist,29).state == 1 ) { writevar options_banmasks $addtok($readvar(options_banmasks),9,32) }
if ( $did(blist,31).state == 1 ) { writevar options_banonly on }
if ($didtok(blist,30,32)) { writevar options_banonlylist $didtok(blist,30,32) }
saveedit options_msg 40 | savecr options_ignore 18 | savecr options_banonly 31
var %s -
if ( $did(blist,19).state == 1) { %s = %s $+ p }
if ( $did(blist,20).state == 1) { %s = %s $+ c }
if ( $did(blist,21).state == 1) { %s = %s $+ n }
if ( $did(blist,22).state == 1) { %s = %s $+ t }
if ( $did(blist,23).state == 1) { %s = %s $+ i }
if ( $did(blist,24).state == 1) { %s = $null }
if (%s) writevar options_ignoreswitches %s
if ( $did(blist,44).state == 1 ) { writevar extra_kick_opt 1 }
else remvar extra_kick_opt
savecr options_onop 35 | savecr extra_displayscript 42 | savecr extra_kick 43
savecr extra_echo 46 | savecr extra_remignore 48
}
;--- Link ---
on *:dialog:blist:sclick:7: {
url -n http://geocities.com/mm_scripts/
}
;-- OK Button --
on *:dialog:blist:sclick:4:save_vars
;-- Apply Button --
on *:dialog:blist:sclick:5:save_vars
;-- Blacklist Add Button --
on *:dialog:blist:sclick:13: {
var %s $input(Add address (eg. *!*@*.aol.com) or nick. Nick must exist on IRC.,1,Add to blacklist)
if (%s) {
blacklist.add %s
did -d blist 9 0
dialog.update
}
}
;-- Edit Info --
on *:dialog:blist:sclick:14: {
if ($did(blist,9).seltext) {
var %i 2
while ($gettok($did(blist,9).seltext,%i,32)) {
var %info = %info $gettok($did(blist,9).seltext,%i,32)
inc %i
}
if (%info == $null) { var %info = - }
var %s $input(Edit Info,1,Edit Info (space for nothing), $+ %info $+ )
if (%s) { .iuser $gettok($did(blist,9).seltext,1,32) %s | /dc 4Info of blacklisted entry edited. | dialog.update }
}
else { return $input(You must select a blacklist entry to edit.,4,Baka detected.) }
}
;-- Del --
on *:dialog:blist:sclick:10: {
if ($did(blist,9).seltext) {
/dc 4Removing selected address from blacklist.
.ruser blacklisted $gettok($did(blist,9).seltext,1,32)
if ($readvar(extra_remignore) == on) {
/dc Removing address from ignore list.
.ignore -r $gettok($did(blist,9).seltext,1,32)
}
dialog.update
}
else { return $input(You must select a blacklist entry to delete.,4,Baka detected.) }
}
;-- Del Wildcard --
on *:dialog:blist:sclick:15: {
var %s $input(Enter Wildcard address (eg. *!*@*.aol.com). Or enter a nickname. The nickname must exist on IRC.,1,Remove Wildcard address or nick.)
if (%s) {
/dc 4Calling "/blacklist.del %s $+ "
blacklist.del %s
dialog.update
}
}
;-- Clear All --
on *:dialog:blist:sclick:11: {
blacklist.clear | dialog.update
}
;-- Options Chan List Add button --
on *:dialog:blist:sclick:32: {
if ( $did(blist,30).text == $null ) || ( $left($did(blist,30).text,1) != $chr(035) ) {
return $input(Invalid Channel,4,Error)
}
did -a blist 30 $did(blist,30).text
did -d blist 30 0
}
;-- Del button --
on *:dialog:blist:sclick:33: {
if ($did(blist,30).sel) {
did -d blist 30 $did(blist,30).sel
did -d blist 30 0
}
}
;-- Clear button --
on *:dialog:blist:sclick:34: {
did -r blist 30
}