https://script.quakenet.org/wiki/api.php?action=feedcontributions&user=Shenghi&feedformat=atomScriptwiki - User contributions [en]2024-03-29T13:35:35ZUser contributionsMediaWiki 1.27.2https://script.quakenet.org/wiki/index.php?title=User:Shenghi&diff=6176User:Shenghi2016-11-29T15:12:35Z<p>Shenghi: Updated age</p>
<hr />
<div>{{Babel-2|nl|en-3}}<br />
<table border="0"><br />
<tr><br />
<!--<td>[[Image:Shenghi.jpg]]</td>--><br />
<td><br />
<table border="0"><br />
<tr><td><b>Name</b></td><td>Bart van Nierop</td></tr><br />
<tr><td><b>Age</b></td><td>33</td></tr><br />
<tr valign="top" height="40"><td><b>Country</b></td><td>Rotterdam, Netherlands</td></tr><br />
<br />
<tr><td><b>Words of wisdom</b></td><td>Give a man a fish and he has food for a day. Teach a man how to fish and he has food for the rest of his life.</td></tr><br />
<tr><td></td><td>People are not born stupid, they decide to be stupid. If you made that decision, please change your mind.</td></tr><br />
</table><br />
</td><br />
</tr><br />
</table><br />
[[Category:Members]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=User:Shenghi&diff=4477User:Shenghi2008-03-31T14:48:28Z<p>Shenghi: 2 years and 4 months too late... but whatever :f</p>
<hr />
<div>{{Babel-2|nl|en-3}}<br />
<table border="0"><br />
<tr><br />
<!--<td>[[Image:Shenghi.jpg]]</td>--><br />
<td><br />
<table border="0"><br />
<tr><td><b>Name</b></td><td>Bart van Nierop</td></tr><br />
<tr><td><b>Age</b></td><td>24</td></tr><br />
<tr valign="top" height="40"><td><b>Country</b></td><td>Rotterdam, Netherlands</td></tr><br />
<br />
<tr><td><b>Words of wisdom</b></td><td>Give a man a fish and he has food for a day. Teach a man how to fish and he has food for the rest of his life.</td></tr><br />
<tr><td></td><td>People are not born stupid, they decide to be stupid. If you made that decision, please change your mind.</td></tr><br />
</table><br />
</td><br />
</tr><br />
</table><br />
[[Category:Members]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Bracket_Checking_Tool&diff=4503Bracket Checking Tool2008-02-01T22:30:37Z<p>Shenghi: </p>
<hr />
<div>This script contains a tool for checking the number of opening and closing brackets in a scriptfile or line against each other. It is not flawless and there can be cases where it flags an error when there is none. For example when using a smiley in a /msg. This works the other way around, too. When you missed a bracket but, for example, a smiley in a /msg makes up for that missing bracket, this tool will not flag an error.<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; Bracket checking tool <br />
; Written by Shenghi <br />
; Contact in #help.script @ irc.quakenet.org <br />
; <br />
; Small tool that checks closing and opening brackets <br />
; in a single line or a file. <br />
; <br />
; Note: With brackets we (I) mean the ( and ) characters.<br />
; <br />
; Usage: /bcheck [-f] <text|file> <br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
alias bcheck { <br />
if ($0 == 2) && ($1 == -f) { <br />
if (!$isfile($2)) echo -ag mdt: No such file. <br />
else { <br />
echo -ag Debugging file: $2 <br />
var %ticks = $ticks <br />
var %pos = 0 <br />
var %l = 1 <br />
var %fs = $file($2).size <br />
while (%pos < %fs) { <br />
bread -t $2 %pos %fs &n <br />
if (!$iscomment(&n)) { <br />
if ($obrack(&n) != $cbrack(&n)) echo -ag bcheck: Error on line %l $+ : number of opening brackets = $v1 -=- number of closing brackets = $v2 $+ . <br />
} <br />
inc %l <br />
var %pos = $calc(%pos + $bvar(&n,0) + 2) <br />
} <br />
echo -ag End of debug. $calc(%l - 1) lines debugged in $calc($ticks - %ticks) ms. <br />
} <br />
} <br />
elseif ($1 != -f) { <br />
if ($count($1-,$chr(40)) != $count($1-,$chr(41))) echo -ag bcheck: Error: number of opening brackets = $v1 -=- number of closing brackets = $v2 $+ . <br />
else echo -ag bcheck: No errors found. <br />
} <br />
else echo -ag bcheck: Error. Erronious syntax. <br />
} <br />
<br />
alias -l iscomment { <br />
if ($bfind($1,1,59)) { <br />
var %bd_semicolon = $v1 <br />
var %i = $calc(%bd_semicolon - 1) <br />
while %i { <br />
if ($bvar($1,%i) != 32) return $null <br />
else dec %i <br />
} <br />
return 1 <br />
} <br />
} <br />
<br />
alias -l obrack { <br />
if ($bvar($1,0) < 900) return $count($bvar($1,1,$v1).text,$chr(40)) <br />
var %num = 0 <br />
var %bpos = 1 <br />
while ($bvar($1,%bpos)) { <br />
if ($bfind($1,%bpos,40)) { <br />
inc %num <br />
var %bpos = $calc($v1 + 1) <br />
} <br />
else var %bpos = $calc($bvar($1,0) + 1) <br />
} <br />
return %num <br />
} <br />
<br />
alias -l cbrack { <br />
if ($bvar($1,0) < 900) return $count($bvar($1,1,$v1).text,$chr(41)) <br />
var %num = 0 <br />
var %bpos = 1 <br />
while ($bvar($1,%bpos)) { <br />
if ($bfind($1,%bpos,41)) { <br />
inc %num <br />
var %bpos = $calc($v1 + 1) <br />
} <br />
else var %bpos = $calc($bvar($1,0) + 1) <br />
} <br />
return %num <br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Login_and_user_system&diff=2304Login and user system2007-07-11T12:26:00Z<p>Shenghi: Removed ; for the sake of uniqueness <3</p>
<hr />
<div>A user system with accesslevels and user control.<br /><br />
The main idea of this script is to identify users through a login, not like mirc's default accesslevels, by nick/ident/host or some of those combinations.<br /><br />
Here it doesn't matter what nick/ident/host the user has, he just logs into the bot.<br />
<br />
Commands:<br /><br />
* /loadusers = makes the users and login tables, and loads saved user information.<br />
* /saveusers = saves user information to users.hsh and frees users and login tables.<br />
* /adduser = adds a new user (/adduser <username> <password><br />
* /deluser = deletes an existing user /deluser <username>)<br />
* /userlist = gives you a list of users (/userlist <-all|-active> -all = all of the users, -active = list only logged in users)<br />
* /edituser = edits users information (/edituser <-pass|-username|-addlevel|-remlevel|-help> <username> <parameters>)<br />
* /logoutusers = logs out all users from a given channel (/logoutusers #chan, used when you part/get kicked)<br />
''$adduser, $deluser and $edituser aliases can be used as an identifier, they return the message whether command was succesfull, or errormessage if input wasn't correct''<br />
<br />
Identifiers:<br /><br />
* $checklevel = checks if the user has sufficient accesslevel, returns $true/$false ($checklevel($address,$chan,master))<br />
* $getlevel = return the users level, numbered/named ($getlevel($address,$chan|Global))<br />
* $getuser = returns username by given address ($getuser($address))<br />
<br />
A little more explanation on how this works:<br /><br />
The user can have an acceslevels on a channel, and a global accesslevel, when checking for a level on certain channel, and it's insufficient, then the global level is checked.<br /><br />
ie. you have a command !op, which requires atleast level 10 to use it, $checklevel($address,$chan,10) is then used, if the user has accesslevel of 5 on that channel, but he has a Global level of 15, he can use the command.<br /><br />
You can also check only for a global level by doing $checklevel($address,global,10), and if you only want to know, if the user is logged in, you can use $checklevel($address).<br />
<br />
If you want to compare the exact level of the user, use $getlevel($address,$chan) ($chan or "global") in an if like: if ($getlevel($address,$chan) == Master) { notice $nick yes, you are a master on $chan }<br /><br />
If you wish to use named levels, like Master, Owner, etc. you'll need to add those levels with corresponding numbered level into the '''cuser''' alias, see the source for more info.<br />
<br />
I added events for user control to the examples part, so you can add the script to your bot and use the commands via query/channel with !command.<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br />
;; Usersystem with accesslevels and user control.<br />
;; Contact: Cail @ QuakeNet -> #help.script<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
alias loadusers {<br />
; check if 'users' and 'login' tables already exist, if not, create them<br />
if (!$hget(users)) { hmake users 100 }<br />
if (!$hget(login)) { hmake login 100 }<br />
<br />
; check if there is a file 'users.hsh' (saved user information), if we have it, empty users-table and load the saved info<br />
if ($is_file(users.hsh)) { hdel -w users * | hload users users.hsh }<br />
}<br />
<br />
alias saveusers {<br />
; check if 'users' and 'login' tables even exist, if so, they can be saved and freed<br />
if ($hget(users)) { hsave users users.hsh | .hfree users }<br />
if ($hget(login)) { hfree login }<br />
}<br />
<br />
alias -l logoutusers {<br />
; loop through a given channel ($1 = channel) and logout everyone who is logged in<br />
<br />
var %x = 1 <br />
while ($nick($1,%x)) { <br />
var %addr = $v1 <br />
<br />
; check the login table for a matching address with $ial().addr, and if he's not on any other same channels as you<br />
if ($hget(login,$ial(%addr).addr)) && (!$comchan(%addr,2)) { hdel login %addr } <br />
inc %x <br />
}<br />
}<br />
<br />
alias cuser {<br />
; return corresponding accesslevel for named levels, needed for comparison<br />
<br />
if ($1 == owner) { return 200 }<br />
elseif ($1 == master) { return 150 }<br />
elseif ($1 == test) { return 100 }<br />
else { return $1 }<br />
}<br />
<br />
alias checklevel {<br />
; if $2 ('#channel' or 'global') isn't given, check if the user is logged in<br />
if (!$2) { return $iif($hget(login,$1),$true,$false) }<br />
<br />
; fetch the username to %user from the login table by $1 (given address),<br />
; %lvl_chan and %lvl_global will get their values from the users-table, converted to a numeric with $cuser<br />
; $iif gives them value 0 if they don't exist (comparison won't work with $null)<br />
var %user = $hget(login,$1)<br />
var %lvl_chan = $iif($cuser($hget(users,$+(%user,$chr(7),$2))),$v1,0)<br />
var %lvl_global = $iif($cuser($hget(users,$+(%user,$chr(7),global))),$v1,0)<br />
<br />
; inner $iif checks which one is greater, channel level or global level, and compares it to given level ($3)<br />
return $iif($iif(%lvl_global > %lvl_chan,%lvl_global,%lvl_chan) >= $cuser($3),$true,$false)<br />
}<br />
<br />
alias getlevel {<br />
; return the named level by given address<br />
return $hget(users,$+($hget(login,$1),$chr(7),$2))<br />
}<br />
<br />
alias getuser { <br />
; return username by given address<br />
return $hget(login,$1) <br />
}<br />
<br />
alias adduser {<br />
; errorchecking<br />
; check if the users-table exist<br />
if (!$hget(users)) { var %error = You need to load the usertable first: /loadusers }<br />
; check if there's enough parameters<br />
if (!$2) { var %error = Insufficient parameters, usage: /adduser <username> <password> }<br />
; check if given username doesn't exist<br />
if ($hget(users,$1)) { var %error = That username is already taken! }<br />
; validate the username and password<br />
if (!$regex($+($1,$2),/^([][A-Za-z\\^`{|}-][][\w\\^`{|}-]*)$/)) { var %error = Incorrect username. }<br />
<br />
; if we encountered an error return the error msg or echo it, depending of if it was called as an identifier or not<br />
; else say that everything's fine<br />
if (%error) { echo -ag %error | return %error } <br />
<br />
; everything was fine if we got here, add the user into users table and save the table<br />
hadd users $1 $2<br />
hsave users users.hsh <br />
echo -ag User $1 added.<br />
return User $1 added.<br />
}<br />
<br />
alias edituser {<br />
; errorchecking<br />
; check if valid parameters are given ($1 = switch, $2 = username, $3- = parameters)<br />
if (!$istok(-pass -addlevel -remlevel -username -help,$1,32)) || (!$3) { <br />
var %error Usage: /edituser <-pass|-addlevel|-remlevel|-username|-help> <username> <parameters><br />
}<br />
; check if the user exists<br />
elseif (!$hget(users,$2)) { var %error No such user. }<br />
<br />
; echo/return errors if any, else carry on<br />
if (%error) { echo -ag %error | return %error }<br />
<br />
; get the address from the login-table, and check if the address is found from IAL, if so, we can msg the user with the changes made<br />
var %nick = $ial($+(*,$hfind(login,$2,1).data),1).nick<br />
<br />
; -pass: changes the users password<br />
if ($1 == -pass) {<br />
; check the validity of the password<br />
if (!$regex($3,/^([][A-Za-z\\^`{|}-][][\w\\^`{|}-]*)$/)) { var %error Incorrect password. }<br />
<br />
; check for errors<br />
if (%error) { echo -ag %error | return %error }<br />
<br />
; everything's fine, add the new password to the users table, echo, and msg %nick (if found)<br />
hadd users $2 $3 <br />
if (%nick) { .notice $v1 Your password has been changed to $3 }<br />
echo -ag Changed $2 $+ 's password to $3 <br />
return Changed $2 $+ 's password to $3<br />
}<br />
<br />
; -addlevel: add access level to user, for #channel or Global<br />
elseif ($1 == -addlevel) {<br />
; here we have more parameters, so we need to check that there is $4<br />
if ($4 == $null) { var %error Usage: /edituser -addlevel username #channel|global accesslevel }<br />
<br />
; check for errors<br />
if (%error) { echo -ag %error | return %error }<br />
<br />
; add a new item into users-table (username7#channel) that 7 in there is $chr(7), we use it to separate username and channel in the item name<br />
; then again echo and msg %nick if possible<br />
hadd users $+($2,$chr(7),$3) $4<br />
if (%nick) { .notice $v1 Your $3 accesslevel has been changed to $4 $+ . }<br />
echo -ag Changed $2 $+ 's level to > $3 $+ : $4<br />
return Changed $2 $+ 's level to > $3 $+ : $4<br />
}<br />
<br />
; -remlevel: remove a users level<br />
elseif ($1 == -remlevel) {<br />
; check that the user has accesslevels in $3 (given channel/Global)<br />
if (!$hget(users,$+($2,$chr(7),$3))) { var %error = User $2 doesn't have accesslevel in $3 }<br />
<br />
; check for errors<br />
if (%error) { echo -ag %error | return %error }<br />
<br />
; hdel the item from users-table, echo, and msg %nick if possible<br />
hdel users $+($2,$chr(7),$3) <br />
if (%nick) { .notice $v1 Your accesslevel in $3 has been removed. }<br />
echo -ag Removed $2 $+ 's accesslevel from $3<br />
return Removed $2 $+ 's accesslevel from $3<br />
}<br />
<br />
; -username: change the username of someone (this is case-insensitive, so you cannot change ie. Cail -> cail)<br />
elseif ($1 == -username) {<br />
; check that the new username isn't already taken, and validate the new username<br />
if ($hget(users,$3)) { var %error = That username is already taken! }<br />
if (!$regex($3,/^([][A-Za-z\\^`{|}-][][\w\\^`{|}-]*)$/)) { var %error = Incorrect username. }<br />
<br />
; check for errors<br />
if (%error) { echo -ag %error | return %error }<br />
<br />
; we need to store the address to a variables, 'cause we will be deleting the old item from the login-table<br />
var %pass = $hget(users,$2)<br />
var %address = $hfind(login,$2,1).data<br />
<br />
; add the new username with the old password, and delete the old item<br />
hadd users $3 $hget(users,$2)<br />
hdel users $2 <br />
<br />
; update all the access levels for the new username, %y = the number of accesslevel items<br />
var %y = $hfind(users,$+($2,$chr(7),*),0,w)<br />
while (%y) {<br />
; use $hfind to get the old item name<br />
var %item = $hfind(users,$+($2,$chr(7),*),%y,w)<br />
<br />
; add the new itemname with the old value, and delete the old item<br />
hadd users $+($3,$chr(7),$gettok(%item,2-,7)) $hget(users,%item)<br />
hdel users %item<br />
dec %y<br />
}<br />
<br />
; change the username in the login-table, if the user is logged in, and msg him with the changes<br />
if (%address) { hadd login %address $3 }<br />
if (%nick) { .notice $v1 Your username has been changed to $3 $+ . }<br />
echo -ag Changed $2 $+ 's username to $3<br />
return Changed $2 $+ 's username to $3<br />
}<br />
<br />
; -help: echo the syntax of /edituser<br />
elseif ($1 == -help) {<br />
echo -ag -pass -> /edituser -pass <username> <new_password><br />
echo -ag -addlevel -> /edituser -addlevel <username> <#channel|global> <level><br />
echo -ag -remlevel -> /edituser -remlevel <username> <#channel|global><br />
echo -ag -username -> /edituser -username <username> <new_username><br />
echo -ag If level is a named level, make sure you have added it into the cuser -alias.<br />
}<br />
<br />
; we have made some changes to the users-table, save it now<br />
hsave users users.hsh<br />
}<br />
<br />
alias deluser {<br />
; check that given username exists<br />
if (!$hget(users,$1)) { var %error No such user. }<br />
<br />
; check for errors<br />
if (%error) { echo -ag %error | return %error }<br />
<br />
; delete the username from the userstable and remove all of his accesslevels, and echo the progress<br />
; and if he is logged in, remove him from the login-table<br />
hdel users $1<br />
hdel -w users $+($1,$chr(7),*)<br />
if ($hfind(login,12,1).data) { hdel login $v1 }<br />
echo -ag Removed user $1<br />
return Removed user $1<br />
}<br />
<br />
alias userlist {<br />
; check that given input is correct<br />
if (!$istok(-all -active,$1,32)) { echo -ag Usage: /userlist <-all|-active> | return }<br />
<br />
; make variable %active $true/$false depending on if we're looking for active users<br />
var %active = $iif($1 == -active,$true,$false)<br />
<br />
; echo an empty line and "listing blaa blaa"<br />
echo -ag $chr(160)<br />
echo -ag --- Listing $remove($1,-) users:<br />
<br />
; the regular expression in the $hfind finds all the items, that doesn't have $chr(7) in the itemname (we don't want to mix accesslevel items with username items)<br />
var %x = 1 <br />
while ($hfind(users,/^[^\x07]+$/i,%x,r)) { <br />
; put the username into a variable, if the user is logged in, %address will hold his address, assign %levels variable to $null at the start<br />
var %user = $v1<br />
var %address = $hfind(login,%user,1).data<br />
var %levels = $null<br />
<br />
; if we are looking for active users %active will now be $true, and if there's no %address, the user isn't logged in, so /continue and keep looking for users<br />
if (%active) && (!%address) { inc %x | continue }<br />
<br />
; echo username and address/"not logged", $base() here will zero-pad the number (2 becomes 02, looks better)<br />
echo -ag $chr(31) $+ $base(%x,10,10,2) $+ : %user ( $+ $iif(%address,%address,not logged) $+ ) $chr(31) <br />
<br />
; now that we have a user, loop through all of his accesslevels (now we want to find everyitem starting with username7, where the 7 is again $chr(7))<br />
var %y = 1<br />
while ($hfind(users,$+(%user,$chr(7),*),%y,w)) {<br />
; put the levels into %levels variable, so we can echo all of them on one line (we''ll put $chr(7) here to separate the "#channel: level" from "#channel2: level2" so we can sort them later)<br />
var %levels = $gettok($v1,2-,7) $+ : $hget(users,$v1) $+ $chr(7) $+ %levels<br />
inc %y<br />
}<br />
<br />
; so we have all the levels the user has in %levels, now $sorttok so we get the Global-level first, and replace that $chr(7) with spaces and -<br />
; we would get a line like: Global: Master - #channel: Owner etc.<br />
echo -ag $str($chr(160),3) Levels: $replace($sorttok(%levels,7,r),$chr(7),$+($chr(32),-,$chr(32)))<br />
inc %x <br />
}<br />
<br />
; echo "end of" and an empty line<br />
echo -ag --- End of users.<br />
echo -ag $chr(160)<br />
}<br />
<br />
; EVENTS<br />
<br />
on *:start:{ loadusers }<br />
on *:exit:{ saveusers }<br />
<br />
on !*:quit:{ <br />
; if the user that quit, was logged in, remove him from the login table<br />
if ($hget(login,$address)) { hdel login $address } <br />
}<br />
<br />
on *:part:#:{ <br />
; if it is you, who parts the channel, logout everyone in that channel (if they're not on some other channels, where you are)<br />
; else check if the user that quit, is logged in (and is not on any other chans with you), log him out<br />
<br />
if ($nick == $me) { logoutusers # }<br />
elseif ($hget(login,$address)) && (!$comchan($nick,2)) { hdel login $address } <br />
}<br />
<br />
on *:kick:#:{ <br />
; if it is you, who got kicked, logout everyone in that channel (if they're not on some other channels, where you are)<br />
; else check if the user that got kicked, is logged in (and is not on any other chans with you), log him out<br />
<br />
if ($knick == $me) { logoutusers # }<br />
elseif ($hget(login,$address)) && (!$comchan($knick,2)) { hdel login $address } <br />
}<br />
<br />
on ^*:open:?:login & &:{<br />
; check if user is already logged in, if so, tell him that<br />
if ($hget(login,$address)) {<br />
.notice $nick You are already logged in!<br />
}<br />
; check that the user is on atleast one channel with you<br />
elseif (!$comchan($nick,0)) { <br />
.notice $nick You need to be on atleast one same channel as i am to login. <br />
}<br />
; if the login information is correct (check that item $2 has the right password $3), add the user into login-table<br />
elseif ($hget(users,$2) == $3) {<br />
.notice $nick succesfully logged in<br />
hadd login $address $2<br />
}<br />
; else the login information is incorrect<br />
else { <br />
.notice $nick Wrong username/password.<br />
}<br />
haltdef<br />
}<br />
<br />
== Exaples of usage ==<br />
<br />
on *:text:!adduser & &:*:{<br />
if ($getlevel($address,global) == Owner) { .notice $nick $adduser($2,$3) }<br />
else { .notice $nick You need to be an owner to use this command }<br />
}<br />
<br />
on *:text:!edituser & & *:*:{<br />
if ($getlevel($address,global) == Owner) { .notice $nick $edituser($2,$3,$4,$5) }<br />
else { .notice $nick You need to be an owner to use this command }<br />
}<br />
<br />
on *:text:!deluser &:*:{<br />
if ($getlevel($address,global) == Owner) { .notice $nick $deluser($2) }<br />
else { .notice $nick You need to be an owner to use this command }<br />
}<br />
<br />
on *:text:!opme:*:{ <br />
; we'll use $checklevel to determine if the user has atleast accesslevel of Master in $chan (or higher Global level)<br />
if ($checklevel($address,$chan,master)) { mode $chan +o $nick }<br />
else { .notice $nick You have to be atleast master to use this command. }<br />
}<br />
<br />
on *:text:!deopme:*:{ <br />
; and here the same, the user needs to have atleast accesslevel of 'test'<br />
if ($checklevel($address,$chan,test)) { mode $chan -o $nick }<br />
else { .notice $nick You have to be atleast at test level to use this command. }<br />
}<br />
<br />
on *:text:!whoami:*:{ <br />
; here we only check that is the user logged in, no other parameters given to $checklevel but the $address<br />
if ($checklevel($address)) { <br />
; $getuser returns the username of the user (username isn't the same as the nick)<br />
; $getlevel returns the named/numbered level of the user on $chan or 'Global'<br />
<br />
.msg $chan You are known as $getuser($address) $+ , you have accesslevel of $iif( $getlevel($address,$chan) ,$v1,0) on $chan<br />
.msg $chan Your global level is $getlevel($address,Global) <br />
}<br />
else { .notice $nick You need to login to use this command. }<br />
}<br />
<br />
[[Category:Script_Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=SimpleGather&diff=2302SimpleGather2007-07-10T11:22:52Z<p>Shenghi: Simple gather script</p>
<hr />
<div>SimpleGather is a fairly basic gather script mainly created because so many beginners are trying to make one, while even a very basic gather script is not that simple. The aim of SimpleGather is simplicity: it can run only one gather at a time, works only on a single channel, and multiple servers is out of the question. Setting it up is easy:<br />
* Copy and paste the script into a new script file, load it and make sure you run the initialization commands;<br />
* Go to the variables tab in the script editor;<br />
* Change "%gatherchannel-1172-df51-b4b6-313e-20070710100156" to your gather channel;<br />
* Change "%gatherplayercount-e7ab-d273-a5f9-6ae2-20070710094110" to the amount of players (defaults to 10);<br />
* Change "%serverinfo-da91-c1fb-b6c7-8f8b-20070710105309" to your server IP/Port.<br />
<br />
== The triggers ==<br />
* !start - Starts a new gather. Only available to channel ops.<br />
* !stop - Stops an ongoing gather. Only available to channel ops.<br />
* !add - Adds the typer to the gather. Available to everyone.<br />
* !remove - Removes the typer from the gather. Available to everyone.<br />
* !remove <nick> - Removes the specified player from the gather. Only available to channel ops.<br />
* !numplayers <num> - Sets the amount of participating players to <num>. If a gather is already past this amount then it will be flagged as full right away. Only available to channel ops.<br />
* !gatherchan <chan> - Sets the gatherchan to <chan>. Cannot be used while gathering is in progress. Only available to channel ops on both the current and the new channel.<br />
* !serverinfo <info> - Sets the server information to <info>. Cannot be used while gathering is in progress. Only available to channel ops.<br />
<br />
== The code ==<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
;; SimpleGather 1.0 by Shenghi <br />
;; #help.script @ irc.quakenet.org <br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;; <br />
<br />
;; Return hash table name. Crazy name to prevent interferance with other scripts <br />
alias -l htname !return htGather-e064-e6ac-679f-c8b3-20070710073819 <br />
<br />
;; Return gather channel name. <br />
alias -l gatherchannel !return %gatherchannel-1172-df51-b4b6-313e-20070710100156 <br />
<br />
alias -l maxplayers !return %gatherplayercount-e7ab-d273-a5f9-6ae2-20070710094110 <br />
<br />
alias -l serverinfo !return %serverinfo-da91-c1fb-b6c7-8f8b-20070710105309 <br />
<br />
alias -l resetgather { <br />
.timer 1 30 if ($!hget($!htname)) !hfree $htname <br />
.timer 1 31 msg $!gatherchannel A new gather can be started now. <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;; TRIGGERS ;;;;;;;;;;;;;;;;;;;; <br />
<br />
;; !start <br />
;; Starts a gather. Only a channel op can start a gather. <br />
on *:TEXT:!start:%gatherchannel-1172-df51-b4b6-313e-20070710100156: { <br />
if ($nick !isop #) { .notice $nick You are not allowed to start a gather. | !return } <br />
<br />
;; check to see if we are already gathering (the hashtable will exist if we are) <br />
if ($hget($htname)) { .notice $nick A gather is already going on. | !return } <br />
<br />
;; if we get here, start the gather. <br />
!hmake $htname <br />
msg # Starting a gather with $maxplayers players. Type !add to add yourself to the list of players or !remove to quit. <br />
} <br />
<br />
;; !stop <br />
;; Stops a gather. Only a channel op can stop a gather. <br />
on *:TEXT:!stop:%gatherchannel-1172-df51-b4b6-313e-20070710100156: { <br />
if ($nick !isop #) { .notice $nick You are not allowed to stop a gather. | !return } <br />
<br />
;; check to see if there is a gather we can stop <br />
if (!$hget($htname)) { .notice $nick There is currently no gather going on. | !return } <br />
<br />
;; if we get here we have to stop what's going on! <br />
!hfree $htname <br />
msg # Gather stopped. Type !start to start a new gather. <br />
} <br />
<br />
;; !add <br />
;; Adds a player to a running gather. Everyone can enter, but never more than 10 players. <br />
on *:TEXT:!add:%gatherchannel-1172-df51-b4b6-313e-20070710100156: { <br />
;; if there's no gathering going on, we can hardly add the player <br />
if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | !return } <br />
<br />
;; up to 10 players can add themselves, never more. <br />
if ($hget($htname,0).item == $maxplayers) { .notice $nick This gather is already full. | !return } <br />
<br />
;; if the player is already part of the gather, there's no point in adding them again. <br />
if ($hget($htname,$nick)) { .notice $nick You are already taking part in this gather. | !return } <br />
<br />
;; clones can't join... <br />
;;if ($hfind($htname,$gettok($fulladdress,2,33)).data) { .notice $nick Clones are not allowed to join a gather. | !return } <br />
<br />
;; if we get here, add the player <br />
!hadd $htname $nick $gettok($fulladdress,2,33) <br />
.notice $nick You have been added to the gather. <br />
<br />
;; if the player who just joined was the 10th we end the gathering <br />
;; and notify the players of the information <br />
if ($hget($htname,0).item == $maxplayers) { <br />
.disable #numplayers-afeb-6ac1-6b3a-7606-20070710103913 <br />
msg # Gather full. If you joined this gather, please do not change your name until you received server information. <br />
msg # Please wait until teams are generated and information is sent to players. <br />
<br />
var %i = $maxplayers, %teamA, %teamB <br />
while %i { <br />
if (($rand(0,1)) && ($numtok(%teamA,44) < $calc($maxplayers / 2))) || ($numtok(%teamB,44) >= $calc($maxplayers / 2)) %teamA = $addtok(%teamA,$chr(32) $+ $hget($htname,%i).item,44) <br />
else %teamB = $addtok(%teamB,$chr(32) $+ $hget($htname,%i).item,44) <br />
dec %i <br />
} <br />
msg # Team A: %teamA <br />
msg # Team B: %teamB <br />
.raw PRIVMSG $remove(%teamA,$chr(32)) :Team: A > %teamA -- Server: $serverinfo <br />
.raw PRIVMSG $remove(%teamB,$chr(32)) :Team: B > %teamB -- Server: $serverinfo <br />
.enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913 <br />
resetgather <br />
} <br />
} <br />
<br />
;; !remove <br />
;; Removes a player from a running gather. Everyone can remove themselves. <br />
on *:TEXT:!remove:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{ <br />
;; if there's no gathering going on, we can hardly remove the player <br />
if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | !return } <br />
<br />
;; if the player was no part of this gather, we can't remove him either <br />
if (!$hget($htname,$nick)) { .notice $nick You are not taking part in this gather. | !return } <br />
<br />
;; if we get here, remove the player from the gather <br />
!hdel $htname $nick <br />
.notice $nick You have been removed from the gather. <br />
} <br />
<br />
;; !remove <player> <br />
;; Removes a player from a running gather. Only a channel op can remove another player. <br />
on *:TEXT:!remove &:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{ <br />
if ($nick !isop #) { .notice $nick You are not allowed to remove another player. | !return } <br />
<br />
;; if there's no gathering going on, we can hardly remove the player <br />
if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | !return } <br />
<br />
;; if the player was no part of this gather, we can't remove him either <br />
if (!$hget($htname,$2)) { .notice $nick That player is not taking part in this gather. | !return } <br />
<br />
;; if we get here, remove the player from the gather <br />
!hdel $htname $2 <br />
.notice $nick $2 has been removed from the gather. <br />
} <br />
<br />
;; !players <br />
;; Shows the current players in a running gather. Only channel operators can use this trigger <br />
on *:TEXT:!players:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{ <br />
if ($nick !isop #) { .notice $nick You are not allowed to dump the playerlist. | !return } <br />
<br />
;; if there is no gather going on, there is no list of players to dump. <br />
if (!$hget($htname)) { msg # There is no gather going on at this moment. Use !start to start one. | !return } <br />
var %i = $hget($htname,0).item <br />
if (!%i) { msg # There are currently no players participating in this gather. | !return } <br />
var %players <br />
while %i { <br />
%players = $addtok(%players,$chr(32) $+ $hget($htname,%i).item,44) <br />
dec %i <br />
} <br />
msg # Current players: %players <br />
} <br />
<br />
#numplayers-afeb-6ac1-6b3a-7606-20070710103913 on <br />
;; !numplayers <br />
;; Sets the amount of players. <br />
on *:TEXT:!numplayers &:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{ <br />
;; first arg has to be a number <br />
if ($2 !isnum) { .notice $nick Wrong usage of trigger. | !return } <br />
<br />
if ($calc($2 % 2)) { .notice $nick Number of players must be even. | !return } <br />
<br />
<br />
!set %gatherplayercount-e7ab-d273-a5f9-6ae2-20070710094110 $2 <br />
msg # Amount of players for gather set to $2 $+ . <br />
<br />
if ($hget($htname,0).item >= $maxplayers) { <br />
;; form teams and start... <br />
.disable #numplayers-afeb-6ac1-6b3a-7606-20070710103913 <br />
msg # Gather full. If you joined this gather, please do not change your name until you received server information. <br />
msg # Please wait until teams are generated and information is sent to players. <br />
<br />
var %i = $maxplayers, %teamA, %teamB <br />
while %i { <br />
if (($rand(0,1)) && ($numtok(%teamA,44) < $calc($maxplayers / 2))) || ($numtok(%teamB,44) >= $calc($maxplayers / 2)) %teamA = $addtok(%teamA,$chr(32) $+ $hget($htname,%i).item,44) <br />
else %teamB = $addtok(%teamB,$chr(32) $+ $hget($htname,%i).item,44) <br />
dec %i <br />
} <br />
msg # Team A: %teamA <br />
msg # Team B: %teamB <br />
.raw PRIVMSG $remove(%teamA,$chr(32)) :Team: A > %teamA -- Server: $serverinfo <br />
.raw PRIVMSG $remove(%teamB,$chr(32)) :Team: B > %teamB -- Server: $serverinfo <br />
.enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913 <br />
resetgather <br />
} <br />
} <br />
#numplayers-afeb-6ac1-6b3a-7606-20070710103913 end <br />
<br />
;; !gatherchan <br />
;; Changes gather channel to a new one <br />
on *:TEXT:!gatherchan &:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{ <br />
if ($nick !isop #) { .notice $nick Only a channel operator on both old and new channel can change the channel. | !return } <br />
if ($hget($htname)) { .notice $nick Cannot change gather channel while a gather is running. | !return } <br />
if ($left($2,1) !isin $chantypes) { .notice $nick Not a valid channelname. | !return } <br />
if ($me !ison $2) { .notice $nick Cannot change the gather channel to a channel I am not on. | !return } <br />
if ($nick !isop $2) { .notice $nick Only a channel operator on both old and new channel can change the channel. | !return } <br />
<br />
!set %gatherchannel-1172-df51-b4b6-313e-20070710100156 $2 <br />
.notice $nick Gather channel set to $2 <br />
} <br />
<br />
;; !serverinfo <br />
;; Changes the server info. Only a channel operator can use this. <br />
on *:TEXT:!serverinfo *:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{ <br />
if ($nick !isop #) { .notice $nick You are not allowed to change the server info | !return } <br />
if ($hget($htname)) { .notice $nick Server info cannot be changed during a gather. | !return } <br />
<br />
!set %serverinfo-da91-c1fb-b6c7-8f8b-20070710105309 $2- <br />
.notice $nick Server information changed. <br />
} <br />
<br />
;;;;; Some overhead. When a player quits, parts or is kicked they are removed from the gather. <br />
;;;;; When the bot quits or is disconnected the gather is terminated. <br />
;;;;; When a user changes his nick it's automatically updated <br />
on *:KICK:%gatherchannel-1172-df51-b4b6-313e-20070710100156: if ($hget($htname,$nick)) !hdel $htname $nick <br />
on *:PART:%gatherchannel-1172-df51-b4b6-313e-20070710100156: if ($hget($htname,$nick)) !hdel $htname $nick <br />
on *:QUIT: { <br />
if ($nick == $me) && ($hget($htname)) !hfree $htname <br />
else if ($hget($htname,$nick)) !hdel $htname $nick <br />
} <br />
on *:DISCONNECT: if ($hget($htname)) !hfree $htname <br />
<br />
on *:NICK:{ <br />
if ($nick != $me) && ($nick != $newnick) { <br />
if ($hget($htname,$nick)) { <br />
!hadd $htname $newnick $v1 <br />
!hdel $htname $nick <br />
} <br />
} <br />
} <br />
<br />
on *:LOAD:{ <br />
!set %gatherchannel-1172-df51-b4b6-313e-20070710100156 #channel <br />
!set %gatherplayercount-e7ab-d273-a5f9-6ae2-20070710094110 10 <br />
!set %serverinfo-da91-c1fb-b6c7-8f8b-20070710105309 cs.someserver.com:12345 <br />
}<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$qauth_alias&diff=2764$qauth alias2007-07-08T15:10:39Z<p>Shenghi: </p>
<hr />
<div>This is a $qauth identifier for QuakeNet. It uses COM objects and Windows Scripting Shell to perform a 'sleep' action in order to wait for data sent by the server. This sleep alias causes the alias not to be very usefull in events, however, the script also offers a solution for this problem.<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; <br />
; Written by Shenghi<br />
; Contact at irc.quakenet.org -> #help.script<br />
;<br />
; $qauth identifier. Will only work on QuakeNet. It will <br />
; first try to extract the Q auth from a users host, if <br />
; the user has usermode +x set. If it can't, it will then <br />
; attempt to get the Q auth from $ial(nick).mark. If the Q <br />
; auth is not set as a mark it will send /who nick n%na to <br />
; get the Q auth from the server. To prevent having to do this <br />
; more than once for each user, the Q auth is saved as ialmark <br />
; when it's received from the server.<br />
;<br />
; The sleep alias has one annoying side-effect. It prevents the<br />
; identifier from working correctly in events. To go around this you<br />
; can put whatever you were going to do in the event in an alias<br />
; and use /timer 1 0 <alias>.<br />
;<br />
;<br />
; A simple example:<br />
; The following script might not work correctly.<br />
; on *:JOIN:#help.script:{ echo -ag $qauth($nick) }<br />
; <br />
; This will work guaranteed.<br />
; alias echo_auth { echo -ag $qauth($1) }<br />
; on *:JOIN:#help.script:{ timer 1 0 echo_auth $nick }<br />
;<br />
;<br />
; Usage: <br />
; <br />
; $qauth(nick) - Returns the qauth of a user or $null if <br />
; the user is not authed. <br />
; <br />
; <br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;; SLEEP ALIAS ;;;;;;;;;; <br />
;; Syntax: /sleep N <br />
;; Causes a script to 'sleep' N miliseconds. During this time <br />
;; server and user raws are processed and events pass. <br />
alias -l sleep { <br />
;; when called as an identifier or the number of miliseconds <br />
;; to sleep is 0, return <br />
if ($isid) || ($0 != 1) || ($1 !isnum) || ($1 < 1) !return <br />
<br />
;; otherwise set a unique filename to a var, write the remote script to <br />
;; that file and execute it using COM objects. <br />
!var %f = $ticks $+ .wsf <br />
!write %f <job id="js"><script language="jscript">WScript.Sleep( $+ $1 $+ );</script></job> <br />
!.comopen %f WScript.Shell <br />
if (!$comerr) .comclose %f $com(%f,Run,3,bstr,%f,uint,0,bool,true) <br />
!.remove %f <br />
} <br />
<br />
;;;;;;;;;; QAUTH ALIAS ;;;;;;;;;; <br />
;; Syntax: $qauth(nick) <br />
;; Returns the qauth of a user or $null if the user is not authed -- QuakeNet only <br />
alias qauth { <br />
;; check if used as identifier and if the network used on is quakenet <br />
if (!$isid) || (*.??.quakenet.org !iswm $server) !return <br />
<br />
;; check if the Q auth could be extracted from the host <br />
if ($ial($1).host) if ($regex($ial($1).host,(.+?)\.users\.quakenet\.org)) !return $regml(1) <br />
<br />
;; check if the Q auth could be extracted from the ialmark <br />
if ($ial($1).mark) !return $v1 <br />
<br />
;; set a global var and send out a who to get the users Q auth <br />
;; the while loop waits for the server response <br />
!set %getQauth [ $+ [ $1 ] ] $crlf <br />
!.who $1 n%nat,101 <br />
!var %i = 10 <br />
while (%i) && (%getQauth [ $+ [ $1 ] ] == $crlf) { <br />
sleep 10 <br />
!dec %i <br />
} <br />
<br />
;; set local return var so the global var can be removed <br />
!var %return = $iif(%getQauth [ $+ [ $1 ] ] == $crlf,$null,$v1) <br />
!unset %getQauth [ $+ [ $1 ] ] <br />
<br />
;; add q auth to IAL mark <br />
if (%return != -) !.ialmark $1 $v1 <br />
<br />
!return $iif(%return != -,$v1,$null)<br />
} <br />
<br />
;;;;;;;;;; RAW 354 - SPECIAL WHO REPLY ;;;;;;;;;; <br />
raw 354:& 101 & *:{ <br />
if (%getQauth [ $+ [ $3 ] ]) { <br />
!set %getQauth [ $+ [ $3 ] ] $iif($4,$v1,-) <br />
!haltdef <br />
} <br />
} <br />
<br />
;;;;;;;;;; RAW 315 - END OF /WHO LIST ;;;;;;;;;; <br />
raw 315:*:{ <br />
;; see whether a Q auth was requested and if so, halt the default output <br />
if (%getQauth [ $+ [ $2 ] ]) !haltdef <br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$qauth_alias&diff=2292$qauth alias2007-07-08T15:04:56Z<p>Shenghi: Fixed small bug where RAW315 output was not halted when using this alias</p>
<hr />
<div>This is a $qauth identifier for QuakeNet. It uses COM objects and Windows Scripting Shell to perform a 'sleep' action in order to wait for data sent by the server. This sleep alias causes the alias not to be very usefull in events, however, the script also offers a solution for this problem.<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; <br />
; Written by Shenghi<br />
; Contact at irc.quakenet.org -> #help.script<br />
;<br />
; $qauth identifier. Will only work on QuakeNet. It will <br />
; first try to extract the Q auth from a users host, if <br />
; the user has usermode +x set. If it can't, it will then <br />
; attempt to get the Q auth from $ial(nick).mark. If the Q <br />
; auth is not set as a mark it will send /who nick n%na to <br />
; get the Q auth from the server. To prevent having to do this <br />
; more than once for each user, the Q auth is saved as ialmark <br />
; when it's received from the server.<br />
;<br />
; The sleep alias has one annoying side-effect. It prevents the<br />
; identifier from working correctly in events. To go around this you<br />
; can put whatever you were going to do in the event in an alias<br />
; and use /timer 1 0 <alias>.<br />
;<br />
;<br />
; A simple example:<br />
; The following script might not work correctly.<br />
; on *:JOIN:#help.script:{ echo -ag $qauth($nick) }<br />
; <br />
; This will work guaranteed.<br />
; alias echo_auth { echo -ag $qauth($1) }<br />
; on *:JOIN:#help.script:{ timer 1 0 echo_auth $nick }<br />
;<br />
;<br />
; Usage: <br />
; <br />
; $qauth(nick) - Returns the qauth of a user or $null if <br />
; the user is not authed. <br />
; <br />
; <br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;; SLEEP ALIAS ;;;;;;;;;; <br />
;; Syntax: /sleep N <br />
;; Causes a script to 'sleep' N miliseconds. During this time <br />
;; server and user raws are processed and events pass. <br />
alias -l sleep { <br />
;; when called as an identifier or the number of miliseconds <br />
;; to sleep is 0, return <br />
if ($isid) || ($0 != 1) || ($1 !isnum) || ($1 < 1) !return <br />
<br />
;; otherwise set a unique filename to a var, write the remote script to <br />
;; that file and execute it using COM objects. <br />
!var %f = $ticks $+ .wsf <br />
!write %f <job id="js"><script language="jscript">WScript.Sleep( $+ $1 $+ );</script></job> <br />
!.comopen %f WScript.Shell <br />
if (!$comerr) .comclose %f $com(%f,Run,3,bstr,%f,uint,0,bool,true) <br />
!.remove %f <br />
} <br />
<br />
;;;;;;;;;; QAUTH ALIAS ;;;;;;;;;; <br />
;; Syntax: $qauth(nick) <br />
;; Returns the qauth of a user or $null if the user is not authed -- QuakeNet only <br />
alias qauth { <br />
;; check if used as identifier and if the network used on is quakenet <br />
if (!$isid) || (*.??.quakenet.org !iswm $server) !return <br />
<br />
;; check if the Q auth could be extracted from the host <br />
if ($ial($1).host) if ($regex($ial($1).host,(.+?)\.users\.quakenet\.org)) !return $regml(1) <br />
<br />
;; check if the Q auth could be extracted from the ialmark <br />
if ($ial($1).mark) !return $v1 <br />
<br />
;; set a global var and send out a who to get the users Q auth <br />
;; the while loop waits for the server response <br />
!set %getQauth [ $+ [ $1 ] ] $crlf <br />
!.who $1 n%nat,101 <br />
!var %i = 10 <br />
while (%i) && (%getQauth [ $+ [ $1 ] ] == $crlf) { <br />
sleep 10 <br />
!dec %i <br />
} <br />
<br />
;; set local return var so the global var can be removed <br />
!var %return = $iif(%getQauth [ $+ [ $1 ] ] == $crlf,$null,$v1) <br />
!unset %getQauth [ $+ [ $1 ] ] <br />
<br />
;; add q auth to IAL mark <br />
if (%return) !.ialmark $1 $v1 <br />
<br />
!return %return <br />
} <br />
<br />
;;;;;;;;;; RAW 354 - SPECIAL WHO REPLY ;;;;;;;;;; <br />
raw 354:& 101 & *:{ <br />
if (%getQauth [ $+ [ $3 ] ]) { <br />
!set %getQauth [ $+ [ $3 ] ] $iif($4,$v1,-) <br />
!haltdef <br />
} <br />
} <br />
<br />
;;;;;;;;;; RAW 315 - END OF /WHO LIST ;;;;;;;;;; <br />
raw 315:*:{ <br />
;; see whether a Q auth was requested and if so, halt the default output <br />
if (%getQauth [ $+ [ $2 ] ]) !haltdef <br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=User:Shenghi&diff=2369User:Shenghi2007-01-13T12:23:51Z<p>Shenghi: </p>
<hr />
<div>{{Babel-2|nl|en-3}}<br />
<table border="0"><br />
<tr><br />
<!--<td>[[Image:Shenghi.jpg]]</td>--><br />
<td><br />
<table border="0"><br />
<tr><td><b>Name</b></td><td>Bart van Nierop</td></tr><br />
<tr><td><b>Age</b></td><td>22</td></tr><br />
<tr valign="top" height="40"><td><b>Country</b></td><td>Rotterdam, Netherlands</td></tr><br />
<br />
<tr><td><b>Words of wisdom</b></td><td>Give a man a fish and he has food for a day. Teach a man how to fish and he has food for the rest of his life.</td></tr><br />
<tr><td></td><td>People are not born stupid, they decide to be stupid. If you made that decision, please change your mind.</td></tr><br />
</table><br />
</td><br />
</tr><br />
</table><br />
[[Category:Members]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Bracket_Checking_Tool&diff=2347Bracket Checking Tool2006-07-02T12:58:01Z<p>Shenghi: Added tool for checking brackets</p>
<hr />
<div>This script contains a tool for checking the number of opening and closing brackets in a scriptfile or line against each other. It is not flawless and there can be cases where it flags an error when there is none. For example when using a smiley in a /msg. This works the other way around, too. When you missed a bracket but, for example, a smiley in a /msg makes up for that missing bracket, this tool will not flag an error.<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; Bracket checking tool <br />
; Written by Shenghi <br />
; Contact in #help.script @ irc.quakenet.org <br />
; <br />
; Small tool that checks closing and opening brackets <br />
; in a single line or a file. <br />
; <br />
; Usage: /bcheck [-f] <text|file> <br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
alias bcheck { <br />
if ($0 == 2) && ($1 == -f) { <br />
if (!$isfile($2)) echo -ag mdt: No such file. <br />
else { <br />
echo -ag Debugging file: $2 <br />
var %ticks = $ticks <br />
var %pos = 0 <br />
var %l = 1 <br />
var %fs = $file($2).size <br />
while (%pos < %fs) { <br />
bread -t $2 %pos %fs &n <br />
if (!$iscomment(&n)) { <br />
if ($obrack(&n) != $cbrack(&n)) echo -ag bcheck: Error on line %l $+ : number of opening brackets = $v1 -=- number of closing brackets = $v2 $+ . <br />
} <br />
inc %l <br />
var %pos = $calc(%pos + $bvar(&n,0) + 2) <br />
} <br />
echo -ag End of debug. $calc(%l - 1) lines debugged in $calc($ticks - %ticks) ms. <br />
} <br />
} <br />
elseif ($1 != -f) { <br />
if ($count($1-,$chr(40)) != $count($1-,$chr(41))) echo -ag bcheck: Error: number of opening brackets = $v1 -=- number of closing brackets = $v2 $+ . <br />
else echo -ag bcheck: No errors found. <br />
} <br />
else echo -ag bcheck: Error. Erronious syntax. <br />
} <br />
<br />
alias -l iscomment { <br />
if ($bfind($1,1,59)) { <br />
var %bd_semicolon = $v1 <br />
var %i = $calc(%bd_semicolon - 1) <br />
while %i { <br />
if ($bvar($1,%i) != 32) return $null <br />
else dec %i <br />
} <br />
return 1 <br />
} <br />
} <br />
<br />
alias -l obrack { <br />
if ($bvar($1,0) < 900) return $count($bvar($1,1,$v1).text,$chr(40)) <br />
var %num = 0 <br />
var %bpos = 1 <br />
while ($bvar($1,%bpos)) { <br />
if ($bfind($1,%bpos,40)) { <br />
inc %num <br />
var %bpos = $calc($v1 + 1) <br />
} <br />
else var %bpos = $calc($bvar($1,0) + 1) <br />
} <br />
return %num <br />
} <br />
<br />
alias -l cbrack { <br />
if ($bvar($1,0) < 900) return $count($bvar($1,1,$v1).text,$chr(41)) <br />
var %num = 0 <br />
var %bpos = 1 <br />
while ($bvar($1,%bpos)) { <br />
if ($bfind($1,%bpos,41)) { <br />
inc %num <br />
var %bpos = $calc($v1 + 1) <br />
} <br />
else var %bpos = $calc($bvar($1,0) + 1) <br />
} <br />
return %num <br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Aop&diff=2120Aop2006-06-29T19:08:36Z<p>Shenghi: fixed a typo</p>
<hr />
<div>Adds or removes an address/nick to/from your autoop list.<br />
/aop [-rw] <on|off|nick/address> [#channel1,#channel2,...] [type] [network]<br />
<br />
<br />
If someone is on your auto-op list, you would op the user everytime he joins the specified channel / any channel (if no channel was specified).<br />
<br />
To turn automatically opping on, use ''/autoop on'', to turn it off ''/autoop off''.<br />
<br />
<br />
You can use the following switches:<br />
{| style="width:100%"<br />
|-<br />
| style="width:10%" | '''''Switch''''' || Style="width:90%" | '''''Meaning'''''<br />
|-<br />
| r || removes someone from the autoop list<br />
|-<br />
| w || makes the auto-op apply to every network<br />
|}<br />
<br />
If you do not specify a type then only the users nickname is used. If you specify a type then the users address is looked up via the server.<br />
<br />
'''Note''' that this is far better than using an [[On_text|On text event]], as this would flood you off the server if many people join, e.g. after a netsplit.<br />
<br />
<br />
== Example ==<br />
aop Dana!dana@staff.quakenet.org #help.script<br />
This would autoop Dana everytime she joins #help.script.<br />
<br />
<br />
aop -r Dana!dana@staff.quakenet.org<br />
This example would remove Dana from your autoop list.<br />
<br />
<br />
aop Dana<br />
If you use this command, you would op a user with the nickname ''Dana'' in every channel you are operator. Note, that this is very unsecure as everyone can use the nickname Dana if it's "free".<br />
== See Also ==<br />
Take a look at [[$aop]] to receive information about your autoop list.<br />
<br />
To give someone voice everytime he joins, use [[Avoice|/avoice]].<br />
[[Category:Control]]<br />
[[Category:Commands]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$qauth_alias&diff=2291$qauth alias2006-06-13T01:27:40Z<p>Shenghi: fixed bug in raw 315</p>
<hr />
<div>This is a $qauth identifier for QuakeNet. It uses COM objects and Windows Scripting Shell to perform a 'sleep' action in order to wait for data sent by the server. This sleep alias causes the alias not to be very usefull in events, however, the script also offers a solution for this problem.<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; <br />
; Written by Shenghi<br />
; Contact at irc.quakenet.org -> #help.script<br />
;<br />
; $qauth identifier. Will only work on QuakeNet. It will <br />
; first try to extract the Q auth from a users host, if <br />
; the user has usermode +x set. If it can't, it will then <br />
; attempt to get the Q auth from $ial(nick).mark. If the Q <br />
; auth is not set as a mark it will send /who nick n%na to <br />
; get the Q auth from the server. To prevent having to do this <br />
; more than once for each user, the Q auth is saved as ialmark <br />
; when it's received from the server.<br />
;<br />
; The sleep alias has one annoying side-effect. It prevents the<br />
; identifier from working correctly in events. To go around this you<br />
; can put whatever you were going to do in the event in an alias<br />
; and use /timer 1 0 <alias>.<br />
;<br />
;<br />
; A simple example:<br />
; The following script might not work correctly.<br />
; on *:JOIN:#help.script:{ echo -ag $qauth($nick) }<br />
; <br />
; This will work guaranteed.<br />
; alias echo_auth { echo -ag $qauth($1) }<br />
; on *:JOIN:#help.script:{ timer 1 0 echo_auth $nick }<br />
;<br />
;<br />
; Usage: <br />
; <br />
; $qauth(nick) - Returns the qauth of a user or $null if <br />
; the user is not authed. <br />
; <br />
; <br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;; SLEEP ALIAS ;;;;;;;;;; <br />
;; Syntax: /sleep N <br />
;; Causes a script to 'sleep' N miliseconds. During this time <br />
;; server and user raws are processed and events pass. <br />
alias -l sleep { <br />
;; when called as an identifier or the number of miliseconds <br />
;; to sleep is 0, return <br />
if ($isid) || ($0 != 1) || ($1 !isnum) || ($1 < 1) !return <br />
<br />
;; otherwise set a unique filename to a var, write the remote script to <br />
;; that file and execute it using COM objects. <br />
!var %f = $ticks $+ .wsf <br />
!write %f <job id="js"><script language="jscript">WScript.Sleep( $+ $1 $+ );</script></job> <br />
!.comopen %f WScript.Shell <br />
if (!$comerr) .comclose %f $com(%f,Run,3,bstr,%f,uint,0,bool,true) <br />
!.remove %f <br />
} <br />
<br />
;;;;;;;;;; QAUTH ALIAS ;;;;;;;;;; <br />
;; Syntax: $qauth(nick) <br />
;; Returns the qauth of a user or $null if the user is not authed -- QuakeNet only <br />
alias qauth { <br />
;; check if used as identifier and if the network used on is quakenet <br />
if (!$isid) || (*.??.quakenet.org !iswm $server) !return <br />
<br />
;; check if the Q auth could be extracted from the host <br />
if ($ial($1).host) if ($regex($ial($1).host,(.+?)\.users\.quakenet\.org)) !return $regml(1) <br />
<br />
;; check if the Q auth could be extracted from the ialmark <br />
if ($ial($1).mark) !return $v1 <br />
<br />
;; set a global var and send out a who to get the users Q auth <br />
;; the while loop waits for the server response <br />
!set %getQauth [ $+ [ $1 ] ] $crlf <br />
!.who $1 n%nat,101 <br />
!var %i = 10 <br />
while (%i) && (%getQauth [ $+ [ $1 ] ] == $crlf) { <br />
sleep 10 <br />
!dec %i <br />
} <br />
<br />
;; set local return var so the global var can be removed <br />
!var %return = $iif(%getQauth [ $+ [ $1 ] ] == $crlf,$null,$v1) <br />
!unset %getQauth [ $+ [ $1 ] ] <br />
<br />
;; add q auth to IAL mark <br />
if (%return) !.ialmark $1 $v1 <br />
<br />
!return %return <br />
} <br />
<br />
;;;;;;;;;; RAW 354 - SPECIAL WHO REPLY ;;;;;;;;;; <br />
raw 354:& 101 & *:{ <br />
if (%getQauth [ $+ [ $3 ] ]) { <br />
!set %getQauth [ $+ [ $3 ] ] $iif($4,$v1,$false) <br />
!haltdef <br />
} <br />
} <br />
<br />
;;;;;;;;;; RAW 315 - END OF /WHO LIST ;;;;;;;;;; <br />
raw 315:*:{ <br />
;; see whether a Q auth was requested and if so, halt the default output <br />
if (%getQauth [ $+ [ $2 ] ]) !haltdef <br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Random_password_generator&diff=1422Random password generator2006-06-05T22:54:02Z<p>Shenghi: </p>
<hr />
<div>This script will allow you to generate a random password of required length and using characters you want to.<br />
<br />
; Usage: $pwgen(length,used characters)<br />
; Examples<br />
; $pwgen(10,a-z A-Z)<br />
; $pwgen(20,a-z 0-9 0-9)<br />
; $pwgen(17,0-9 [[$chr]](36) $+ - $+ $chr(41))<br />
<br />
[[alias]] pwgen {<br />
; first we check if this alias is used as identifier<br />
if (![[$isid]]) { [[return]] }<br />
; also check if the length is correct<br />
if ([[$int]]([[$1]]) == 0) { return } <br />
; the next part will fill &chars with characters that can be picked to make the password<br />
;<br />
; we cycle the different sets of "used characters"<br />
[[var]] %i = [[$numtok]]($2,32)<br />
[[while]] (%i > 0) {<br />
var %set = [[$gettok]]($2,%i,32)<br />
; if the length of the current set is 3, we assume its the right syntax<br />
[[if]] ([[$len]](%set) == 3) {<br />
; get the ascii values of the two characters<br />
var %asc1 = [[$asc]]([[$left]](%set,1)) , %asc2 = $asc([[$right]](%set,1))<br />
var %j = [[$iif]](%asc1 < %asc2,%asc1,%asc2) , %max = $iif(%asc1 < %asc2,%asc2,%asc1)<br />
; we will loop from the smallest ascii number to the largest<br />
while (%j <= %max) {<br />
; we add the ascii value to the &chars binvar<br />
[[bset]] &chars [[$calc]]([[$bvar]](&chars,0) + 1) %j<br />
[[inc]] %j<br />
}<br />
}<br />
[[dec]] %i<br />
}<br />
; check if &chars is not empty<br />
if ($bvar(&chars,0) == 0) { return }<br />
;<br />
; now we filled &chars we randomly pick characters out of &chars to make the password<br />
var %i = $iif([[$abs]]($int($1)) > 900,900,[[$v1]])<br />
; we do this $1 times, as long as its not larger then 900<br />
; (wich is approximate the limit of commands)<br />
while (%i > 0) {<br />
var %pw = %pw $+ $bvar(&chars,[[$rand]](1,$bvar(&chars,0))).text<br />
dec %i<br />
}<br />
; and its done<br />
return %pw<br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$qauth_alias&diff=1425$qauth alias2006-06-05T22:52:33Z<p>Shenghi: </p>
<hr />
<div>This is a $qauth identifier for QuakeNet. It uses COM objects and Windows Scripting Shell to perform a 'sleep' action in order to wait for data sent by the server. This sleep alias causes the alias not to be very usefull in events, however, the script also offers a solution for this problem.<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; <br />
; Written by Shenghi<br />
; Contact at irc.quakenet.org -> #help.script<br />
;<br />
; $qauth identifier. Will only work on QuakeNet. It will <br />
; first try to extract the Q auth from a users host, if <br />
; the user has usermode +x set. If it can't, it will then <br />
; attempt to get the Q auth from $ial(nick).mark. If the Q <br />
; auth is not set as a mark it will send /who nick n%na to <br />
; get the Q auth from the server. To prevent having to do this <br />
; more than once for each user, the Q auth is saved as ialmark <br />
; when it's received from the server.<br />
;<br />
; The sleep alias has one annoying side-effect. It prevents the<br />
; identifier from working correctly in events. To go around this you<br />
; can put whatever you were going to do in the event in an alias<br />
; and use /timer 1 0 <alias>.<br />
;<br />
;<br />
; A simple example:<br />
; The following script might not work correctly.<br />
; on *:JOIN:#help.script:{ echo -ag $qauth($nick) }<br />
; <br />
; This will work guaranteed.<br />
; alias echo_auth { echo -ag $qauth($1) }<br />
; on *:JOIN:#help.script:{ timer 1 0 echo_auth $nick }<br />
;<br />
;<br />
; Usage: <br />
; <br />
; $qauth(nick) - Returns the qauth of a user or $null if <br />
; the user is not authed. <br />
; <br />
; <br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;; SLEEP ALIAS ;;;;;;;;;; <br />
;; Syntax: /sleep N <br />
;; Causes a script to 'sleep' N miliseconds. During this time <br />
;; server and user raws are processed and events pass. <br />
alias -l sleep { <br />
;; when called as an identifier or the number of miliseconds <br />
;; to sleep is 0, return <br />
if ($isid) || ($0 != 1) || ($1 !isnum) || ($1 < 1) !return <br />
<br />
;; otherwise set a unique filename to a var, write the remote script to <br />
;; that file and execute it using COM objects. <br />
!var %f = $ticks $+ .wsf <br />
!write %f <job id="js"><script language="jscript">WScript.Sleep( $+ $1 $+ );</script></job> <br />
!.comopen %f WScript.Shell <br />
if (!$comerr) .comclose %f $com(%f,Run,3,bstr,%f,uint,0,bool,true) <br />
!.remove %f <br />
} <br />
<br />
;;;;;;;;;; QAUTH ALIAS ;;;;;;;;;; <br />
;; Syntax: $qauth(nick) <br />
;; Returns the qauth of a user or $null if the user is not authed -- QuakeNet only <br />
alias qauth { <br />
;; check if used as identifier and if the network used on is quakenet <br />
if (!$isid) || (*.??.quakenet.org !iswm $server) !return <br />
<br />
;; check if the Q auth could be extracted from the host <br />
if ($ial($1).host) if ($regex($ial($1).host,(.+?)\.users\.quakenet\.org)) !return $regml(1) <br />
<br />
;; check if the Q auth could be extracted from the ialmark <br />
if ($ial($1).mark) !return $v1 <br />
<br />
;; set a global var and send out a who to get the users Q auth <br />
;; the while loop waits for the server response <br />
!set %getQauth [ $+ [ $1 ] ] $crlf <br />
!.who $1 n%nat,101 <br />
!var %i = 10 <br />
while (%i) && (%getQauth [ $+ [ $1 ] ] == $crlf) { <br />
sleep 10 <br />
!dec %i <br />
} <br />
<br />
;; set local return var so the global var can be removed <br />
!var %return = $iif(%getQauth [ $+ [ $1 ] ] == $crlf,$null,$v1) <br />
!unset %getQauth [ $+ [ $1 ] ] <br />
<br />
;; add q auth to IAL mark <br />
if (%return) !.ialmark $1 $v1 <br />
<br />
!return %return <br />
} <br />
<br />
;;;;;;;;;; RAW 354 - SPECIAL WHO REPLY ;;;;;;;;;; <br />
raw 354:& 101 & *:{ <br />
if (%getQauth [ $+ [ $3 ] ]) { <br />
!set %getQauth [ $+ [ $3 ] ] $iif($4,$v1,$false) <br />
!haltdef <br />
} <br />
} <br />
<br />
;;;;;;;;;; RAW 315 - END OF /WHO LIST ;;;;;;;;;; <br />
raw 315:*:{ <br />
;; see whether a Q auth was requested and if so, halt the default output <br />
if ($getQauth [ $+ [ $2 ] ]) !haltdef <br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$qauth_alias&diff=1420$qauth alias2006-06-05T22:38:19Z<p>Shenghi: Added script for a $qauth identifier</p>
<hr />
<div>This is a $qauth identifier for QuakeNet. It uses COM objects and Windows Scripting Shell to perform a 'sleep' action in order to wait for data sent by the server. This sleep alias causes the alias not to be very usefull in events, however, the script also offers a solution for this problem.<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; <br />
; $qauth identifier. Will only work on QuakeNet. It will <br />
; first try to extract the Q auth from a users host, if <br />
; the user has usermode +x set. If it can't, it will then <br />
; attempt to get the Q auth from $ial(nick).mark. If the Q <br />
; auth is not set as a mark it will send /who nick n%na to <br />
; get the Q auth from the server. To prevent having to do this <br />
; more than once for each user, the Q auth is saved as ialmark <br />
; when it's received from the server.<br />
;<br />
; The sleep alias has one annoying side-effect. It prevents the<br />
; identifier from working correctly in events. To go around this you<br />
; can put whatever you were going to do in the event in an alias<br />
; and use /timer 1 0 <alias>.<br />
;<br />
; A simple example:<br />
; The following script might not work correctly.<br />
; on *:JOIN:#help.script:{ echo -ag $qauth($nick) }<br />
; <br />
; This will work guaranteed.<br />
; alias echo_auth { echo -ag $qauth($1) }<br />
; on *:JOIN:#help.script:{ timer 1 0 echo_auth $nick }<br />
;<br />
; Usage: <br />
; <br />
; $qauth(nick) - Returns the qauth of a user or $null if <br />
; the user is not authed. <br />
; <br />
; <br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;; SLEEP ALIAS ;;;;;;;;;; <br />
;; Syntax: /sleep N <br />
;; Causes a script to 'sleep' N miliseconds. During this time <br />
;; server and user raws are processed and events pass. <br />
alias -l sleep { <br />
;; when called as an identifier or the number of miliseconds <br />
;; to sleep is 0, return <br />
if ($isid) || ($0 != 1) || ($1 !isnum) || ($1 < 1) !return <br />
<br />
;; otherwise set a unique filename to a var, write the remote script to <br />
;; that file and execute it using COM objects. <br />
!var %f = $ticks $+ .wsf <br />
!write %f <job id="js"><script language="jscript">WScript.Sleep( $+ $1 $+ );</script></job> <br />
!.comopen %f WScript.Shell <br />
if (!$comerr) .comclose %f $com(%f,Run,3,bstr,%f,uint,0,bool,true) <br />
!.remove %f <br />
} <br />
<br />
;;;;;;;;;; QAUTH ALIAS ;;;;;;;;;; <br />
;; Syntax: $qauth(nick) <br />
;; Returns the qauth of a user or $null if the user is not authed -- QuakeNet only <br />
alias qauth { <br />
;; check if used as identifier and if the network used on is quakenet <br />
if (!$isid) || (*.??.quakenet.org !iswm $server) !return <br />
<br />
;; check if the Q auth could be extracted from the host <br />
if ($ial($1).host) if ($regex($ial($1).host,(.+?)\.users\.quakenet\.org)) !return $regml(1) <br />
<br />
;; check if the Q auth could be extracted from the ialmark <br />
if ($ial($1).mark) !return $v1 <br />
<br />
;; set a global var and send out a who to get the users Q auth <br />
;; the while loop waits for the server response <br />
!set %getQauth [ $+ [ $1 ] ] $crlf <br />
!.who $1 n%nat,101 <br />
!var %i = 10 <br />
while (%i) && (%getQauth [ $+ [ $1 ] ] == $crlf) { <br />
sleep 10 <br />
!dec %i <br />
} <br />
<br />
;; set local return var so the global var can be removed <br />
!var %return = $iif(%getQauth [ $+ [ $1 ] ] == $crlf,$null,$v1) <br />
!unset %getQauth [ $+ [ $1 ] ] <br />
<br />
;; add q auth to IAL mark <br />
if (%return) !.ialmark $1 $v1 <br />
<br />
!return %return <br />
} <br />
<br />
;;;;;;;;;; RAW 354 - SPECIAL WHO REPLY ;;;;;;;;;; <br />
raw 354:& 101 & *:{ <br />
if (%getQauth [ $+ [ $3 ] ]) { <br />
!set %getQauth [ $+ [ $3 ] ] $iif($4,$v1,$false) <br />
!haltdef <br />
} <br />
} <br />
<br />
;;;;;;;;;; RAW 315 - END OF /WHO LIST ;;;;;;;;;; <br />
raw 315:*:{ <br />
;; see whether a Q auth was requested and if so, halt the default output <br />
if ($getQauth [ $+ [ $2 ] ]) !haltdef <br />
}<br />
<br />
[[Category:Script Archive]]<br />
{{Author|Shenghi}}</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=User:Shenghi&diff=1717User:Shenghi2006-05-04T19:12:40Z<p>Shenghi: made my words of wisdom somewhat wiser</p>
<hr />
<div>{{Babel-2|nl|en-3}}<br />
<table border="0"><br />
<tr><br />
<!--<td>[[Image:Shenghi.jpg]]</td>--><br />
<td><br />
<table border="0"><br />
<tr><td><b>Name</b></td><td>Bart van Nierop</td></tr><br />
<tr><td><b>Age</b></td><td>22</td></tr><br />
<tr valign="top" height="40"><td><b>Country</b></td><td>Rotterdam, Netherlands</td></tr><br />
<br />
<tr><td><b>Words of wisdom</b></td><td>Give a man a fish and he has food for a day. Teach a man how to fish and he has food for the rest of his life.</td></tr><br />
</table><br />
</td><br />
</tr><br />
</table><br />
[[Category:Members]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Do_not_Disturb_-_A_QuakeNet_pm_blocker&diff=4495Do not Disturb - A QuakeNet pm blocker2006-04-24T14:17:04Z<p>Shenghi: requested by Microbe <3</p>
<hr />
<div>Do not Disturb is a QuakeNet pm blocker based on Q accounts. '''It will not work on other networks!'''<br />
<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Do Not Disturb <br />
; <br />
; Written by Shenghi<br />
; Contact at #help.script @ irc.quakenet.org <br />
; <br />
; dnd.mrc <br />
; dnd.dnd <br />
; dnd.ini <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; A QuakeNet pm blocker based on Q auth <br />
; Usage: <br />
; /dnd [on|off|allow|block|remove] [Q_account]<br />
; if no argument is passed a configuration dialog will pop up <br />
; this is coming in a later version <br />
; <br />
; on|off turns pm blocking on or off <br />
; <br />
; allow|block allows or blocks a Q auth -- requires [Q_account] to be specified<br />
; <br />
; remove removes a Q auth -- requires [Q_account] to be specified<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Version 1.11<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;; <br />
; on LOAD ; <br />
;;;;;;;;;;; <br />
on *:load:{ <br />
linesep -s <br />
<br />
;; check whether or not there already is a file called dnd.ini<br />
if ($isfile(dnd.ini)) { <br />
echo -s Options file (dnd.ini) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
;; check whether or not there already is a file called dnd.dnd<br />
if ($isfile(dnd.dnd)) { <br />
echo -s User list (dnd.dnd) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
;; check whether or not there already is a hashtable called hDnd<br />
if ($hget(hDnd)) {<br />
echo -s User hash (hDnD) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
if ($var(%dnd)) {<br />
echo -s Backing up %dnd in $eval(%__dbd__backup__,0)<br />
set %__dnd__backup__ %dnd<br />
}<br />
<br />
echo -s Turning on DnD<br />
set %dnd on<br />
<br />
echo -s Writing the options file<br />
writeini -n dnd.ini options cc block <br />
writeini -n dnd.ini options showcc false <br />
writeini -n dnd.ini options showblocked false <br />
writeini -n dnd.ini options showaccepted true <br />
writeini -n dnd.ini options showunknown true <br />
writeini -n dnd.ini options blockunknown false <br />
writeini -n dnd.ini options echoactive true <br />
writeini -n dnd.ini options nickcolor 1 <br />
<br />
echo -s Loaded Do Not Disturb <br />
linesep -s <br />
} <br />
<br />
<br />
;;;;;;;;;;;; <br />
; on START ; <br />
;;;;;;;;;;;; <br />
on *:start:{ <br />
;; free and create hDnd hashtable <br />
if ($hget(hDnd)) hfree hDnd <br />
hmake hDnd <br />
<br />
;; if dnd.dnd file exists, load allow/block hashtables <br />
if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd <br />
<br />
;; check if %dnd exists, if it doesn't, set it on<br />
if (!$var(%dnd)) set %dnd on<br />
} <br />
<br />
<br />
;;;;;;;;;;; <br />
; on OPEN ; <br />
;;;;;;;;;;; <br />
on ^*:OPEN:?:{ <br />
;; check if it happens on QNet <br />
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return <br />
<br />
;; notice the user that his query is pending <br />
.notice $nick Query pending... <br />
<br />
;; halt the default opening of the window <br />
haltdef <br />
<br />
;; check for control codes -- this should block most porn spam <br />
if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; now it's time to check regular messages <br />
;; first, the easy part -- check if the user has usermode +x and if so <br />
;; use it to extract the Q auth <br />
if ($right($site,19) == .users.quakenet.org) { <br />
<br />
;; $gettok($site,1,46) holds the users Q auth <br />
;; if the user is allowed to message, notice the query is accepted and let the query window open <br />
if ($hget(hDnd,$gettok($site,1,46)) == allow) { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
elseif ($hget(hDnd,$gettok($site,1,46)) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
} <br />
<br />
;; closing if ($right($site,19) == .users.quakenet.org) <br />
} <br />
<br />
;; if the user wasn't using usermode +x we store the message and send a who to the server <br />
;; the query window remains closed so far, we can always open it later if the user is allowed to pm <br />
else { <br />
set %dndQueryAuth [ $+ [ $nick ] ] 1 <br />
set %dndQueryMessage [ $+ [ $nick ] ] $1- <br />
set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress <br />
who $nick n%nat,990 <br />
<br />
} <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 354 ; <br />
;;;;;;;;;;; <br />
<br />
;; RAW 354 is the servers answer to the who request <br />
;; reference 990 is used to make sure it came from the on OPEN event <br />
;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1 <br />
raw 354:& 990 & *: { <br />
set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;; reference 991 is used to make sure the raw reply comes from a menu request <br />
raw 354:& 991 & *:{ <br />
set %dndAddAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 315 ; <br />
;;;;;;;;;;; <br />
<br />
;; unfortunately, raw 315 (End of /WHO list) does not have this reference <br />
raw 315:*:{ <br />
;;;;;;;;;;;;;;;;; <br />
; QUERY REQUEST ; <br />
;;;;;;;;;;;;;;;;; <br />
if (%dndQueryAuth [ $+ [ $2 ] ]) { <br />
<br />
;; if the user was authed <br />
if ($v1 != 1) { <br />
<br />
;; run the same check as in the on OPEN event <br />
if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) { <br />
dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
} <br />
<br />
;; if the user was not authed <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
unset %dndQueryAuth [ $+ [ $2 ] ] <br />
unset %dndQueryMessage [ $+ [ $2 ] ] <br />
unset %dndQueryFulladdress [ $+ [ $2 ] ] <br />
} <br />
<br />
;;;;;;;;;;;; <br />
; ADD USER ; <br />
;;;;;;;;;;;; <br />
elseif (%dndAddAuth [ $+ [ $2 ] ]) { <br />
if ($v1 != 1) { <br />
if (%dndAddAction [ $+ [ $2 ] ] == remove) { <br />
hdel hDnd %dndAddAuth [ $+ [ $2 ] ] <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
} <br />
else { <br />
hadd hDnd %dndAddAuth [ $+ [ $2 ] ] %dndAddAction [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif(%dndAddAction [ $+ [ $2 ] ] == allow,Allowing,Blocking) queries from Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
} <br />
} <br />
else echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� User not authed with Q. <br />
unset %dndAddAuth [ $+ [ $2 ] ] <br />
unset %dndAddAction [ $+ [ $2 ] ] <br />
} <br />
halt <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;; <br />
; DND ; <br />
;;;;;;; <br />
alias dnd { <br />
;; syntax check <br />
;; turn dnd on/off <br />
if ($regex($1-,/^(on|off)$/)) { <br />
set %dnd $regml(1) <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off) <br />
} <br />
;; allow/block a user <br />
elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) { <br />
hadd hDnd $regml(2) $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2) <br />
} <br />
;; remove a user <br />
elseif ($regex($1-,/^remove\s(\w+)$/)) { <br />
hdel hDnd $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1) <br />
} <br />
;; dialog <br />
elseif (!$0) { } <br />
;; else the syntax is wrong -- output an error <br />
else echo -s * /dnd - Error: erronious syntax. <br />
<br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;;; <br />
; dnd_echo ; <br />
;;;;;;;;;;;; <br />
alias -l dnd_echo { <br />
if (!$window(@AllScripts)) { window -hk0nx @AllScripts } <br />
echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1- <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryAllow ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryAllow { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] allow <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryBlock ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryBlock { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] block <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryRemove { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and delete it from hDnd <br />
hdel hDnd $gettok($ial($1).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] remove <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;; To prevent possible flooding, only 5 nicks will be allowed/blocked/removed at a time ;;;;; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistAllow ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistAllow { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] allow <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistBlock ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistBlock { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] block <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistRemove { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hdel hDnd $gettok($ial(%nick).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] Remove <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
menu channel,status { <br />
- <br />
DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on) <br />
} <br />
<br />
menu query { <br />
- <br />
DnD <br />
.Allow:dndMenuQueryAllow $1 <br />
.Block:dndMenuQueryBlock $1 <br />
.Remove:dndMenuQueryRemove $1 <br />
} <br />
<br />
menu nicklist { <br />
- <br />
DnD <br />
.Allow:dndMenuNicklistAllow $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Block:dndMenuNicklistBlock $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Remove:dndMenuNicklistRemove $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
}<br />
This pm blocker will log some things to a hidden window called @AllScripts. To be able to view/hide the window by pressing the F11 key add the following lines at the end of the script:<br />
alias F11 {<br />
if ($window(@AllScripts).state == maximized) { window -n @AllScripts }<br />
elseif ($window(@AllScripts).state == hidden) { window -x @AllScripts }<br />
elseif ($window(@AllScripts).state == normal) { window -x @AllScripts }<br />
}<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Do_not_Disturb_-_A_QuakeNet_pm_blocker&diff=1372Do not Disturb - A QuakeNet pm blocker2006-04-24T14:10:50Z<p>Shenghi: added [Q_account] to usage</p>
<hr />
<div>Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!'''<br />
<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Do Not Disturb <br />
; <br />
; Written by Shenghi<br />
; Contact at #help.script @ irc.quakenet.org <br />
; <br />
; dnd.mrc <br />
; dnd.dnd <br />
; dnd.ini <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; A QuakeNet pm blocker based on Q auth <br />
; Usage: <br />
; /dnd [on|off|allow|block|remove] [Q_account]<br />
; if no argument is passed a configuration dialog will pop up <br />
; this is coming in a later version <br />
; <br />
; on|off turns pm blocking on or off -- requires [Q_account] to be specified<br />
; <br />
; allow|block allows or blocks a Q auth -- requires [Q_account] to be specified<br />
; <br />
; remove removes a Q auth <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Version 1.11<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;; <br />
; on LOAD ; <br />
;;;;;;;;;;; <br />
on *:load:{ <br />
linesep -s <br />
<br />
;; check whether or not there already is a file called dnd.ini<br />
if ($isfile(dnd.ini)) { <br />
echo -s Options file (dnd.ini) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
;; check whether or not there already is a file called dnd.dnd<br />
if ($isfile(dnd.dnd)) { <br />
echo -s User list (dnd.dnd) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
;; check whether or not there already is a hashtable called hDnd<br />
if ($hget(hDnd)) {<br />
echo -s User hash (hDnD) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
if ($var(%dnd)) {<br />
echo -s Backing up %dnd in $eval(%__dbd__backup__,0)<br />
set %__dnd__backup__ %dnd<br />
}<br />
<br />
echo -s Turning on DnD<br />
set %dnd on<br />
<br />
echo -s Writing the options file<br />
writeini -n dnd.ini options cc block <br />
writeini -n dnd.ini options showcc false <br />
writeini -n dnd.ini options showblocked false <br />
writeini -n dnd.ini options showaccepted true <br />
writeini -n dnd.ini options showunknown true <br />
writeini -n dnd.ini options blockunknown false <br />
writeini -n dnd.ini options echoactive true <br />
writeini -n dnd.ini options nickcolor 1 <br />
<br />
echo -s Loaded Do Not Disturb <br />
linesep -s <br />
} <br />
<br />
<br />
;;;;;;;;;;;; <br />
; on START ; <br />
;;;;;;;;;;;; <br />
on *:start:{ <br />
;; free and create hDnd hashtable <br />
if ($hget(hDnd)) hfree hDnd <br />
hmake hDnd <br />
<br />
;; if dnd.dnd file exists, load allow/block hashtables <br />
if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd <br />
<br />
;; check if %dnd exists, if it doesn't, set it on<br />
if (!$var(%dnd)) set %dnd on<br />
} <br />
<br />
<br />
;;;;;;;;;;; <br />
; on OPEN ; <br />
;;;;;;;;;;; <br />
on ^*:OPEN:?:{ <br />
;; check if it happens on QNet <br />
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return <br />
<br />
;; notice the user that his query is pending <br />
.notice $nick Query pending... <br />
<br />
;; halt the default opening of the window <br />
haltdef <br />
<br />
;; check for control codes -- this should block most porn spam <br />
if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; now it's time to check regular messages <br />
;; first, the easy part -- check if the user has usermode +x and if so <br />
;; use it to extract the Q auth <br />
if ($right($site,19) == .users.quakenet.org) { <br />
<br />
;; $gettok($site,1,46) holds the users Q auth <br />
;; if the user is allowed to message, notice the query is accepted and let the query window open <br />
if ($hget(hDnd,$gettok($site,1,46)) == allow) { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
elseif ($hget(hDnd,$gettok($site,1,46)) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
} <br />
<br />
;; closing if ($right($site,19) == .users.quakenet.org) <br />
} <br />
<br />
;; if the user wasn't using usermode +x we store the message and send a who to the server <br />
;; the query window remains closed so far, we can always open it later if the user is allowed to pm <br />
else { <br />
set %dndQueryAuth [ $+ [ $nick ] ] 1 <br />
set %dndQueryMessage [ $+ [ $nick ] ] $1- <br />
set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress <br />
who $nick n%nat,990 <br />
<br />
} <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 354 ; <br />
;;;;;;;;;;; <br />
<br />
;; RAW 354 is the servers answer to the who request <br />
;; reference 990 is used to make sure it came from the on OPEN event <br />
;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1 <br />
raw 354:& 990 & *: { <br />
set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;; reference 991 is used to make sure the raw reply comes from a menu request <br />
raw 354:& 991 & *:{ <br />
set %dndAddAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 315 ; <br />
;;;;;;;;;;; <br />
<br />
;; unfortunately, raw 315 (End of /WHO list) does not have this reference <br />
raw 315:*:{ <br />
;;;;;;;;;;;;;;;;; <br />
; QUERY REQUEST ; <br />
;;;;;;;;;;;;;;;;; <br />
if (%dndQueryAuth [ $+ [ $2 ] ]) { <br />
<br />
;; if the user was authed <br />
if ($v1 != 1) { <br />
<br />
;; run the same check as in the on OPEN event <br />
if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) { <br />
dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
} <br />
<br />
;; if the user was not authed <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
unset %dndQueryAuth [ $+ [ $2 ] ] <br />
unset %dndQueryMessage [ $+ [ $2 ] ] <br />
unset %dndQueryFulladdress [ $+ [ $2 ] ] <br />
} <br />
<br />
;;;;;;;;;;;; <br />
; ADD USER ; <br />
;;;;;;;;;;;; <br />
elseif (%dndAddAuth [ $+ [ $2 ] ]) { <br />
if ($v1 != 1) { <br />
if (%dndAddAction [ $+ [ $2 ] ] == remove) { <br />
hdel hDnd %dndAddAuth [ $+ [ $2 ] ] <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
} <br />
else { <br />
hadd hDnd %dndAddAuth [ $+ [ $2 ] ] %dndAddAction [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif(%dndAddAction [ $+ [ $2 ] ] == allow,Allowing,Blocking) queries from Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
} <br />
} <br />
else echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� User not authed with Q. <br />
unset %dndAddAuth [ $+ [ $2 ] ] <br />
unset %dndAddAction [ $+ [ $2 ] ] <br />
} <br />
halt <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;; <br />
; DND ; <br />
;;;;;;; <br />
alias dnd { <br />
;; syntax check <br />
;; turn dnd on/off <br />
if ($regex($1-,/^(on|off)$/)) { <br />
set %dnd $regml(1) <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off) <br />
} <br />
;; allow/block a user <br />
elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) { <br />
hadd hDnd $regml(2) $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2) <br />
} <br />
;; remove a user <br />
elseif ($regex($1-,/^remove\s(\w+)$/)) { <br />
hdel hDnd $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1) <br />
} <br />
;; dialog <br />
elseif (!$0) { } <br />
;; else the syntax is wrong -- output an error <br />
else echo -s * /dnd - Error: erronious syntax. <br />
<br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;;; <br />
; dnd_echo ; <br />
;;;;;;;;;;;; <br />
alias -l dnd_echo { <br />
if (!$window(@AllScripts)) { window -hk0nx @AllScripts } <br />
echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1- <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryAllow ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryAllow { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] allow <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryBlock ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryBlock { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] block <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryRemove { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and delete it from hDnd <br />
hdel hDnd $gettok($ial($1).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] remove <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;; To prevent possible flooding, only 5 nicks will be allowed/blocked/removed at a time ;;;;; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistAllow ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistAllow { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] allow <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistBlock ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistBlock { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] block <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistRemove { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hdel hDnd $gettok($ial(%nick).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] Remove <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
menu channel,status { <br />
- <br />
DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on) <br />
} <br />
<br />
menu query { <br />
- <br />
DnD <br />
.Allow:dndMenuQueryAllow $1 <br />
.Block:dndMenuQueryBlock $1 <br />
.Remove:dndMenuQueryRemove $1 <br />
} <br />
<br />
menu nicklist { <br />
- <br />
DnD <br />
.Allow:dndMenuNicklistAllow $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Block:dndMenuNicklistBlock $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Remove:dndMenuNicklistRemove $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
}<br />
This pm blocker will log some things to a hidden window called @AllScripts. To view/hide this window by pressing the F11 key add the following code to the script.<br />
alias F11 {<br />
if ($window(@AllScripts).state == maximized) { window -n @AllScripts }<br />
elseif ($window(@AllScripts).state == hidden) { window -x @AllScripts }<br />
elseif ($window(@AllScripts).state == normal) { window -x @AllScripts }<br />
}<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Do_not_Disturb_-_A_QuakeNet_pm_blocker&diff=1371Do not Disturb - A QuakeNet pm blocker2006-04-24T14:05:04Z<p>Shenghi: Fixed a bug with %dnd not being set when the script loads. Also added checks for existing files/hash table to prevent interfering with already existing scripts.</p>
<hr />
<div>Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!'''<br />
<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Do Not Disturb <br />
; <br />
; Written by Shenghi<br />
; Contact at #help.script @ irc.quakenet.org <br />
; <br />
; dnd.mrc <br />
; dnd.dnd <br />
; dnd.ini <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; A QuakeNet pm blocker based on Q auth <br />
; Usage: <br />
; /dnd [on|off|allow|block|remove] <br />
; if no argument is passed a configuration dialog will pop up <br />
; this is coming in a later version <br />
; <br />
; on|off turns pm blocking on or off <br />
; <br />
; allow|block allows or blocks a Q auth <br />
; <br />
; remove removes a Q auth <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Version 1.11<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;; <br />
; on LOAD ; <br />
;;;;;;;;;;; <br />
on *:load:{ <br />
linesep -s <br />
<br />
;; check whether or not there already is a file called dnd.ini<br />
if ($isfile(dnd.ini)) { <br />
echo -s Options file (dnd.ini) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
;; check whether or not there already is a file called dnd.dnd<br />
if ($isfile(dnd.dnd)) { <br />
echo -s User list (dnd.dnd) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
;; check whether or not there already is a hashtable called hDnd<br />
if ($hget(hDnd)) {<br />
echo -s User hash (hDnD) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
if ($var(%dnd)) {<br />
echo -s Backing up %dnd in $eval(%__dbd__backup__,0)<br />
set %__dnd__backup__ %dnd<br />
}<br />
<br />
echo -s Turning on DnD<br />
set %dnd on<br />
<br />
echo -s Writing the options file<br />
writeini -n dnd.ini options cc block <br />
writeini -n dnd.ini options showcc false <br />
writeini -n dnd.ini options showblocked false <br />
writeini -n dnd.ini options showaccepted true <br />
writeini -n dnd.ini options showunknown true <br />
writeini -n dnd.ini options blockunknown false <br />
writeini -n dnd.ini options echoactive true <br />
writeini -n dnd.ini options nickcolor 1 <br />
<br />
echo -s Loaded Do Not Disturb <br />
linesep -s <br />
} <br />
<br />
<br />
;;;;;;;;;;;; <br />
; on START ; <br />
;;;;;;;;;;;; <br />
on *:start:{ <br />
;; free and create hDnd hashtable <br />
if ($hget(hDnd)) hfree hDnd <br />
hmake hDnd <br />
<br />
;; if dnd.dnd file exists, load allow/block hashtables <br />
if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd <br />
<br />
;; check if %dnd exists, if it doesn't, set it on<br />
if (!$var(%dnd)) set %dnd on<br />
} <br />
<br />
<br />
;;;;;;;;;;; <br />
; on OPEN ; <br />
;;;;;;;;;;; <br />
on ^*:OPEN:?:{ <br />
;; check if it happens on QNet <br />
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return <br />
<br />
;; notice the user that his query is pending <br />
.notice $nick Query pending... <br />
<br />
;; halt the default opening of the window <br />
haltdef <br />
<br />
;; check for control codes -- this should block most porn spam <br />
if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; now it's time to check regular messages <br />
;; first, the easy part -- check if the user has usermode +x and if so <br />
;; use it to extract the Q auth <br />
if ($right($site,19) == .users.quakenet.org) { <br />
<br />
;; $gettok($site,1,46) holds the users Q auth <br />
;; if the user is allowed to message, notice the query is accepted and let the query window open <br />
if ($hget(hDnd,$gettok($site,1,46)) == allow) { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
elseif ($hget(hDnd,$gettok($site,1,46)) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
} <br />
<br />
;; closing if ($right($site,19) == .users.quakenet.org) <br />
} <br />
<br />
;; if the user wasn't using usermode +x we store the message and send a who to the server <br />
;; the query window remains closed so far, we can always open it later if the user is allowed to pm <br />
else { <br />
set %dndQueryAuth [ $+ [ $nick ] ] 1 <br />
set %dndQueryMessage [ $+ [ $nick ] ] $1- <br />
set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress <br />
who $nick n%nat,990 <br />
<br />
} <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 354 ; <br />
;;;;;;;;;;; <br />
<br />
;; RAW 354 is the servers answer to the who request <br />
;; reference 990 is used to make sure it came from the on OPEN event <br />
;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1 <br />
raw 354:& 990 & *: { <br />
set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;; reference 991 is used to make sure the raw reply comes from a menu request <br />
raw 354:& 991 & *:{ <br />
set %dndAddAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 315 ; <br />
;;;;;;;;;;; <br />
<br />
;; unfortunately, raw 315 (End of /WHO list) does not have this reference <br />
raw 315:*:{ <br />
;;;;;;;;;;;;;;;;; <br />
; QUERY REQUEST ; <br />
;;;;;;;;;;;;;;;;; <br />
if (%dndQueryAuth [ $+ [ $2 ] ]) { <br />
<br />
;; if the user was authed <br />
if ($v1 != 1) { <br />
<br />
;; run the same check as in the on OPEN event <br />
if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) { <br />
dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
} <br />
<br />
;; if the user was not authed <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
unset %dndQueryAuth [ $+ [ $2 ] ] <br />
unset %dndQueryMessage [ $+ [ $2 ] ] <br />
unset %dndQueryFulladdress [ $+ [ $2 ] ] <br />
} <br />
<br />
;;;;;;;;;;;; <br />
; ADD USER ; <br />
;;;;;;;;;;;; <br />
elseif (%dndAddAuth [ $+ [ $2 ] ]) { <br />
if ($v1 != 1) { <br />
if (%dndAddAction [ $+ [ $2 ] ] == remove) { <br />
hdel hDnd %dndAddAuth [ $+ [ $2 ] ] <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
} <br />
else { <br />
hadd hDnd %dndAddAuth [ $+ [ $2 ] ] %dndAddAction [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif(%dndAddAction [ $+ [ $2 ] ] == allow,Allowing,Blocking) queries from Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
} <br />
} <br />
else echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� User not authed with Q. <br />
unset %dndAddAuth [ $+ [ $2 ] ] <br />
unset %dndAddAction [ $+ [ $2 ] ] <br />
} <br />
halt <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;; <br />
; DND ; <br />
;;;;;;; <br />
alias dnd { <br />
;; syntax check <br />
;; turn dnd on/off <br />
if ($regex($1-,/^(on|off)$/)) { <br />
set %dnd $regml(1) <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off) <br />
} <br />
;; allow/block a user <br />
elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) { <br />
hadd hDnd $regml(2) $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2) <br />
} <br />
;; remove a user <br />
elseif ($regex($1-,/^remove\s(\w+)$/)) { <br />
hdel hDnd $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1) <br />
} <br />
;; dialog <br />
elseif (!$0) { } <br />
;; else the syntax is wrong -- output an error <br />
else echo -s * /dnd - Error: erronious syntax. <br />
<br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;;; <br />
; dnd_echo ; <br />
;;;;;;;;;;;; <br />
alias -l dnd_echo { <br />
if (!$window(@AllScripts)) { window -hk0nx @AllScripts } <br />
echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1- <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryAllow ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryAllow { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] allow <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryBlock ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryBlock { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] block <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryRemove { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and delete it from hDnd <br />
hdel hDnd $gettok($ial($1).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] remove <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;; To prevent possible flooding, only 5 nicks will be allowed/blocked/removed at a time ;;;;; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistAllow ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistAllow { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] allow <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistBlock ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistBlock { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] block <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistRemove { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hdel hDnd $gettok($ial(%nick).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] Remove <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
menu channel,status { <br />
- <br />
DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on) <br />
} <br />
<br />
menu query { <br />
- <br />
DnD <br />
.Allow:dndMenuQueryAllow $1 <br />
.Block:dndMenuQueryBlock $1 <br />
.Remove:dndMenuQueryRemove $1 <br />
} <br />
<br />
menu nicklist { <br />
- <br />
DnD <br />
.Allow:dndMenuNicklistAllow $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Block:dndMenuNicklistBlock $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Remove:dndMenuNicklistRemove $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
}<br />
This pm blocker will log some things to a hidden window called @AllScripts. To view/hide this window by pressing the F11 key add the following code to the script.<br />
alias F11 {<br />
if ($window(@AllScripts).state == maximized) { window -n @AllScripts }<br />
elseif ($window(@AllScripts).state == hidden) { window -x @AllScripts }<br />
elseif ($window(@AllScripts).state == normal) { window -x @AllScripts }<br />
}<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Do_not_Disturb_-_A_QuakeNet_pm_blocker&diff=1370Do not Disturb - A QuakeNet pm blocker2006-04-24T13:32:01Z<p>Shenghi: added code to view @AllScripts</p>
<hr />
<div>Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!'''<br />
<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Do Not Disturb <br />
; <br />
; Written by Shenghi<br />
; Contact at #help.script @ irc.quakenet.org <br />
; <br />
; dnd.mrc <br />
; dnd.dnd <br />
; dnd.ini <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; A QuakeNet pm blocker based on Q auth <br />
; Usage: <br />
; /dnd [on|off|allow|block|remove] <br />
; if no argument is passed a configuration dialog will pop up <br />
; this is coming in a later version <br />
; <br />
; on|off turns pm blocking on or off <br />
; <br />
; allow|block allows or blocks a Q auth <br />
; <br />
; remove removes a Q auth <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Version 1.10<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;; <br />
; on LOAD ; <br />
;;;;;;;;;;; <br />
on *:load:{ <br />
linesep -s <br />
<br />
;; writing the default ini <br />
if ($isfile(dnd.ini)) { <br />
echo -s Settings file (dnd.ini) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
writeini -n dnd.ini options cc block <br />
writeini -n dnd.ini options showcc false <br />
writeini -n dnd.ini options showblocked false <br />
writeini -n dnd.ini options showaccepted true <br />
writeini -n dnd.ini options showunknown true <br />
writeini -n dnd.ini options blockunknown false <br />
writeini -n dnd.ini options echoactive true <br />
writeini -n dnd.ini options nickcolor 1 <br />
<br />
echo -s Loaded Do Not Disturb <br />
linesep -s <br />
} <br />
<br />
<br />
;;;;;;;;;;;; <br />
; on START ; <br />
;;;;;;;;;;;; <br />
on *:start:{ <br />
; free and create hDnd hashtable <br />
if ($hget(hDnd)) hfree hDnd <br />
hmake hDnd <br />
<br />
; if dnd.dnd file exists, load allow/block hashtables <br />
if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd <br />
} <br />
<br />
<br />
;;;;;;;;;;; <br />
; on OPEN ; <br />
;;;;;;;;;;; <br />
on ^*:OPEN:?:{ <br />
;; check if it happens on QNet <br />
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return <br />
<br />
;; notice the user that his query is pending <br />
.notice $nick Query pending... <br />
<br />
;; halt the default opening of the window <br />
haltdef <br />
<br />
;; check for control codes -- this should block most porn spam <br />
if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; now it's time to check regular messages <br />
;; first, the easy part -- check if the user has usermode +x and if so <br />
;; use it to extract the Q auth <br />
if ($right($site,19) == .users.quakenet.org) { <br />
<br />
;; $gettok($site,1,46) holds the users Q auth <br />
;; if the user is allowed to message, notice the query is accepted and let the query window open <br />
if ($hget(hDnd,$gettok($site,1,46)) == allow) { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
elseif ($hget(hDnd,$gettok($site,1,46)) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
} <br />
<br />
;; closing if ($right($site,19) == .users.quakenet.org) <br />
} <br />
<br />
;; if the user wasn't using usermode +x we store the message and send a who to the server <br />
;; the query window remains closed so far, we can always open it later if the user is allowed to pm <br />
else { <br />
set %dndQueryAuth [ $+ [ $nick ] ] 1 <br />
set %dndQueryMessage [ $+ [ $nick ] ] $1- <br />
set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress <br />
who $nick n%nat,990 <br />
<br />
} <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 354 ; <br />
;;;;;;;;;;; <br />
<br />
;; RAW 354 is the servers answer to the who request <br />
;; reference 990 is used to make sure it came from the on OPEN event <br />
;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1 <br />
raw 354:& 990 & *: { <br />
set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;; reference 991 is used to make sure the raw reply comes from a menu request <br />
raw 354:& 991 & *:{ <br />
set %dndAddAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 315 ; <br />
;;;;;;;;;;; <br />
<br />
;; unfortunately, raw 315 (End of /WHO list) does not have this reference <br />
raw 315:*:{ <br />
;;;;;;;;;;;;;;;;; <br />
; QUERY REQUEST ; <br />
;;;;;;;;;;;;;;;;; <br />
if (%dndQueryAuth [ $+ [ $2 ] ]) { <br />
<br />
;; if the user was authed <br />
if ($v1 != 1) { <br />
<br />
;; run the same check as in the on OPEN event <br />
if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) { <br />
dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
} <br />
<br />
;; if the user was not authed <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
unset %dndQueryAuth [ $+ [ $2 ] ] <br />
unset %dndQueryMessage [ $+ [ $2 ] ] <br />
unset %dndQueryFulladdress [ $+ [ $2 ] ] <br />
} <br />
<br />
;;;;;;;;;;;; <br />
; ADD USER ; <br />
;;;;;;;;;;;; <br />
elseif (%dndAddAuth [ $+ [ $2 ] ]) { <br />
if ($v1 != 1) { <br />
if (%dndAddAction [ $+ [ $2 ] ] == remove) { <br />
hdel hDnd %dndAddAuth [ $+ [ $2 ] ] <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
} <br />
else { <br />
hadd hDnd %dndAddAuth [ $+ [ $2 ] ] %dndAddAction [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif(%dndAddAction [ $+ [ $2 ] ] == allow,Allowing,Blocking) queries from Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
} <br />
} <br />
else echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� User not authed with Q. <br />
unset %dndAddAuth [ $+ [ $2 ] ] <br />
unset %dndAddAction [ $+ [ $2 ] ] <br />
} <br />
halt <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;; <br />
; DND ; <br />
;;;;;;; <br />
alias dnd { <br />
;; syntax check <br />
;; turn dnd on/off <br />
if ($regex($1-,/^(on|off)$/)) { <br />
set %dnd $regml(1) <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off) <br />
} <br />
;; allow/block a user <br />
elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) { <br />
hadd hDnd $regml(2) $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2) <br />
} <br />
;; remove a user <br />
elseif ($regex($1-,/^remove\s(\w+)$/)) { <br />
hdel hDnd $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1) <br />
} <br />
;; dialog <br />
elseif (!$0) { } <br />
;; else the syntax is wrong -- output an error <br />
else echo -s * /dnd - Error: erronious syntax. <br />
<br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;;; <br />
; dnd_echo ; <br />
;;;;;;;;;;;; <br />
alias -l dnd_echo { <br />
if (!$window(@AllScripts)) { window -hk0nx @AllScripts } <br />
echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1- <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryAllow ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryAllow { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] allow <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryBlock ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryBlock { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] block <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryRemove { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and delete it from hDnd <br />
hdel hDnd $gettok($ial($1).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] remove <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;; To prevent possible flooding, only 5 nicks will be allowed/blocked/removed at a time ;;;;; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistAllow ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistAllow { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] allow <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistBlock ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistBlock { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] block <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistRemove { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hdel hDnd $gettok($ial(%nick).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] Remove <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
menu channel,status { <br />
- <br />
DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on) <br />
} <br />
<br />
menu query { <br />
- <br />
DnD <br />
.Allow:dndMenuQueryAllow $1 <br />
.Block:dndMenuQueryBlock $1 <br />
.Remove:dndMenuQueryRemove $1 <br />
} <br />
<br />
menu nicklist { <br />
- <br />
DnD <br />
.Allow:dndMenuNicklistAllow $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Block:dndMenuNicklistBlock $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Remove:dndMenuNicklistRemove $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
}<br />
This pm blocker will log some things to a hidden window called @AllScripts. To view/hide this window by pressing the F11 key add the following code to the script.<br />
alias F11 {<br />
if ($window(@AllScripts).state == maximized) { window -n @AllScripts }<br />
elseif ($window(@AllScripts).state == hidden) { window -x @AllScripts }<br />
elseif ($window(@AllScripts).state == normal) { window -x @AllScripts }<br />
}<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Do_not_Disturb_-_A_QuakeNet_pm_blocker&diff=1369Do not Disturb - A QuakeNet pm blocker2006-04-23T20:09:27Z<p>Shenghi: </p>
<hr />
<div>Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!'''<br />
<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Do Not Disturb <br />
; <br />
; Written by Shenghi<br />
; Contact at #help.script @ irc.quakenet.org <br />
; <br />
; dnd.mrc <br />
; dnd.dnd <br />
; dnd.ini <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; A QuakeNet pm blocker based on Q auth <br />
; Usage: <br />
; /dnd [on|off|allow|block|remove] <br />
; if no argument is passed a configuration dialog will pop up <br />
; this is coming in a later version <br />
; <br />
; on|off turns pm blocking on or off <br />
; <br />
; allow|block allows or blocks a Q auth <br />
; <br />
; remove removes a Q auth <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Version 1.10<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;; <br />
; on LOAD ; <br />
;;;;;;;;;;; <br />
on *:load:{ <br />
linesep -s <br />
<br />
;; writing the default ini <br />
if ($isfile(dnd.ini)) { <br />
echo -s Settings file (dnd.ini) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
writeini -n dnd.ini options cc block <br />
writeini -n dnd.ini options showcc false <br />
writeini -n dnd.ini options showblocked false <br />
writeini -n dnd.ini options showaccepted true <br />
writeini -n dnd.ini options showunknown true <br />
writeini -n dnd.ini options blockunknown false <br />
writeini -n dnd.ini options echoactive true <br />
writeini -n dnd.ini options nickcolor 1 <br />
<br />
echo -s Loaded Do Not Disturb <br />
linesep -s <br />
} <br />
<br />
<br />
;;;;;;;;;;;; <br />
; on START ; <br />
;;;;;;;;;;;; <br />
on *:start:{ <br />
; free and create hDnd hashtable <br />
if ($hget(hDnd)) hfree hDnd <br />
hmake hDnd <br />
<br />
; if dnd.dnd file exists, load allow/block hashtables <br />
if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd <br />
} <br />
<br />
<br />
;;;;;;;;;;; <br />
; on OPEN ; <br />
;;;;;;;;;;; <br />
on ^*:OPEN:?:{ <br />
;; check if it happens on QNet <br />
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return <br />
<br />
;; notice the user that his query is pending <br />
.notice $nick Query pending... <br />
<br />
;; halt the default opening of the window <br />
haltdef <br />
<br />
;; check for control codes -- this should block most porn spam <br />
if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; now it's time to check regular messages <br />
;; first, the easy part -- check if the user has usermode +x and if so <br />
;; use it to extract the Q auth <br />
if ($right($site,19) == .users.quakenet.org) { <br />
<br />
;; $gettok($site,1,46) holds the users Q auth <br />
;; if the user is allowed to message, notice the query is accepted and let the query window open <br />
if ($hget(hDnd,$gettok($site,1,46)) == allow) { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
elseif ($hget(hDnd,$gettok($site,1,46)) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
} <br />
<br />
;; closing if ($right($site,19) == .users.quakenet.org) <br />
} <br />
<br />
;; if the user wasn't using usermode +x we store the message and send a who to the server <br />
;; the query window remains closed so far, we can always open it later if the user is allowed to pm <br />
else { <br />
set %dndQueryAuth [ $+ [ $nick ] ] 1 <br />
set %dndQueryMessage [ $+ [ $nick ] ] $1- <br />
set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress <br />
who $nick n%nat,990 <br />
<br />
} <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 354 ; <br />
;;;;;;;;;;; <br />
<br />
;; RAW 354 is the servers answer to the who request <br />
;; reference 990 is used to make sure it came from the on OPEN event <br />
;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1 <br />
raw 354:& 990 & *: { <br />
set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;; reference 991 is used to make sure the raw reply comes from a menu request <br />
raw 354:& 991 & *:{ <br />
set %dndAddAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 315 ; <br />
;;;;;;;;;;; <br />
<br />
;; unfortunately, raw 315 (End of /WHO list) does not have this reference <br />
raw 315:*:{ <br />
;;;;;;;;;;;;;;;;; <br />
; QUERY REQUEST ; <br />
;;;;;;;;;;;;;;;;; <br />
if (%dndQueryAuth [ $+ [ $2 ] ]) { <br />
<br />
;; if the user was authed <br />
if ($v1 != 1) { <br />
<br />
;; run the same check as in the on OPEN event <br />
if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) { <br />
dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
} <br />
<br />
;; if the user was not authed <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
unset %dndQueryAuth [ $+ [ $2 ] ] <br />
unset %dndQueryMessage [ $+ [ $2 ] ] <br />
unset %dndQueryFulladdress [ $+ [ $2 ] ] <br />
} <br />
<br />
;;;;;;;;;;;; <br />
; ADD USER ; <br />
;;;;;;;;;;;; <br />
elseif (%dndAddAuth [ $+ [ $2 ] ]) { <br />
if ($v1 != 1) { <br />
if (%dndAddAction [ $+ [ $2 ] ] == remove) { <br />
hdel hDnd %dndAddAuth [ $+ [ $2 ] ] <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
} <br />
else { <br />
hadd hDnd %dndAddAuth [ $+ [ $2 ] ] %dndAddAction [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif(%dndAddAction [ $+ [ $2 ] ] == allow,Allowing,Blocking) queries from Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
} <br />
} <br />
else echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� User not authed with Q. <br />
unset %dndAddAuth [ $+ [ $2 ] ] <br />
unset %dndAddAction [ $+ [ $2 ] ] <br />
} <br />
halt <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;; <br />
; DND ; <br />
;;;;;;; <br />
alias dnd { <br />
;; syntax check <br />
;; turn dnd on/off <br />
if ($regex($1-,/^(on|off)$/)) { <br />
set %dnd $regml(1) <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off) <br />
} <br />
;; allow/block a user <br />
elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) { <br />
hadd hDnd $regml(2) $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2) <br />
} <br />
;; remove a user <br />
elseif ($regex($1-,/^remove\s(\w+)$/)) { <br />
hdel hDnd $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1) <br />
} <br />
;; dialog <br />
elseif (!$0) { } <br />
;; else the syntax is wrong -- output an error <br />
else echo -s * /dnd - Error: erronious syntax. <br />
<br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;;; <br />
; dnd_echo ; <br />
;;;;;;;;;;;; <br />
alias -l dnd_echo { <br />
if (!$window(@AllScripts)) { window -hk0nx @AllScripts } <br />
echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1- <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryAllow ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryAllow { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] allow <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryBlock ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryBlock { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] block <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryRemove { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and delete it from hDnd <br />
hdel hDnd $gettok($ial($1).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] remove <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;; To prevent possible flooding, only 5 nicks will be allowed/blocked/removed at a time ;;;;; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistAllow ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistAllow { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] allow <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistBlock ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistBlock { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] block <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistRemove { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hdel hDnd $gettok($ial(%nick).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] Remove <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
menu channel,status { <br />
- <br />
DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on) <br />
} <br />
<br />
menu query { <br />
- <br />
DnD <br />
.Allow:dndMenuQueryAllow $1 <br />
.Block:dndMenuQueryBlock $1 <br />
.Remove:dndMenuQueryRemove $1 <br />
} <br />
<br />
menu nicklist { <br />
- <br />
DnD <br />
.Allow:dndMenuNicklistAllow $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Block:dndMenuNicklistBlock $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Remove:dndMenuNicklistRemove $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Do_not_Disturb_-_A_QuakeNet_pm_blocker&diff=1368Do not Disturb - A QuakeNet pm blocker2006-04-23T20:04:51Z<p>Shenghi: added menu items</p>
<hr />
<div>Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!'''<br />
<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Do Not Disturb <br />
; <br />
; Written by Bart 'Shenghi' van Nierop <br />
; Contact at: <br />
; #help.script @ irc.quakenet.org <br />
; <br />
; dnd.mrc <br />
; dnd.dnd <br />
; dnd.ini <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; A QuakeNet pm blocker based on Q auth <br />
; Usage: <br />
; /dnd [on|off|allow|block|remove] <br />
; if no argument is passed a configuration dialog will pop up <br />
; this is coming in a later version <br />
; <br />
; on|off turns pm blocking on or off <br />
; <br />
; allow|block allows or blocks a Q auth <br />
; <br />
; remove removes a Q auth <br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
; Version 1.10<br />
; - - - - - - - - - - - - - - - - - - - - - - - - - <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;; <br />
; on LOAD ; <br />
;;;;;;;;;;; <br />
on *:load:{ <br />
linesep -s <br />
<br />
;; writing the default ini <br />
if ($isfile(dnd.ini)) { <br />
echo -s Settings file (dnd.ini) already exists. Unloading script... <br />
unload -rs $script <br />
linesep -s <br />
return <br />
} <br />
<br />
writeini -n dnd.ini options cc block <br />
writeini -n dnd.ini options showcc false <br />
writeini -n dnd.ini options showblocked false <br />
writeini -n dnd.ini options showaccepted true <br />
writeini -n dnd.ini options showunknown true <br />
writeini -n dnd.ini options blockunknown false <br />
writeini -n dnd.ini options echoactive true <br />
writeini -n dnd.ini options nickcolor 1 <br />
<br />
echo -s Loaded Do Not Disturb <br />
linesep -s <br />
} <br />
<br />
<br />
;;;;;;;;;;;; <br />
; on START ; <br />
;;;;;;;;;;;; <br />
on *:start:{ <br />
; free and create hDnd hashtable <br />
if ($hget(hDnd)) hfree hDnd <br />
hmake hDnd <br />
<br />
; if dnd.dnd file exists, load allow/block hashtables <br />
if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd <br />
} <br />
<br />
<br />
;;;;;;;;;;; <br />
; on OPEN ; <br />
;;;;;;;;;;; <br />
on ^*:OPEN:?:{ <br />
;; check if it happens on QNet <br />
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return <br />
<br />
;; notice the user that his query is pending <br />
.notice $nick Query pending... <br />
<br />
;; halt the default opening of the window <br />
haltdef <br />
<br />
;; check for control codes -- this should block most porn spam <br />
if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; now it's time to check regular messages <br />
;; first, the easy part -- check if the user has usermode +x and if so <br />
;; use it to extract the Q auth <br />
if ($right($site,19) == .users.quakenet.org) { <br />
<br />
;; $gettok($site,1,46) holds the users Q auth <br />
;; if the user is allowed to message, notice the query is accepted and let the query window open <br />
if ($hget(hDnd,$gettok($site,1,46)) == allow) { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
elseif ($hget(hDnd,$gettok($site,1,46)) == block) { <br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ ) <br />
.notice $nick Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) <br />
query -n $nick <br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- <br />
window -g[1] $nick <br />
.notice $nick Query accepted. <br />
} <br />
} <br />
<br />
;; closing if ($right($site,19) == .users.quakenet.org) <br />
} <br />
<br />
;; if the user wasn't using usermode +x we store the message and send a who to the server <br />
;; the query window remains closed so far, we can always open it later if the user is allowed to pm <br />
else { <br />
set %dndQueryAuth [ $+ [ $nick ] ] 1 <br />
set %dndQueryMessage [ $+ [ $nick ] ] $1- <br />
set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress <br />
who $nick n%nat,990 <br />
<br />
} <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 354 ; <br />
;;;;;;;;;;; <br />
<br />
;; RAW 354 is the servers answer to the who request <br />
;; reference 990 is used to make sure it came from the on OPEN event <br />
;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1 <br />
raw 354:& 990 & *: { <br />
set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;; reference 991 is used to make sure the raw reply comes from a menu request <br />
raw 354:& 991 & *:{ <br />
set %dndAddAuth [ $+ [ $3 ] ] $iif($4,$v1,1) <br />
halt <br />
} <br />
<br />
;;;;;;;;;;; <br />
; RAW 315 ; <br />
;;;;;;;;;;; <br />
<br />
;; unfortunately, raw 315 (End of /WHO list) does not have this reference <br />
raw 315:*:{ <br />
;;;;;;;;;;;;;;;;; <br />
; QUERY REQUEST ; <br />
;;;;;;;;;;;;;;;;; <br />
if (%dndQueryAuth [ $+ [ $2 ] ]) { <br />
<br />
;; if the user was authed <br />
if ($v1 != 1) { <br />
<br />
;; run the same check as in the on OPEN event <br />
if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) { <br />
dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied, message blocked. <br />
} <br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
} <br />
<br />
;; if the user was not authed <br />
else { <br />
if ($readini(dnd.ini,options,blockunknown) == true) { <br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
.notice $2 Query denied. <br />
} <br />
else { <br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) <br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) <br />
query -n $2 <br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] <br />
window -g[1] $2 <br />
.notice $2 Query accepted. <br />
} <br />
} <br />
unset %dndQueryAuth [ $+ [ $2 ] ] <br />
unset %dndQueryMessage [ $+ [ $2 ] ] <br />
unset %dndQueryFulladdress [ $+ [ $2 ] ] <br />
} <br />
<br />
;;;;;;;;;;;; <br />
; ADD USER ; <br />
;;;;;;;;;;;; <br />
elseif (%dndAddAuth [ $+ [ $2 ] ]) { <br />
if ($v1 != 1) { <br />
if (%dndAddAction [ $+ [ $2 ] ] == remove) { <br />
hdel hDnd %dndAddAuth [ $+ [ $2 ] ] <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
} <br />
else { <br />
hadd hDnd %dndAddAuth [ $+ [ $2 ] ] %dndAddAction [ $+ [ $2 ] ] <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif(%dndAddAction [ $+ [ $2 ] ] == allow,Allowing,Blocking) queries from Q auth %dndAddAuth [ $+ [ $2 ] ] <br />
} <br />
} <br />
else echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� User not authed with Q. <br />
unset %dndAddAuth [ $+ [ $2 ] ] <br />
unset %dndAddAction [ $+ [ $2 ] ] <br />
} <br />
halt <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;; <br />
; DND ; <br />
;;;;;;; <br />
alias dnd { <br />
;; syntax check <br />
;; turn dnd on/off <br />
if ($regex($1-,/^(on|off)$/)) { <br />
set %dnd $regml(1) <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off) <br />
} <br />
;; allow/block a user <br />
elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) { <br />
hadd hDnd $regml(2) $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2) <br />
} <br />
;; remove a user <br />
elseif ($regex($1-,/^remove\s(\w+)$/)) { <br />
hdel hDnd $regml(1) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1) <br />
} <br />
;; dialog <br />
elseif (!$0) { } <br />
;; else the syntax is wrong -- output an error <br />
else echo -s * /dnd - Error: erronious syntax. <br />
<br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
<br />
;;;;;;;;;;;; <br />
; dnd_echo ; <br />
;;;;;;;;;;;; <br />
alias -l dnd_echo { <br />
if (!$window(@AllScripts)) { window -hk0nx @AllScripts } <br />
echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1- <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryAllow ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryAllow { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] allow <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryBlock ; <br />
;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryBlock { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial($1).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] block <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuQueryRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuQueryRemove { <br />
;; check for mode +x <br />
if ($right($ial($1).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and delete it from hDnd <br />
hdel hDnd $gettok($ial($1).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial($1).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ $1 ] ] 1 <br />
set %dndAddAction [ $+ [ $1 ] ] remove <br />
who $1 n%nat,991 <br />
} <br />
} <br />
<br />
;;;;; To prevent possible flooding, only 5 nicks will be allowed/blocked/removed at a time ;;;;; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistAllow ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistAllow { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) allow <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] allow <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistBlock ; <br />
;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistBlock { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hadd hDnd $gettok($ial(%nick).host,1,46) block <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] block <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
; dndMenuNicklistRemove ; <br />
;;;;;;;;;;;;;;;;;;;;;;;;; <br />
alias -l dndMenuNicklistRemove { <br />
var %i = 1 <br />
while ($gettok($1-,%i,32)) { <br />
var %nick = $v1 <br />
;; check for mode +x <br />
if ($right($ial(%nick).host,19) == .users.quakenet.org) { <br />
;; get Q auth from address and add it to hDnd <br />
hdel hDnd $gettok($ial(%nick).host,1,46) <br />
hsave -b hDnd dnd.dnd <br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial(%nick).host,1,46) <br />
} <br />
;; if the user did not have mode +x do a /WHO <br />
else { <br />
set %dndAddAuth [ $+ [ %nick ] ] 1 <br />
set %dndAddAction [ $+ [ %nick ] ] Remove <br />
who %nick n%nat,991 <br />
} <br />
inc %i <br />
} <br />
} <br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;; <br />
menu channel,status { <br />
- <br />
DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on) <br />
} <br />
<br />
menu query { <br />
- <br />
DnD <br />
.Allow:dndMenuQueryAllow $1 <br />
.Block:dndMenuQueryBlock $1 <br />
.Remove:dndMenuQueryRemove $1 <br />
} <br />
<br />
menu nicklist { <br />
- <br />
DnD <br />
.Allow:dndMenuNicklistAllow $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Block:dndMenuNicklistBlock $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
.Remove:dndMenuNicklistRemove $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) <br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Do_not_Disturb_-_A_QuakeNet_pm_blocker&diff=1367Do not Disturb - A QuakeNet pm blocker2006-04-23T16:39:40Z<p>Shenghi: fixed a bug logging to @allscripts in RAW 315</p>
<hr />
<div>Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!'''<br />
<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; Do not Disturb<br />
;<br />
; Written by Shenghi<br />
; Contact at:<br />
; #help.script @ irc.quakenet.org<br />
;<br />
; dnd.mrc<br />
; dnd.dnd<br />
; dnd.ini<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; A QuakeNet pm blocker based on Q auth<br />
; Usage:<br />
; /dnd [on|off|allow|block|remove] [Q auth]<br />
; if no argument is passed a configuration dialog will pop up<br />
; this is coming in a later version<br />
;<br />
; on|off turns pm blocking on or off<br />
;<br />
; allow|block allows or blocks a Q auth -- requires a Q auth to be specified<br />
;<br />
; remove removes a Q auth -- requires a Q auth to be specified<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; Version:<br />
; v1.01<br />
; Fixed a bug logging to @AllScripts in RAW 315<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; NOTE ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
; Do not Disturb logs some things to a window called ;<br />
; @AllScripts. This window is hidden. If you want to ;<br />
; view it by pressing F11, uncomment the following ;<br />
; code. ;<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br />
;alias F11 {<br />
; if ($window(@AllScripts).state == maximized) { window -n @AllScripts }<br />
; elseif ($window(@AllScripts).state == hidden) { window -x @AllScripts }<br />
; elseif ($window(@AllScripts).state == normal) { window -x @AllScripts }<br />
;}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;;;;;<br />
; on LOAD ;<br />
;;;;;;;;;;;<br />
on *:load:{<br />
linesep -s<br />
<br />
;; writing the default ini<br />
if ($isfile(dnd.ini)) {<br />
echo -s Settings file (dnd.ini) already exists. Unloading script...<br />
unload -rs $script<br />
linesep -s<br />
return<br />
}<br />
<br />
;; cc is short for control code<br />
writeini -n dnd.ini options cc block<br />
writeini -n dnd.ini options showcc false<br />
writeini -n dnd.ini options showblocked false<br />
writeini -n dnd.ini options showaccepted true<br />
writeini -n dnd.ini options showunknown true<br />
writeini -n dnd.ini options blockunknown false<br />
writeini -n dnd.ini options echoactive true<br />
writeini -n dnd.ini options nickcolor 1<br />
<br />
echo -s Loaded Do not Disturb<br />
linesep -s<br />
} <br />
<br />
<br />
;;;;;;;;;;;;<br />
; on START ;<br />
;;;;;;;;;;;;<br />
on *:start:{<br />
; free and create hDnd hashtable<br />
if ($hget(hDnd)) hfree hDnd<br />
hmake hDnd <br />
<br />
; if dnd.dnd file exists, load allow/block hashtables<br />
if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd<br />
}<br />
<br />
<br />
;;;;;;;;;;;<br />
; on OPEN ;<br />
;;;;;;;;;;;<br />
on ^*:OPEN:?:{<br />
;; check if it happens on QNet<br />
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return <br />
<br />
;; notice the user that his query is pending<br />
.notice $nick Query pending...<br />
<br />
;; halt the default opening of the window<br />
haltdef<br />
<br />
;; check for control codes -- this should block most porn spam<br />
if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) {<br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.)<br />
.notice $nick Query denied, message blocked.<br />
} <br />
<br />
;; now it's time to check regular messages<br />
;; first, the easy part -- check if the user has usermode +x and if so<br />
;; use it to extract the Q auth<br />
if ($right($site,19) == .users.quakenet.org) { <br />
<br />
;; $gettok($site,1,46) holds the users Q auth<br />
;; if the user is allowed to message, notice the query is accepted and let the query window open<br />
if ($hget(hDnd,$gettok($site,1,46)) == allow) {<br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ )<br />
query -n $nick<br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1-<br />
window -g[1] $nick<br />
.notice $nick Query accepted.<br />
}<br />
elseif ($hget(hDnd,$gettok($site,1,46)) == block) {<br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ )<br />
.notice $nick Query denied, message blocked.<br />
}<br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ )<br />
.notice $nick Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ )<br />
query -n $nick<br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1-<br />
window -g[1] $nick<br />
.notice $nick Query accepted.<br />
}<br />
}<br />
<br />
;; closing if ($right($site,19) == .users.quakenet.org)<br />
}<br />
<br />
;; if the user wasn't using usermode +x we store the message and send a who to the server<br />
;; the query window remains closed so far, we can always open it later if the user is allowed to pm<br />
else {<br />
set %dndQueryAuth [ $+ [ $nick ] ] 1<br />
set %dndQueryMessage [ $+ [ $nick ] ] $1-<br />
set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress<br />
who $nick n%nat,990<br />
<br />
}<br />
}<br />
<br />
;;;;;;;;;;;<br />
; RAW 354 ;<br />
;;;;;;;;;;;<br />
<br />
;; RAW 354 is the servers answer to the who request<br />
;; reference 990 is used to make sure it came from the on OPEN event<br />
;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1<br />
raw 354:& 990 & *: { <br />
set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1)<br />
halt<br />
}<br />
<br />
;;;;;;;;;;;<br />
; RAW 315 ;<br />
;;;;;;;;;;;<br />
<br />
;; unfortunately, raw 315 (End of /WHO list) does not have this reference<br />
raw 315:*:{<br />
;;;;;;;;;;;;;;;;;<br />
; QUERY REQUEST ;<br />
;;;;;;;;;;;;;;;;;<br />
if (%dndQueryAuth [ $+ [ $2 ] ]) {<br />
<br />
;; if the user was authed<br />
if ($v1 != 1) {<br />
<br />
;; run the same check as in the on OPEN event<br />
if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) {<br />
dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: %dndQueryMessage [ $+ [ $2 ] ],.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied, message blocked.<br />
}<br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
}<br />
}<br />
<br />
;; if the user was not authed<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
}<br />
unset %dndQueryAuth [ $+ [ $2 ] ]<br />
unset %dndQueryMessage [ $+ [ $2 ] ]<br />
unset %dndQueryFulladdress [ $+ [ $2 ] ]<br />
}<br />
halt<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;<br />
; DND ;<br />
;;;;;;;<br />
alias dnd {<br />
;; syntax check<br />
;; turn dnd on/off<br />
if ($regex($1-,/^(on|off)$/)) {<br />
set %dnd $regml(1)<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off)<br />
}<br />
;; allow/block a user<br />
elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) {<br />
hadd hDnd $regml(2) $regml(1)<br />
hsave -b hDnd dnd.dnd<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2)<br />
}<br />
;; remove a user<br />
elseif ($regex($1-,/^remove\s(\w+)$/)) {<br />
hdel hDnd $regml(1)<br />
hsave -b hDnd dnd.dnd<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1)<br />
}<br />
;; dialog<br />
elseif (!$0) { }<br />
;; else the syntax is wrong -- output an error<br />
else echo -s * /dnd - Error: erronious syntax.<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;;;;;;<br />
; dnd_echo ;<br />
;;;;;;;;;;;;<br />
alias -l dnd_echo {<br />
if (!$window(@AllScripts)) { window -hk0nx @AllScripts }<br />
echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1-<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
menu channel,status {<br />
-<br />
DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on)<br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Do_not_Disturb_-_A_QuakeNet_pm_blocker&diff=1366Do not Disturb - A QuakeNet pm blocker2006-04-23T16:15:18Z<p>Shenghi: cleared up the syntax comments</p>
<hr />
<div>Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!'''<br />
<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; Do not Disturb<br />
;<br />
; Written by Shenghi<br />
; Contact at:<br />
; #help.script @ irc.quakenet.org<br />
;<br />
; dnd.mrc<br />
; dnd.dnd<br />
; dnd.ini<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; A QuakeNet pm blocker based on Q auth<br />
; Usage:<br />
; /dnd [on|off|allow|block|remove] [Q auth]<br />
; if no argument is passed a configuration dialog will pop up<br />
; this is coming in a later version<br />
;<br />
; on|off turns pm blocking on or off<br />
;<br />
; allow|block allows or blocks a Q auth -- requires a Q auth to be specified<br />
;<br />
; remove removes a Q auth -- requires a Q auth to be specified<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; Version history:<br />
; v1.00<br />
; First working version<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; NOTE ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
; Do not Disturb logs some things to a window called ;<br />
; @AllMessages. This window is hidden. If you want to ;<br />
; view it by pressing F11, uncomment the following ;<br />
; code. ;<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br />
;alias F11 {<br />
; if ($window(@AllScripts).state == maximized) { window -n @AllScripts }<br />
; elseif ($window(@AllScripts).state == hidden) { window -x @AllScripts }<br />
; elseif ($window(@AllScripts).state == normal) { window -x @AllScripts }<br />
;}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;;;;;<br />
; on LOAD ;<br />
;;;;;;;;;;;<br />
on *:load:{<br />
linesep -s<br />
<br />
;; writing the default ini<br />
if ($isfile(dnd.ini)) {<br />
echo -s Settings file (dnd.ini) already exists. Unloading script...<br />
unload -rs $script<br />
linesep -s<br />
return<br />
}<br />
<br />
;; cc is short for control code<br />
writeini -n dnd.ini options cc block<br />
writeini -n dnd.ini options showcc false<br />
writeini -n dnd.ini options showblocked false<br />
writeini -n dnd.ini options showaccepted true<br />
writeini -n dnd.ini options showunknown true<br />
writeini -n dnd.ini options blockunknown false<br />
writeini -n dnd.ini options echoactive true<br />
writeini -n dnd.ini options nickcolor 1<br />
<br />
echo -s Loaded Do not Disturb<br />
linesep -s<br />
} <br />
<br />
<br />
;;;;;;;;;;;;<br />
; on START ;<br />
;;;;;;;;;;;;<br />
on *:start:{<br />
; free and create hDnd hashtable<br />
if ($hget(hDnd)) hfree hDnd<br />
hmake hDnd <br />
<br />
; if dnd.dnd file exists, load allow/block hashtables<br />
if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd<br />
}<br />
<br />
<br />
;;;;;;;;;;;<br />
; on OPEN ;<br />
;;;;;;;;;;;<br />
on ^*:OPEN:?:{<br />
;; check if it happens on QNet<br />
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return <br />
<br />
;; notice the user that his query is pending<br />
.notice $nick Query pending...<br />
<br />
;; halt the default opening of the window<br />
haltdef<br />
<br />
;; check for control codes -- this should block most porn spam<br />
if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) {<br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.)<br />
.notice $nick Query denied, message blocked.<br />
} <br />
<br />
;; now it's time to check regular messages<br />
;; first, the easy part -- check if the user has usermode +x and if so<br />
;; use it to extract the Q auth<br />
if ($right($site,19) == .users.quakenet.org) { <br />
<br />
;; $gettok($site,1,46) holds the users Q auth<br />
;; if the user is allowed to message, notice the query is accepted and let the query window open<br />
if ($hget(hDnd,$gettok($site,1,46)) == allow) {<br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ )<br />
query -n $nick<br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1-<br />
window -g[1] $nick<br />
.notice $nick Query accepted.<br />
}<br />
elseif ($hget(hDnd,$gettok($site,1,46)) == block) {<br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ )<br />
.notice $nick Query denied, message blocked.<br />
}<br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ )<br />
.notice $nick Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ )<br />
query -n $nick<br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1-<br />
window -g[1] $nick<br />
.notice $nick Query accepted.<br />
}<br />
}<br />
<br />
;; closing if ($right($site,19) == .users.quakenet.org)<br />
}<br />
<br />
;; if the user wasn't using usermode +x we store the message and send a who to the server<br />
;; the query window remains closed so far, we can always open it later if the user is allowed to pm<br />
else {<br />
set %dndQueryAuth [ $+ [ $nick ] ] 1<br />
set %dndQueryMessage [ $+ [ $nick ] ] $1-<br />
set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress<br />
who $nick n%nat,990<br />
<br />
}<br />
}<br />
<br />
;;;;;;;;;;;<br />
; RAW 354 ;<br />
;;;;;;;;;;;<br />
<br />
;; RAW 354 is the servers answer to the who request<br />
;; reference 990 is used to make sure it came from the on OPEN event<br />
;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1<br />
raw 354:& 990 & *: { <br />
set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1)<br />
halt<br />
}<br />
<br />
;;;;;;;;;;;<br />
; RAW 315 ;<br />
;;;;;;;;;;;<br />
<br />
;; unfortunately, raw 315 (End of /WHO list) does not have this reference<br />
raw 315:*:{<br />
;;;;;;;;;;;;;;;;;<br />
; QUERY REQUEST ;<br />
;;;;;;;;;;;;;;;;;<br />
if (%dndQueryAuth [ $+ [ $2 ] ]) {<br />
<br />
;; if the user was authed<br />
if ($v1 != 1) {<br />
<br />
;; run the same check as in the on OPEN event<br />
if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) {<br />
dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied, message blocked.<br />
}<br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
}<br />
}<br />
<br />
;; if the user was not authed<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
}<br />
unset %dndQueryAuth [ $+ [ $2 ] ]<br />
unset %dndQueryMessage [ $+ [ $2 ] ]<br />
unset %dndQueryFulladdress [ $+ [ $2 ] ]<br />
}<br />
halt<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;<br />
; DND ;<br />
;;;;;;;<br />
alias dnd {<br />
;; syntax check<br />
;; turn dnd on/off<br />
if ($regex($1-,/^(on|off)$/)) {<br />
set %dnd $regml(1)<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off)<br />
}<br />
;; allow/block a user<br />
elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) {<br />
hadd hDnd $regml(2) $regml(1)<br />
hsave -b hDnd dnd.dnd<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2)<br />
}<br />
;; remove a user<br />
elseif ($regex($1-,/^remove\s(\w+)$/)) {<br />
hdel hDnd $regml(1)<br />
hsave -b hDnd dnd.dnd<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1)<br />
}<br />
;; dialog<br />
elseif (!$0) { }<br />
;; else the syntax is wrong -- output an error<br />
else echo -s * /dnd - Error: erronious syntax.<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;;;;;;<br />
; dnd_echo ;<br />
;;;;;;;;;;;;<br />
alias -l dnd_echo {<br />
if (!$window(@AllScripts)) { window -hk0nx @AllScripts }<br />
echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1-<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
menu channel,status {<br />
-<br />
DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on)<br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Do_not_Disturb_-_A_QuakeNet_pm_blocker&diff=1365Do not Disturb - A QuakeNet pm blocker2006-04-23T16:12:13Z<p>Shenghi: </p>
<hr />
<div>Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!'''<br />
<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; Do not Disturb<br />
;<br />
; Written by Shenghi<br />
; Contact at:<br />
; #help.script @ irc.quakenet.org<br />
;<br />
; dnd.mrc<br />
; dnd.dnd<br />
; dnd.ini<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; A QuakeNet pm blocker based on Q auth<br />
; Usage:<br />
; /dnd [on|off|allow|block|remove]<br />
; if no argument is passed a configuration dialog will pop up<br />
; this is coming in a later version<br />
;<br />
; on|off turns pm blocking on or off<br />
;<br />
; allow|block allows or blocks a Q auth<br />
;<br />
; remove removes a Q auth<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; Version history:<br />
; v1.00<br />
; First working version<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; NOTE ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
; Do not Disturb logs some things to a window called ;<br />
; @AllMessages. This window is hidden. If you want to ;<br />
; view it by pressing F11, uncomment the following ;<br />
; code. ;<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br />
;alias F11 {<br />
; if ($window(@AllScripts).state == maximized) { window -n @AllScripts }<br />
; elseif ($window(@AllScripts).state == hidden) { window -x @AllScripts }<br />
; elseif ($window(@AllScripts).state == normal) { window -x @AllScripts }<br />
;}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;;;;;<br />
; on LOAD ;<br />
;;;;;;;;;;;<br />
on *:load:{<br />
linesep -s<br />
<br />
;; writing the default ini<br />
if ($isfile(dnd.ini)) {<br />
echo -s Settings file (dnd.ini) already exists. Unloading script...<br />
unload -rs $script<br />
linesep -s<br />
return<br />
}<br />
<br />
;; cc is short for control code<br />
writeini -n dnd.ini options cc block<br />
writeini -n dnd.ini options showcc false<br />
writeini -n dnd.ini options showblocked false<br />
writeini -n dnd.ini options showaccepted true<br />
writeini -n dnd.ini options showunknown true<br />
writeini -n dnd.ini options blockunknown false<br />
writeini -n dnd.ini options echoactive true<br />
writeini -n dnd.ini options nickcolor 1<br />
<br />
echo -s Loaded Do not Disturb<br />
linesep -s<br />
} <br />
<br />
<br />
;;;;;;;;;;;;<br />
; on START ;<br />
;;;;;;;;;;;;<br />
on *:start:{<br />
; free and create hDnd hashtable<br />
if ($hget(hDnd)) hfree hDnd<br />
hmake hDnd <br />
<br />
; if dnd.dnd file exists, load allow/block hashtables<br />
if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd<br />
}<br />
<br />
<br />
;;;;;;;;;;;<br />
; on OPEN ;<br />
;;;;;;;;;;;<br />
on ^*:OPEN:?:{<br />
;; check if it happens on QNet<br />
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return <br />
<br />
;; notice the user that his query is pending<br />
.notice $nick Query pending...<br />
<br />
;; halt the default opening of the window<br />
haltdef<br />
<br />
;; check for control codes -- this should block most porn spam<br />
if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) {<br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.)<br />
.notice $nick Query denied, message blocked.<br />
} <br />
<br />
;; now it's time to check regular messages<br />
;; first, the easy part -- check if the user has usermode +x and if so<br />
;; use it to extract the Q auth<br />
if ($right($site,19) == .users.quakenet.org) { <br />
<br />
;; $gettok($site,1,46) holds the users Q auth<br />
;; if the user is allowed to message, notice the query is accepted and let the query window open<br />
if ($hget(hDnd,$gettok($site,1,46)) == allow) {<br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ )<br />
query -n $nick<br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1-<br />
window -g[1] $nick<br />
.notice $nick Query accepted.<br />
}<br />
elseif ($hget(hDnd,$gettok($site,1,46)) == block) {<br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ )<br />
.notice $nick Query denied, message blocked.<br />
}<br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ )<br />
.notice $nick Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ )<br />
query -n $nick<br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1-<br />
window -g[1] $nick<br />
.notice $nick Query accepted.<br />
}<br />
}<br />
<br />
;; closing if ($right($site,19) == .users.quakenet.org)<br />
}<br />
<br />
;; if the user wasn't using usermode +x we store the message and send a who to the server<br />
;; the query window remains closed so far, we can always open it later if the user is allowed to pm<br />
else {<br />
set %dndQueryAuth [ $+ [ $nick ] ] 1<br />
set %dndQueryMessage [ $+ [ $nick ] ] $1-<br />
set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress<br />
who $nick n%nat,990<br />
<br />
}<br />
}<br />
<br />
;;;;;;;;;;;<br />
; RAW 354 ;<br />
;;;;;;;;;;;<br />
<br />
;; RAW 354 is the servers answer to the who request<br />
;; reference 990 is used to make sure it came from the on OPEN event<br />
;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1<br />
raw 354:& 990 & *: { <br />
set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1)<br />
halt<br />
}<br />
<br />
;;;;;;;;;;;<br />
; RAW 315 ;<br />
;;;;;;;;;;;<br />
<br />
;; unfortunately, raw 315 (End of /WHO list) does not have this reference<br />
raw 315:*:{<br />
;;;;;;;;;;;;;;;;;<br />
; QUERY REQUEST ;<br />
;;;;;;;;;;;;;;;;;<br />
if (%dndQueryAuth [ $+ [ $2 ] ]) {<br />
<br />
;; if the user was authed<br />
if ($v1 != 1) {<br />
<br />
;; run the same check as in the on OPEN event<br />
if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) {<br />
dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied, message blocked.<br />
}<br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
}<br />
}<br />
<br />
;; if the user was not authed<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
}<br />
unset %dndQueryAuth [ $+ [ $2 ] ]<br />
unset %dndQueryMessage [ $+ [ $2 ] ]<br />
unset %dndQueryFulladdress [ $+ [ $2 ] ]<br />
}<br />
halt<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;<br />
; DND ;<br />
;;;;;;;<br />
alias dnd {<br />
;; syntax check<br />
;; turn dnd on/off<br />
if ($regex($1-,/^(on|off)$/)) {<br />
set %dnd $regml(1)<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off)<br />
}<br />
;; allow/block a user<br />
elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) {<br />
hadd hDnd $regml(2) $regml(1)<br />
hsave -b hDnd dnd.dnd<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2)<br />
}<br />
;; remove a user<br />
elseif ($regex($1-,/^remove\s(\w+)$/)) {<br />
hdel hDnd $regml(1)<br />
hsave -b hDnd dnd.dnd<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1)<br />
}<br />
;; dialog<br />
elseif (!$0) { }<br />
;; else the syntax is wrong -- output an error<br />
else echo -s * /dnd - Error: erronious syntax.<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;;;;;;<br />
; dnd_echo ;<br />
;;;;;;;;;;;;<br />
alias -l dnd_echo {<br />
if (!$window(@AllScripts)) { window -hk0nx @AllScripts }<br />
echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1-<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
menu channel,status {<br />
-<br />
DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on)<br />
}<br />
<br />
[[Category:Script Archive]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Do_not_Disturb_-_A_QuakeNet_pm_blocker&diff=1364Do not Disturb - A QuakeNet pm blocker2006-04-23T16:11:37Z<p>Shenghi: </p>
<hr />
<div>Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!'''<br />
<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; Do not Disturb<br />
;<br />
; Written by Shenghi<br />
; Contact at:<br />
; #help.script @ irc.quakenet.org<br />
;<br />
; dnd.mrc<br />
; dnd.dnd<br />
; dnd.ini<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; A QuakeNet pm blocker based on Q auth<br />
; Usage:<br />
; /dnd [on|off|allow|block|remove]<br />
; if no argument is passed a configuration dialog will pop up<br />
; this is coming in a later version<br />
;<br />
; on|off turns pm blocking on or off<br />
;<br />
; allow|block allows or blocks a Q auth<br />
;<br />
; remove removes a Q auth<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
; Version history:<br />
; v1.00<br />
; First working version<br />
; - - - - - - - - - - - - - - - - - - - - - - - - -<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; NOTE ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
; Do not Disturb logs some things to a window called ;<br />
; @AllMessages. This window is hidden. If you want to ;<br />
; view it by pressing F11, uncomment the following ;<br />
; code. ;<br />
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br />
;alias F11 {<br />
; if ($window(@AllScripts).state == maximized) { window -n @AllScripts }<br />
; elseif ($window(@AllScripts).state == hidden) { window -x @AllScripts }<br />
; elseif ($window(@AllScripts).state == normal) { window -x @AllScripts }<br />
;}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;;;;;<br />
; on LOAD ;<br />
;;;;;;;;;;;<br />
on *:load:{<br />
linesep -s<br />
<br />
;; writing the default ini<br />
if ($isfile(dnd.ini)) {<br />
echo -s Settings file (dnd.ini) already exists. Unloading script...<br />
unload -rs $script<br />
linesep -s<br />
return<br />
}<br />
<br />
;; cc is short for control code<br />
writeini -n dnd.ini options cc block<br />
writeini -n dnd.ini options showcc false<br />
writeini -n dnd.ini options showblocked false<br />
writeini -n dnd.ini options showaccepted true<br />
writeini -n dnd.ini options showunknown true<br />
writeini -n dnd.ini options blockunknown false<br />
writeini -n dnd.ini options echoactive true<br />
writeini -n dnd.ini options nickcolor 1<br />
<br />
echo -s Loaded Do not Disturb<br />
linesep -s<br />
} <br />
<br />
<br />
;;;;;;;;;;;;<br />
; on START ;<br />
;;;;;;;;;;;;<br />
on *:start:{<br />
; free and create hDnd hashtable<br />
if ($hget(hDnd)) hfree hDnd<br />
hmake hDnd <br />
<br />
; if dnd.dnd file exists, load allow/block hashtables<br />
if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd<br />
}<br />
<br />
<br />
;;;;;;;;;;;<br />
; on OPEN ;<br />
;;;;;;;;;;;<br />
on ^*:OPEN:?:{<br />
;; check if it happens on QNet<br />
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return <br />
<br />
;; notice the user that his query is pending<br />
.notice $nick Query pending...<br />
<br />
;; halt the default opening of the window<br />
haltdef<br />
<br />
;; check for control codes -- this should block most porn spam<br />
if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) {<br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.)<br />
.notice $nick Query denied, message blocked.<br />
} <br />
<br />
;; now it's time to check regular messages<br />
;; first, the easy part -- check if the user has usermode +x and if so<br />
;; use it to extract the Q auth<br />
if ($right($site,19) == .users.quakenet.org) { <br />
<br />
;; $gettok($site,1,46) holds the users Q auth<br />
;; if the user is allowed to message, notice the query is accepted and let the query window open<br />
if ($hget(hDnd,$gettok($site,1,46)) == allow) {<br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ )<br />
query -n $nick<br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1-<br />
window -g[1] $nick<br />
.notice $nick Query accepted.<br />
}<br />
elseif ($hget(hDnd,$gettok($site,1,46)) == block) {<br />
dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ )<br />
.notice $nick Query denied, message blocked.<br />
}<br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ )<br />
.notice $nick Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ )<br />
query -n $nick<br />
echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1-<br />
window -g[1] $nick<br />
.notice $nick Query accepted.<br />
}<br />
}<br />
<br />
;; closing if ($right($site,19) == .users.quakenet.org)<br />
}<br />
<br />
;; if the user wasn't using usermode +x we store the message and send a who to the server<br />
;; the query window remains closed so far, we can always open it later if the user is allowed to pm<br />
else {<br />
set %dndQueryAuth [ $+ [ $nick ] ] 1<br />
set %dndQueryMessage [ $+ [ $nick ] ] $1-<br />
set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress<br />
who $nick n%nat,990<br />
<br />
}<br />
}<br />
<br />
;;;;;;;;;;;<br />
; RAW 354 ;<br />
;;;;;;;;;;;<br />
<br />
;; RAW 354 is the servers answer to the who request<br />
;; reference 990 is used to make sure it came from the on OPEN event<br />
;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1<br />
raw 354:& 990 & *: { <br />
set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1)<br />
halt<br />
}<br />
<br />
;;;;;;;;;;;<br />
; RAW 315 ;<br />
;;;;;;;;;;;<br />
<br />
;; unfortunately, raw 315 (End of /WHO list) does not have this reference<br />
raw 315:*:{<br />
;;;;;;;;;;;;;;;;;<br />
; QUERY REQUEST ;<br />
;;;;;;;;;;;;;;;;;<br />
if (%dndQueryAuth [ $+ [ $2 ] ]) {<br />
<br />
;; if the user was authed<br />
if ($v1 != 1) {<br />
<br />
;; run the same check as in the on OPEN event<br />
if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) {<br />
dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied, message blocked.<br />
}<br />
<br />
;; if a user is unknown we let faith (read: options) decide whether to accept or decline<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
}<br />
}<br />
<br />
;; if the user was not authed<br />
else {<br />
if ($readini(dnd.ini,options,blockunknown) == true) {<br />
dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
.notice $2 Query denied.<br />
}<br />
else {<br />
dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.)<br />
if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ )<br />
query -n $2<br />
echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ]<br />
window -g[1] $2<br />
.notice $2 Query accepted.<br />
}<br />
}<br />
unset %dndQueryAuth [ $+ [ $2 ] ]<br />
unset %dndQueryMessage [ $+ [ $2 ] ]<br />
unset %dndQueryFulladdress [ $+ [ $2 ] ]<br />
}<br />
halt<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;<br />
; DND ;<br />
;;;;;;;<br />
alias dnd {<br />
;; syntax check<br />
;; turn dnd on/off<br />
if ($regex($1-,/^(on|off)$/)) {<br />
set %dnd $regml(1)<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off)<br />
}<br />
;; allow/block a user<br />
elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) {<br />
hadd hDnd $regml(2) $regml(1)<br />
hsave -b hDnd dnd.dnd<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2)<br />
}<br />
;; remove a user<br />
elseif ($regex($1-,/^remove\s(\w+)$/)) {<br />
hdel hDnd $regml(1)<br />
hsave -b hDnd dnd.dnd<br />
echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1)<br />
}<br />
;; dialog<br />
elseif (!$0) { }<br />
;; else the syntax is wrong -- output an error<br />
else echo -s * /dnd - Error: erronious syntax.<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
<br />
;;;;;;;;;;;;<br />
; dnd_echo ;<br />
;;;;;;;;;;;;<br />
alias -l dnd_echo {<br />
if (!$window(@AllScripts)) { window -hk0nx @AllScripts }<br />
echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1-<br />
}<br />
<br />
<br />
;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;;<br />
menu channel,status {<br />
-<br />
DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on)<br />
}</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$fulladdress&diff=4494$fulladdress2006-04-22T16:32:23Z<p>Shenghi: added a dot</p>
<hr />
<div>Returns the full address of the user triggering an event in the form nick!user@host.<br />
$site<br />
== Example ==<br />
on *:[[On_join|JOIN]]:#: {<br />
[[if]] ([[$nick]] === Dana) {<br />
[[echo]] -ag $fulladdress ; returns ''Dana!dana@staff.quakenet.org''<br />
}<br />
}<br />
<br />
== See also ==<br />
*[[$site]] returns the portion of [[$address]] after the @ related to an event.<br />
*[[$wildsite]] returns the address of a user who triggered an event in the form *!*@host.<br />
<br />
[[Category:Remote Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$wildsite&diff=4493$wildsite2006-04-22T16:31:46Z<p>Shenghi: added $fulladdress to see also</p>
<hr />
<div>Returns the address of the user who triggered an event in the form *!*@host.<br />
$wildsite<br />
== Example ==<br />
on *:[[On_join|JOIN]]:#: {<br />
[[if]] ([[$nick]] === Dana) {<br />
[[echo]] -ag $wildsite ; returns ''*!*@staff.quakenet.org''<br />
}<br />
}<br />
<br />
== See also ==<br />
*[[$fulladdress]] returns the full address of the user triggering an event in the form nick!user@host.<br />
*[[$site]] returns the portion of [[$address]] after the @ related to an event.<br />
<br />
[[Category:Remote Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$site&diff=4492$site2006-04-22T16:30:39Z<p>Shenghi: added $fulladdress to see also</p>
<hr />
<div>Returns the portion of [[$address]] after the @ for the user associated with an event in the form user@host.<br />
$site<br />
== Example ==<br />
on *:[[On_join|JOIN]]:#: {<br />
[[if]] ([[$nick]] === Dana) {<br />
[[echo]] -ag $site ; returns ''staff.quakenet.org''<br />
}<br />
}<br />
<br />
== See also ==<br />
*[[$fulladdress]] returns the full address of the user triggering an event in the form nick!user@host.<br />
*[[$wildsite]] returns the address of the user who triggered an event in the form *!*@host.<br />
<br />
[[Category:Remote Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$fulladdress&diff=1363$fulladdress2006-04-22T16:29:05Z<p>Shenghi: </p>
<hr />
<div>Returns the full address of the user triggering an event in the form nick!user@host.<br />
$site<br />
== Example ==<br />
on *:[[On_join|JOIN]]:#: {<br />
[[if]] ([[$nick]] === Dana) {<br />
[[echo]] -ag $fulladdress ; returns ''Dana!dana@staff.quakenet.org''<br />
}<br />
}<br />
<br />
== See also ==<br />
*[[$site]] returns the portion of [[$address]] after the @ related to an event.<br />
*[[$wildsite]] returns the address of a user who triggered an event in the form *!*@host<br />
<br />
[[Category:Remote Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$wildsite&diff=1362$wildsite2006-04-22T16:26:41Z<p>Shenghi: </p>
<hr />
<div>Returns the address of a user who triggered an event in the form *!*@host.<br />
$wildsite<br />
== Example ==<br />
on *:[[On_join|JOIN]]:#: {<br />
[[if]] ([[$nick]] === Dana) {<br />
[[echo]] -ag $wildsite ; returns ''*!*@staff.quakenet.org''<br />
}<br />
}<br />
<br />
== See also ==<br />
[[$site]] Returns the portion of [[$address]] after the @ related to an event.<br />
<br />
[[Category:Remote Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$site&diff=1361$site2006-04-22T16:24:48Z<p>Shenghi: </p>
<hr />
<div>Returns the portion of [[$address]] after the @ related to an event.<br />
$site<br />
== Example ==<br />
on *:[[On_join|JOIN]]:#: {<br />
[[if]] ([[$nick]] === Dana) {<br />
[[echo]] -ag $site ; returns ''staff.quakenet.org''<br />
}<br />
}<br />
<br />
== See also ==<br />
[[$wildsite]] returns the address of a user who triggered an event in the form *!*@host<br />
<br />
[[Category:Remote Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=On_join&diff=2172On join2006-04-22T14:50:35Z<p>Shenghi: added a note about $address($nick,N) not working</p>
<hr />
<div>The on JOIN event trigger when a user joins a channel.<br />
on <level>:JOIN:<#[,#]>:<commands><br />
<br />
'''Note''' that this event also triggers when you join a channel yourself.<br />
<br />
== Examples ==<br />
on *:JOIN:#: { <br />
[[echo]] -t [[$chan]] < [[DollarPlus|$+]] [[$nick]] $+ > has just joined $chan $+ .<br />
}<br />
This will echo whenever someone has joined a channel and echo it to this channel. You can use this to modify mIRC's layout.<br />
<br />
<br />
on *:JOIN:#yourchan: {<br />
[[notice]] $nick Hello $nick $+ ! Enjoy your stay here in $chan $+ .<br />
}<br />
This will notice everyone joining #yourchan (you have to replace it with your chan of course). You can use it to have your own welcome-message.<br />
<br />
<br />
on me:*:JOIN:#: {<br />
echo -s I have just joined $chan<br />
}<br />
The example reacts on you joining a channel. Note that it is no mistake, the prefix is "me:".<br />
== Note ==<br />
The $address(nick,N) identifier gets its information from the Internal Address List (IAL). When the on JOIN event is triggered, the user joining is not yet added to the IAL unless he already was, if he/she had common channels before he/she joined. Therefore it's safe to assume that $address($nick,N) will not work in an on JOIN event. The event related identifiers [[$address]], [[$fulladdress]], [[$nick]], [[$site]], [[$wildsite]] and such do work.<br />
on *:JOIN:#: {<br />
[[echo]] -ag [[$mask]]([[$fulladdress]],2)<br />
}<br />
The above example would echo the same as $address($nick,2) would have done in most events.<br />
== See Also ==<br />
To react on parts, take a look at the [[On_part|On part event]].<br />
<br />
[[Category:Events]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$strip&diff=2190$strip2006-04-12T15:22:14Z<p>Shenghi: last edit? please?</p>
<hr />
<div>Returns text with control codes stripped out.<br />
$strip(''text''[,burcmo])<br />
The first parameter is the text you want to strip the control codes from. The second parameter is optional and specifies which control codes are stripped.<br />
<br />
{| style="width:100%"<br />
| style="width:5%" | '''''Switch''''' || style="width:95%" | '''''Meaning'''''<br />
|-<br />
| b || The ''b'' switch strips all ''bold'' control codes.<br />
|-<br />
| u || The ''u'' switch strips all ''underline'' control codes.<br />
|-<br />
| r || The ''r'' switch strips all ''reverse'' control codes. This control code reverses the background and text color as specified in the ''Colors...'' dialog.<br />
|-<br />
| c || The ''c'' switch strips all ''color'' control codes.<br />
|-<br />
| m || The ''m'' switch strips all control codes as specified in Options=>IRC=>Messages, not including the ''Only if...'' option.<br />
|-<br />
| o || The ''o'' switch applies the ''Only if...'' setting in Options=>IRC=>Messages.<br />
|}<br />
<br />
== Example ==<br />
[[On_text|on ^*:TEXT:]]*:?:{<br />
[[echo]] -t [[$nick]] < [[DollarPlus|$+]] [[$nick]] [[DollarPlus|$+]] > $strip([[$1-]],m)<br />
[[haltdef]]<br />
}<br />
The above little script would strip control codes from private messages as they are specified in Options=>IRC=>Messages.<br />
<br />
== Also See ==<br />
* [[$stripped]] - This returns the number of control codes stripped by $strip.<br />
<br />
[[Category:Text_and_Number_Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$strip&diff=1350$strip2006-04-12T15:19:40Z<p>Shenghi: </p>
<hr />
<div>Returns text with control codes stripped out.<br />
$strip(''text''[,burcmo])<br />
The first parameter is the text you want to strip the control codes from. The second parameter is optional and specifies which control codes are stripped.<br />
<br />
{| style="width:100%"<br />
| style="width:5%" | '''''Switch''''' || style="width:95%" | '''''Meaning'''''<br />
|-<br />
| b || The ''b'' switch strips all ''bold'' control codes.<br />
|-<br />
| u || The ''u'' switch strips all ''underline'' control codes.<br />
|-<br />
| r || The ''r'' switch strips all ''reverse'' control codes. This control code reverses the background and text color as specified in the ''Colors...'' dialog.<br />
|-<br />
| c || The ''c'' switch strips all ''color'' control codes.<br />
|-<br />
| m || The ''m'' switch strips all control codes as specified in Options=>IRC=>Messages, not including the ''Only if...'' option.<br />
|-<br />
| o || The ''o'' switch applies the ''Only if...'' setting in Options=>IRC=>Messages.<br />
|}<br />
<br />
== Example ==<br />
[[On_text|on ^*:TEXT:]]*:?:{<br />
[[echo]] -t [[$nick]] < $+ [[$nick]] $+ > $strip([[$1-]],m)<br />
[[haltdef]]<br />
}<br />
The above little script would strip control codes from private messages as they are specified in Options=>IRC=>Messages.<br />
<br />
== Also See ==<br />
* [[$stripped]] - This returns the number of control codes stripped by $strip.<br />
<br />
[[Category:Text_and_Number_Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$strip&diff=1349$strip2006-04-12T15:12:48Z<p>Shenghi: linked on text, $+ and $1-</p>
<hr />
<div>Returns text with control codes stripped out.<br />
$strip(''text''[,burcmo])<br />
The first parameter is the text you want to strip the control codes from. The second parameter is optional and specifies which control codes are stripped.<br />
<br />
{| style="width:100%"<br />
| style="width:5%" | '''''Switch''''' || style="width:95%" | '''''Meaning'''''<br />
|-<br />
| b || The ''b'' switch strips all ''bold'' control codes.<br />
|-<br />
| u || The ''u'' switch strips all ''underline'' control codes.<br />
|-<br />
| r || The ''r'' switch strips all ''reverse'' control codes. This control code reverses the background and text color as specified in the ''Colors...'' dialog.<br />
|-<br />
| c || The ''c'' switch strips all ''color'' control codes.<br />
|-<br />
| m || The ''m'' switch strips all control codes as specified in Options=>IRC=>Messages, not including the ''Only if...'' option.<br />
|-<br />
| o || The ''o'' switch applies the ''Only if...'' setting in Options=>IRC=>Messages.<br />
|}<br />
<br />
== Example ==<br />
[[On_text|on ^*:TEXT:]]*:?:{<br />
[[echo]] -t [[$nick]] < [[$+]] [[$nick]] $+ > $strip([[$1-]],m)<br />
[[haltdef]]<br />
}<br />
The above little script would strip control codes from private messages as they are specified in Options=>IRC=>Messages.<br />
<br />
== Also See ==<br />
* [[$stripped]] - This returns the number of control codes stripped by $strip.<br />
<br />
[[Category:Text_and_Number_Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$strip&diff=1348$strip2006-04-12T15:06:49Z<p>Shenghi: added the function of 'reverse' control code</p>
<hr />
<div>Returns text with control codes stripped out.<br />
$strip(''text''[,burcmo])<br />
The first parameter is the text you want to strip the control codes from. The second parameter is optional and specifies which control codes are stripped.<br />
<br />
{| style="width:100%"<br />
| style="width:5%" | '''''Switch''''' || style="width:95%" | '''''Meaning'''''<br />
|-<br />
| b || The ''b'' switch strips all ''bold'' control codes.<br />
|-<br />
| u || The ''u'' switch strips all ''underline'' control codes.<br />
|-<br />
| r || The ''r'' switch strips all ''reverse'' control codes. This control code reverses the background and text color as specified in the ''Colors...'' dialog.<br />
|-<br />
| c || The ''c'' switch strips all ''color'' control codes.<br />
|-<br />
| m || The ''m'' switch strips all control codes as specified in Options=>IRC=>Messages, not including the ''Only if...'' option.<br />
|-<br />
| o || The ''o'' switch applies the ''Only if...'' setting in Options=>IRC=>Messages.<br />
|}<br />
<br />
== Example ==<br />
on ^*:TEXT:*:?:{<br />
[[echo]] -t [[$nick]] < $+ [[$nick]] $+ > $strip($1-,m)<br />
[[haltdef]]<br />
}<br />
The above little script would strip control codes from private messages as they are specified in Options=>IRC=>Messages.<br />
<br />
== Also See ==<br />
* [[$stripped]] - This returns the number of control codes stripped by $strip.<br />
<br />
[[Category:Text_and_Number_Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$strip&diff=1347$strip2006-04-12T15:05:26Z<p>Shenghi: added Also See and Category</p>
<hr />
<div>Returns text with control codes stripped out.<br />
$strip(''text''[,burcmo])<br />
The first parameter is the text you want to strip the control codes from. The second parameter is optional and specifies which control codes are stripped.<br />
<br />
{| style="width:100%"<br />
| style="width:5%" | '''''Switch''''' || style="width:95%" | '''''Meaning'''''<br />
|-<br />
| b || The ''b'' switch strips all ''bold'' control codes.<br />
|-<br />
| u || The ''u'' switch strips all ''underline'' control codes.<br />
|-<br />
| r || The ''r'' switch strips all ''reverse'' control codes.<br />
|-<br />
| c || The ''c'' switch strips all ''color'' control codes.<br />
|-<br />
| m || The ''m'' switch strips all control codes as specified in Options=>IRC=>Messages, not including the ''Only if...'' option.<br />
|-<br />
| o || The ''o'' switch applies the ''Only if...'' setting in Options=>IRC=>Messages.<br />
|}<br />
<br />
== Example ==<br />
on ^*:TEXT:*:?:{<br />
[[echo]] -t [[$nick]] < $+ [[$nick]] $+ > $strip($1-,m)<br />
[[haltdef]]<br />
}<br />
The above little script would strip control codes from private messages as they are specified in Options=>IRC=>Messages.<br />
<br />
== Also See ==<br />
* [[$stripped]] - This returns the number of control codes stripped by $strip.<br />
<br />
[[Category:Text_and_Number_Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$strip&diff=1346$strip2006-04-12T15:00:55Z<p>Shenghi: </p>
<hr />
<div>Returns text with control codes stripped out.<br />
$strip(''text''[,burcmo])<br />
The first parameter is the text you want to strip the control codes from. The second parameter is optional and specifies which control codes are stripped.<br />
<br />
{| style="width:100%"<br />
| style="width:5%" | '''''Switch''''' || style="width:95%" | '''''Meaning'''''<br />
|-<br />
| b || The ''b'' switch strips all ''bold'' control codes.<br />
|-<br />
| u || The ''u'' switch strips all ''underline'' control codes.<br />
|-<br />
| r || The ''r'' switch strips all ''reverse'' control codes.<br />
|-<br />
| c || The ''c'' switch strips all ''color'' control codes.<br />
|-<br />
| m || The ''m'' switch strips all control codes as specified in Options=>IRC=>Messages, not including the ''Only if...'' option.<br />
|-<br />
| o || The ''o'' switch applies the ''Only if...'' setting in Options=>IRC=>Messages.<br />
|}<br />
<br />
== Example ==<br />
on ^*:TEXT:*:?:{<br />
[[echo]] -t [[$nick]] < $+ [[$nick]] $+ > $strip($1-,m)<br />
[[haltdef]]<br />
}<br />
The above little script would strip control codes from private messages as they are specified in Options=>IRC=>Messages.</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Category:Hash_Table&diff=1343Category:Hash Table2006-04-12T00:07:23Z<p>Shenghi: deleted 3 semicolons... those look so ugly!</p>
<hr />
<div>== Basic Defintion ==<br />
Basically, hash tables are like [[:Category:Ini|ini files]], storing information in following format:<br />
<br />
<b>Tablename</b><br /><br />
item1=data1<br /><br />
item2=data2<br /><br />
...<br />
<br />
However, hash tables are a lot faster than ini- or text-files, which especially takes effect if you have a lot of entries. A kind of disadvantage is the missing possibility to ''see'' all entries. With some files, you can just open them and take a look on every entry, whereat hash table, you can't just ''open'' then. To have the chance to still get an overview, you can use the following script:<br />
<br />
; lets make a little alias called ''showhash''. At the end, it will look like ''/showhash <name>''<br />
[[alias]] showhash {<br />
; echo the name and a kind of "table header"<br />
[[echo]] -a $1<br />
echo -a item => data<br />
[[var]] %i = 1<br />
; lets loop through all items. $hget($1,0).item will return the total amount of items.<br />
[[while]] (%i <= $hget($1,0).item) {<br />
echo -a $hget($1,%i).item => $hget($1,%i).data<br />
; increase looping-variable<br />
[[inc]] %i<br />
} <br />
}<br />
<br />
=== Modifying hash tables ===<br />
You can make a new hashtable using the [[Hmake|/hmake]], respectivly delete one using the [[Hfree|/hfree]] command. Using [[Hdel|/hdel]] and [[Hadd|/hadd]], you can modify the data saved in your hashtable. Due to hash tables not being automatically saved, you have to use the [[Hsave|/hsave]] and [[Hload|/hload]] command.<br />
<br />
=== Receiving data ===<br />
After saving data in hash tables, you can of course receive them. Therefor, use the [[$hget]] and [[$hfind]] identifiers.<br />
<br />
<br />
== More detailed information ==<br />
<br />
The following explanations aren't necessary for using hashtables in mIRC scripts, however, these facts could help you make your scripts faster, especially if you are going to use hash tables for a lot of data.<br />
<br />
<br />
A hashtable is basically an array of N buckets (N being the size from /hmake) where each bucket is just a pointer (4 bytes) to a linked list of items. In principle you could enlarge the number of buckets later on by resizing the array, but that means the hash values for items change: the bucket number for an item, i.e. the index into the array of pointers, is determined by the formula "hashfunc(itemname) modulo N". Changing N on the fly essentially means you have to reassign most of the items to other buckets, which is a nightmare with large hashtables.<br />
<br />
<br />
This means that $hget will indeed be slower if you take a smaller hashtable and fill it with the same amount of items as before, since the average amount of items to traverse in a bucket when looking for a match is N/2, which would mean that $hget takes much longer on a big file loaded in a small hash table, compared to a big file loaded in a big hash table.<br />
A benchmark would show this, although you'd have to repeat $hget a large number of times of course, as the speed of individual $hgets is still negligible.<br />
<br />
<br />
On the other hand, if your file contains M entries, /hload does M implicit $hgets to ensure that item names won't be added twice. If the factor M:N (i.e. items:size) is 10:1, then it will do (on average) 5 * M lookups, if it is 100:1, then it will do 50 * M lookups and so on. For large values of M, this difference is noticeable, even with one single /hload. So you should choose N very carefully before issuing a /hload. <br />
<br />
<br />
Note that there is no such thing as an "overflow" in hashtables; buckets point to linked lists that can be of arbitrary length. If you make a hashtable of size 1, you are essentially using a single linked list of items, and everything will still work fine (but $hget would be just as slow as $hfind in that case). <br />
<br />
<br />
== Deleting unwanted items from a hash table ==<br />
<br />
In some cases, you'll want to loop over ''all'' the items in the hashtable, deleting the ones you do not want anymore. It may be a bit unclear at first how to do this: deleting items while looping over them is kind of like removing the ground under your own feet; how can you be sure you don't end up skipping over items, for example?<br />
<br />
Fortunately, there's one fundamental fact that you can use to do this: if you loop over N items using $hget().item, and then delete the N+1'th item, then those N items will remain the same. The N+1'th item, though, will be a new item (typically the N+2'th item). For example, if $hget().item returns A, B, C and D for respectively N values 1, 2, 3 and 4. and then you delete item C, then you can be sure that $hget().item with N values 1 and 2 will still return A and B after deleting C, respectively. Item D, however, will now be item 3 instead of 4, because there will never be any "gaps" between item numbers.<br />
<br />
The following alias shows how to put this into practice, by looping over all the items in a given hashtable, and calling a custom identifier $want-to-delete on each of them, deleting the items for which $want-to-delete returns $true. The loop will always complete (no infinite loop!), and after it has completed, ''all'' the items that were to be deleted, will indeed be gone.<br />
<br />
; usage: /purgeitems <hashtable><br />
[[alias]] purgeitems {<br />
; our counter: we start off at the first item<br />
[[var]] %i = 1<br />
<br />
; as long as the %i-th item exists, continue looping<br />
[[while]] ($hget($1,%i).item != $null) {<br />
; temporarily store the name of this item in a variable<br />
; $v1 refers to the "$hget($1,%i).item" bit above<br />
[[var]] %t = $v1<br />
<br />
; now perform a check to see if we still want to keep this item;<br />
; $want-to-delete is a custom alias (not included) and returns<br />
; either $true or $false, indicating whether we should delete %t<br />
[[if]] ($want-to-delete(%t)) {<br />
; yes, we want to delete this item; use its item name (%t) to<br />
; actually delete it using /hdel<br />
[[hdel]] $1 %t<br />
<br />
; the important part is that we do NOT increase %i here;<br />
; we just deleted the %i-th item, so the %i-th item is now a<br />
; new item. due to the way hashtable iteration works, we also<br />
; know for sure that we have not seen the %i-th item yet!<br />
}<br />
[[else]] {<br />
; we're leaving this item in, so let's increase %i so that we<br />
; move on to the next item.<br />
[[inc]] %i<br />
}<br />
}<br />
}<br />
<br />
Note that this is a very expensive (slow) operation, you should not use $hget().item unless you have to. If you can, use [[hdel|/hdel]] with the -w (wildcard) switch instead!<br />
[[Category:MIRC Help]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Category:Aliases&diff=1333Category:Aliases2006-04-10T23:28:54Z<p>Shenghi: fixed 2 brackets</p>
<hr />
<div>== Basic ==<br />
mIRC script allows you to create your own set of commands and identifiers, refered to as aliases. Aliases can be called from the command line, from other aliases, from popup and from remote scripts. An alias in mIRC can not be called recursively. They can be created by either putting them in the <nowiki>"Aliases"</nowiki> section of the mIRC Scripts Editor, by using the /alias command from either the command line or in the <nowiki>"Remote"</nowiki> section of the Scripts Editor. Creating an alias in the command line results in it being placed in the "Aliases" section of the Script Editor.<br />
<br />
=== Example ===<br />
; this is placed in the "Aliases" section<br />
moo { [[echo]] -ag moo }<br />
<br />
; this is placed in the "Remote" section<br />
[[alias]] moo { [[echo]] -ag moo }<br />
<br />
== Naming aliases ==<br />
You can give an alias virtualy any name you want, but keep a few things in mind:<br />
<br />
* When you give an alias used as a command the same name as an existing mIRC command, your alias gets preference.<br />
* When you give an alias used as an identifier the same name as an existing mIRC identifier, mIRC's identifier gets preference.<br />
<br />
== Aliases: parameters and events ==<br />
mIRC script allows you to pass parameters to your aliases, just like you pass parameters into built-in mIRC commands or identifiers. They can be referred to as $1, $2 ... $N.<br />
<br />
=== Parameters ===<br />
[[alias]] moo { echo -ag m $+ [[$str]](o,$$1) }<br />
<br />
Assuming you pass a number as parameter this would echo an <nowiki>"m"</nowiki> folowed by a number of <nowiki>"o's"</nowiki>, depending on the number you specified as parameter. This alias can be called in 2 different ways:<br />
/moo 12<br />
$moo(27)<br />
Note that $moo doesn't return anything in this case, it will simply echo the message.<br />
<br />
=== Events ===<br />
When calling an alias from an event, the identifiers related to that event will still be available in that alias.<br />
on *:TEXT:hi:#: { myAlias }<br />
<br />
[[alias]] myAlias { [[msg]] [[$chan]] [[$nick]] said hi! }<br />
<br />
This would be exactly the same as:<br />
on *:TEXT:hi:#: { [[msg]] [[$chan]] [[$nick]] said hi! }<br />
This in turn means that you don't have to pass a identifier supplied by an event into your alias as parameter.<br />
<br />
== Commands vs identifiers ==<br />
Being that you can use your aliases as both commands as identifiers, the question may rise which you should pick. The general answer is quite simple: if you want your alias to have a return value use identifiers and in any other case use commands.<br />
<br />
=== Error handling ===<br />
However, mIRC's built-in error handling cannot be used for your aliases, so for proper error handling you might want to use return values. For example, you could use return value 1 when an action was succesfull and 0 when it was not.<br />
; this identifier returns 1 if it was succesfull in what it would do and 0 if it wasn't<br />
; the (useless) idea of the following identifier is to message "moo" to the currently active channel<br />
; if it is on QuakeNet<br />
[[alias]] moo {<br />
[[if]] ([[$network]] != QuakeNet) || (![[$chan]]) { [[return]] 0 }<br />
[[else]] {<br />
[[msg]] [[$chan]] moo<br />
[[return]] 1<br />
}<br />
}<br />
<br />
To use this as error handling you could do the following:<br />
%error = $moo<br />
[[if]] (!%error) {<br />
; do what you want to do if the command failed<br />
; in this case when there was no channel active<br />
; or the server was not QuakeNet<br />
}<br />
[[elseif]] (%error = 1) {<br />
; do what you want to do if the command succeeded<br />
; in this case when there was an active channel and<br />
; the server was QuakeNet<br />
}<br />
[[else]] {<br />
; the script should never reach this place!<br />
}<br />
Although the same identifier could have been run as a command as well, error handling would not have been possible that way. Of course the alias itself has some error handling already, but there are cases in which you want an action to be able to fail.<br />
<br />
Another reason to prefer identifiers over comands are parameters. When you call an alias as a command every space will result in a new parameter and there is no way you can get around that. Using an alias as an identifier it is possible to get around the comma and thus have your parameters contain a comma. Here's how to do that:<br />
; calling an identifier with a comma in a parameter<br />
[[alias]] test {<br />
; the while loop will echo every parameter<br />
[[var]] %i = $0<br />
[[while]] (%i)<br />
[[echo]] -ag $ [ $+ [ %i ] ]<br />
[[dec]] %i<br />
}<br />
}<br />
<br />
var %param = abcdef,ghijk<br />
%someVar = $test(%param)<br />
The snippets above would result in having the identifier $test echo only 1 parameter: the data which was set in %param. Would you do the same for a command -- replacing the comma with a space -- it would result in /test getting 2 parameters. Handling parameters is much easier if you are a 100% sure which parameter will contain which data, and an identifier is more reliable in doing so.<br />
<br />
=== Forced identifiers ===<br />
To force an alias to be an identifier -- it can't be used as a command -- or vice versa you can use the identifier [[$isid]].<br />
; this alias can only be called as an identifier<br />
[[alias]] qnet {<br />
if ([[$isid]]) {<br />
; the following code only gets executed if the alias was called as an identifier<br />
[[if]] ([[$network]] === QuakeNet) { [[return]] 1 }<br />
[[else]] { [[return]] 0 }<br />
}<br />
}<br />
Calling the alias will result in a return value of either 0 or 1, while calling it as a command will do completely nothing.<br />
[[Category:mIRC_Help]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Category:Aliases&diff=1332Category:Aliases2006-04-10T20:19:01Z<p>Shenghi: added a bracket</p>
<hr />
<div>== Basic ==<br />
mIRC script allows you to create your own set of commands and identifiers, refered to as aliases. Aliases can be called from the command line, from other aliases, from popup and from remote scripts. An alias in mIRC can not be called recursively. They can be created by either putting them in the <nowiki>"Aliases"</nowiki> section of the mIRC Scripts Editor, by using the /alias command from either the command line or in the <nowiki>"Remote"</nowiki> section of the Scripts Editor. Creating an alias in the command line results in it being placed in the "Aliases" section of the Script Editor.<br />
<br />
=== Example ===<br />
; this is placed in the "Aliases" section<br />
moo { [[echo]] -ag moo }<br />
<br />
; this is placed in the "Remote" section<br />
[[alias]] moo { [[echo]] -ag moo }<br />
<br />
== Naming aliases ==<br />
You can give an alias virtualy any name you want, but keep a few things in mind:<br />
<br />
* When you give an alias used as a command the same name as an existing mIRC command, your alias gets preference.<br />
* When you give an alias used as an identifier the same name as an existing mIRC identifier, mIRC's identifier gets preference.<br />
<br />
== Aliases: parameters and events ==<br />
mIRC script allows you to pass parameters to your aliases, just like you pass parameters into built-in mIRC commands or identifiers. They can be referred to as $1, $2 ... $N.<br />
<br />
=== Parameters ===<br />
[[alias]] moo { echo -ag m $+ [[$str]](o,$$1) }<br />
<br />
Assuming you pass a number as parameter this would echo an <nowiki>"m"</nowiki> folowed by a number of <nowiki>"o's"</nowiki>, depending on the number you specified as parameter. This alias can be called in 2 different ways:<br />
/moo 12<br />
$moo(27)<br />
Note that $moo doesn't return anything in this case, it will simply echo the message.<br />
<br />
=== Events ===<br />
When calling an alias from an event, the identifiers related to that event will still be available in that alias.<br />
on *:TEXT:hi:#: { myAlias }<br />
<br />
[[alias]] myAlias { [[msg]] [[$chan]] [[$nick]] said hi!<br />
<br />
This would be exactly the same as:<br />
on *:TEXT:hi:#: { [[msg]] [[$chan]] [[$nick]] said hi!<br />
This in turn means that you don't have to pass a identifier supplied by an event into your alias as parameter.<br />
<br />
== Commands vs identifiers ==<br />
Being that you can use your aliases as both commands as identifiers, the question may rise which you should pick. The general answer is quite simple: if you want your alias to have a return value use identifiers and in any other case use commands.<br />
<br />
=== Error handling ===<br />
However, mIRC's built-in error handling cannot be used for your aliases, so for proper error handling you might want to use return values. For example, you could use return value 1 when an action was succesfull and 0 when it was not.<br />
; this identifier returns 1 if it was succesfull in what it would do and 0 if it wasn't<br />
; the (useless) idea of the following identifier is to message "moo" to the currently active channel<br />
; if it is on QuakeNet<br />
[[alias]] moo {<br />
[[if]] ([[$network]] != QuakeNet) || (![[$chan]]) { [[return]] 0 }<br />
[[else]] {<br />
[[msg]] [[$chan]] moo<br />
[[return]] 1<br />
}<br />
}<br />
<br />
To use this as error handling you could do the following:<br />
%error = $moo<br />
[[if]] (!%error) {<br />
; do what you want to do if the command failed<br />
; in this case when there was no channel active<br />
; or the server was not QuakeNet<br />
}<br />
[[elseif]] (%error = 1) {<br />
; do what you want to do if the command succeeded<br />
; in this case when there was an active channel and<br />
; the server was QuakeNet<br />
}<br />
[[else]] {<br />
; the script should never reach this place!<br />
}<br />
Although the same identifier could have been run as a command as well, error handling would not have been possible that way. Of course the alias itself has some error handling already, but there are cases in which you want an action to be able to fail.<br />
<br />
Another reason to prefer identifiers over comands are parameters. When you call an alias as a command every space will result in a new parameter and there is no way you can get around that. Using an alias as an identifier it is possible to get around the comma and thus have your parameters contain a comma. Here's how to do that:<br />
; calling an identifier with a comma in a parameter<br />
[[alias]] test {<br />
; the while loop will echo every parameter<br />
[[var]] %i = $0<br />
[[while]] (%i)<br />
[[echo]] -ag $ [ $+ [ %i ] ]<br />
[[dec]] %i<br />
}<br />
}<br />
<br />
var %param = abcdef,ghijk<br />
%someVar = $test(%param)<br />
The snippets above would result in having the identifier $test echo only 1 parameter: the data which was set in %param. Would you do the same for a command -- replacing the comma with a space -- it would result in /test getting 2 parameters. Handling parameters is much easier if you are a 100% sure which parameter will contain which data, and an identifier is more reliable in doing so.<br />
<br />
=== Forced identifiers ===<br />
To force an alias to be an identifier -- it can't be used as a command -- or vice versa you can use the identifier [[$isid]].<br />
; this alias can only be called as an identifier<br />
[[alias]] qnet {<br />
if ([[$isid]]) {<br />
; the following code only gets executed if the alias was called as an identifier<br />
[[if]] ([[$network]] === QuakeNet) { [[return]] 1 }<br />
[[else]] { [[return]] 0 }<br />
}<br />
}<br />
Calling the alias will result in a return value of either 0 or 1, while calling it as a command will do completely nothing.<br />
[[Category:mIRC_Help]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Elseif&diff=4480Elseif2006-04-10T19:56:26Z<p>Shenghi: redirect to If-Then-Else</p>
<hr />
<div>#Redirect [[If-Then-Else]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Category:Aliases&diff=1330Category:Aliases2006-04-10T19:53:20Z<p>Shenghi: added /commands vs $identifiers</p>
<hr />
<div>== Basic ==<br />
mIRC script allows you to create your own set of commands and identifiers, refered to as aliases. Aliases can be called from the command line, from other aliases, from popup and from remote scripts. An alias in mIRC can not be called recursively. They can be created by either putting them in the <nowiki>"Aliases"</nowiki> section of the mIRC Scripts Editor, by using the /alias command from either the command line or in the <nowiki>"Remote"</nowiki> section of the Scripts Editor. Creating an alias in the command line results in it being placed in the "Aliases" section of the Script Editor.<br />
<br />
=== Example ===<br />
; this is placed in the "Aliases" section<br />
moo { [[echo]] -ag moo }<br />
<br />
; this is placed in the "Remote" section<br />
[[alias]] moo { [[echo]] -ag moo }<br />
<br />
== Naming aliases ==<br />
You can give an alias virtualy any name you want, but keep a few things in mind:<br />
<br />
* When you give an alias used as a command the same name as an existing mIRC command, your alias gets preference.<br />
* When you give an alias used as an identifier the same name as an existing mIRC identifier, mIRC's identifier gets preference.<br />
<br />
== Aliases: parameters and events ==<br />
mIRC script allows you to pass parameters to your aliases, just like you pass parameters into built-in mIRC commands or identifiers. They can be referred to as $1, $2 ... $N.<br />
<br />
=== Parameters ===<br />
[[alias]] moo { echo -ag m $+ [[$str]](o,$$1)<br />
<br />
Assuming you pass a number as parameter this would echo an <nowiki>"m"</nowiki> folowed by a number of <nowiki>"o's"</nowiki>, depending on the number you specified as parameter. This alias can be called in 2 different ways:<br />
/moo 12<br />
$moo(27)<br />
Note that $moo doesn't return anything in this case, it will simply echo the message.<br />
<br />
=== Events ===<br />
When calling an alias from an event, the identifiers related to that event will still be available in that alias.<br />
on *:TEXT:hi:#: { myAlias }<br />
<br />
[[alias]] myAlias { [[msg]] [[$chan]] [[$nick]] said hi!<br />
<br />
This would be exactly the same as:<br />
on *:TEXT:hi:#: { [[msg]] [[$chan]] [[$nick]] said hi!<br />
This in turn means that you don't have to pass a identifier supplied by an event into your alias as parameter.<br />
<br />
== Commands vs identifiers ==<br />
Being that you can use your aliases as both commands as identifiers, the question may rise which you should pick. The general answer is quite simple: if you want your alias to have a return value use identifiers and in any other case use commands.<br />
<br />
=== Error handling ===<br />
However, mIRC's built-in error handling cannot be used for your aliases, so for proper error handling you might want to use return values. For example, you could use return value 1 when an action was succesfull and 0 when it was not.<br />
; this identifier returns 1 if it was succesfull in what it would do and 0 if it wasn't<br />
; the (useless) idea of the following identifier is to message "moo" to the currently active channel<br />
; if it is on QuakeNet<br />
[[alias]] moo {<br />
[[if]] ([[$network]] != QuakeNet) || (![[$chan]]) { [[return]] 0 }<br />
[[else]] {<br />
[[msg]] [[$chan]] moo<br />
[[return]] 1<br />
}<br />
}<br />
<br />
To use this as error handling you could do the following:<br />
%error = $moo<br />
[[if]] (!%error) {<br />
; do what you want to do if the command failed<br />
; in this case when there was no channel active<br />
; or the server was not QuakeNet<br />
}<br />
[[elseif]] (%error = 1) {<br />
; do what you want to do if the command succeeded<br />
; in this case when there was an active channel and<br />
; the server was QuakeNet<br />
}<br />
[[else]] {<br />
; the script should never reach this place!<br />
}<br />
Although the same identifier could have been run as a command as well, error handling would not have been possible that way. Of course the alias itself has some error handling already, but there are cases in which you want an action to be able to fail.<br />
<br />
Another reason to prefer identifiers over comands are parameters. When you call an alias as a command every space will result in a new parameter and there is no way you can get around that. Using an alias as an identifier it is possible to get around the comma and thus have your parameters contain a comma. Here's how to do that:<br />
; calling an identifier with a comma in a parameter<br />
[[alias]] test {<br />
; the while loop will echo every parameter<br />
[[var]] %i = $0<br />
[[while]] (%i)<br />
[[echo]] -ag $ [ $+ [ %i ] ]<br />
[[dec]] %i<br />
}<br />
}<br />
<br />
var %param = abcdef,ghijk<br />
%someVar = $test(%param)<br />
The snippets above would result in having the identifier $test echo only 1 parameter: the data which was set in %param. Would you do the same for a command -- replacing the comma with a space -- it would result in /test getting 2 parameters. Handling parameters is much easier if you are a 100% sure which parameter will contain which data, and an identifier is more reliable in doing so.<br />
<br />
=== Forced identifiers ===<br />
To force an alias to be an identifier -- it can't be used as a command -- or vice versa you can use the identifier [[$isid]].<br />
; this alias can only be called as an identifier<br />
[[alias]] qnet {<br />
if ([[$isid]]) {<br />
; the following code only gets executed if the alias was called as an identifier<br />
[[if]] ([[$network]] === QuakeNet) { [[return]] 1 }<br />
[[else]] { [[return]] 0 }<br />
}<br />
}<br />
Calling the alias will result in a return value of either 0 or 1, while calling it as a command will do completely nothing.<br />
[[Category:mIRC_Help]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Category:Aliases&diff=1329Category:Aliases2006-04-10T15:29:50Z<p>Shenghi: fixed some typos before dinner</p>
<hr />
<div>== Basic ==<br />
mIRC script allows you to create your own set of commands and identifiers, refered to as aliases. Aliases can be called from the command line, from other aliases, from popup and from remote scripts. An alias in mIRC can not be called recursively. They can be created by either putting them in the <nowiki>"Aliases"</nowiki> section of the mIRC Scripts Editor, by using the /alias command from either the command line or in the <nowiki>"Remote"</nowiki> section of the Scripts Editor. Creating an alias in the command line results in it being placed in the "Aliases" section of the Script Editor.<br />
<br />
=== Example ===<br />
; this is placed in the "Aliases" section<br />
moo { [[echo]] -ag moo }<br />
<br />
; this is placed in the "Remote" section<br />
[[alias]] moo { [[echo]] -ag moo }<br />
<br />
== Naming aliases ==<br />
You can give an alias virtualy any name you want, but keep a few things in mind:<br />
<br />
* When you give an alias used as a command the same name as an existing mIRC command, your alias gets preference.<br />
* When you give an alias used as an identifier the same name as an existing mIRC identifier, mIRC's identifier gets preference.<br />
<br />
== Aliases: parameters and events ==<br />
mIRC script allows you to pass parameters to your aliases, just like you pass parameters into built-in mIRC commands or identifiers. They can be referred to as $1, $2 ... $N.<br />
<br />
=== Parameters ===<br />
[[alias]] moo { echo -ag m $+ [[$str]](o,$$1)<br />
<br />
Assuming you pass a number as parameter this would echo an <nowiki>"m"</nowiki> folowed by a number of <nowiki>"o's"</nowiki>, depending on the number you specified as parameter. This alias can be called in 2 different ways:<br />
/moo 12<br />
$moo(27)<br />
Note that $moo doesn't return anything in this case, it will simply echo the message.<br />
<br />
=== Events ===<br />
When calling an alias from an event, the identifiers related to that event will still be available in that alias.<br />
on *:TEXT:hi:#: { myAlias }<br />
<br />
[[alias]] myAlias { [[msg]] [[$chan]] [[$nick]] said hi!<br />
<br />
This would be exactly the same as:<br />
on *:TEXT:hi:#: { [[msg]] [[$chan]] [[$nick]] said hi!<br />
This in turn means that you don't have to pass a identifier supplied by an event into your alias as parameter.<br />
<br />
[[Category:mIRC_Help]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=Category:Aliases&diff=1328Category:Aliases2006-04-10T15:23:52Z<p>Shenghi: First part, additions will be a quick look at $isid and /return</p>
<hr />
<div>== Basic ==<br />
mIRC script allows you to create your own set of commands and identifiers, refered to as aliases. Aliases can be called from the command line, from other aliases, from popup and from remote scripts. An alias in mIRC can not be called recursively. They can be created by either putting them in the <nowiki>"Aliases"</nowiki> section of the mIRC Scripts Editor or by using the /alias command from either the command line or in the <nowiki>"Remote"</nowiki> section of the Scripts Editor. Creating an alias in the command line results in it being placed in the "Aliases" section of the Script Editor.<br />
<br />
=== Example ===<br />
; this is placed in the "Aliases" section<br />
moo { [[echo]] -ag moo }<br />
<br />
; the is placed in the "Remote" section<br />
[[alias]] moo { [[echo]] -ag moo }<br />
<br />
== Naming aliases ==<br />
You can give an alias virtualy any name you want, but keep a few things in mind:<br />
<br />
* When you give an alias used as a command the same name as an existing mIRC command, your alias gets preference.<br />
* When you give an alias used as an identifier the same name as an existing mIRC identifier, mIRC's identifier gets preference.<br />
<br />
== Aliases: parameters and events ==<br />
mIRC script allows you to pass parameters to your aliases, just like you pass parameters into built-in mIRC commands or identifiers. They can be referred to as $1, $2 ... $N.<br />
<br />
=== Parameters ===<br />
[[alias]] moo { echo -ag m $+ [[$str]](o,$$1)<br />
<br />
Assuming you pass a number as parameter this would echo an <nowiki>"m"</nowiki> folowed by a number of <nowiki>"o's"</nowiki>, depending on the number you specified as parameter. This alias can be called in 2 different ways:<br />
/moo 12<br />
$moo(27)<br />
Note that $moo doesn't return anything in this case, it will simply echo the message.<br />
<br />
=== Events ===<br />
When calling an alias from an event, the identifiers related to that event will still be available in that alias.<br />
on *:TEXT:hi:#: { myAlias }<br />
<br />
[[alias]] myAlias { [[msg]] [[$chan]] [[$nick]] said hi!<br />
<br />
This would be exactly the same as:<br />
on *:TEXT:hi:#: { [[msg]] [[$chan]] [[$nick]] said hi!<br />
This in turn means that you don't have to pass a identifier supplied by an event into your alias as parameter.<br />
<br />
[[Category:mIRC_Help]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=$str&diff=4479$str2006-03-29T22:17:23Z<p>Shenghi: </p>
<hr />
<div>Returns text repeated N times.<br />
<br />
$str(text,N)<br />
== Example ==<br />
[[echo]] -ag $str(test,5)<br />
The above example would have ''testtesttesttesttest'' as output.<br />
== Example ==<br />
[[alias]] moo {<br />
[[var]] %i = $rand(5,10), %moo = m00<br />
[[while loops|while]] (%i) {<br />
[[var]] %moo = %moo $+ $iif($right(%moo,1) == o,$str(0,$rand(1,3)),$str(o,$rand(1,3)))<br />
[[dec]] %i<br />
}<br />
[[echo]] -ag %moo<br />
}<br />
Above is a more complicated example of using $str. In conjuction with [[$rand]] it adds a random number of ''o''<nowiki>'</nowiki>s and ''0''<nowiki>'</nowiki>s to the word ''m00''.<br />
Some possible outputs for this alias are:<br />
<br />
* ''m00o000o0o''<br />
* ''m00oo0oo000ooo00ooo000ooo''<br />
* ''m00oo0oo0ooo00''<br />
<br />
[[Category:Text and Number Identifiers]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=User:Shenghi&diff=1397User:Shenghi2006-03-29T21:19:17Z<p>Shenghi: </p>
<hr />
<div>{{Babel-2|nl|en-3}}<br />
<table border="0"><br />
<tr><br />
<!--<td>[[Image:Shenghi.jpg]]</td>--><br />
<td><br />
<table border="0"><br />
<tr><td><b>Name</b></td><td>Bart van Nierop</td></tr><br />
<tr><td><b>Age</b></td><td>22</td></tr><br />
<tr valign="top" height="40"><td><b>Country</b></td><td>Rotterdam, Netherlands</td></tr><br />
<br />
<tr><td><b>Words of wisdom</b></td><td>Then perhaps there is no great wisdom in that.</td></tr><br />
</table><br />
</td><br />
</tr><br />
</table><br />
[[Category:Members]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=User:Shenghi&diff=1317User:Shenghi2006-03-29T21:18:19Z<p>Shenghi: </p>
<hr />
<div>{{Babel-1|nl}}<br />
<table border="0"><br />
<tr><br />
<!--<td>[[Image:Shenghi.jpg]]</td>--><br />
<td><br />
<table border="0"><br />
<tr><td><b>Name</b></td><td>Bart van Nierop</td></tr><br />
<tr><td><b>Age</b></td><td>22</td></tr><br />
<tr valign="top" height="40"><td><b>Country</b></td><td>Rotterdam, Netherlands</td></tr><br />
<br />
<tr><td><b>Words of wisdom</b></td><td>Then perhaps there is no great wisdom in that.</td></tr><br />
</table><br />
</td><br />
</tr><br />
</table><br />
[[Category:Members]]</div>Shenghihttps://script.quakenet.org/wiki/index.php?title=User:Shenghi&diff=1316User:Shenghi2006-03-29T21:16:02Z<p>Shenghi: </p>
<hr />
<div>{{Babel-1|en}}<br />
<table border="0"><br />
<tr><br />
<!--<td>[[Image:Shenghi.jpg]]</td>--><br />
<td><br />
<table border="0"><br />
<tr><td><b>Name</b></td><td>Bart van Nierop</td></tr><br />
<tr><td><b>Age</b></td><td>22</td></tr><br />
<tr valign="top" height="40"><td><b>Country</b></td><td>Rotterdam, Netherlands</td></tr><br />
<br />
<tr><td><b>Words of wisdom</b></td><td>Then perhaps there is no great wisdom in that.</td></tr><br />
</table><br />
</td><br />
</tr><br />
</table><br />
[[Category:Members]]</div>Shenghi