Difference between revisions of "Do not Disturb - A QuakeNet pm blocker"
From Scriptwiki
(fixed a bug logging to @allscripts in RAW 315) |
(added menu items) |
||
Line 1: | Line 1: | ||
Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!''' | Do not Disturb is a QuakeNet pm blocker based on Q account. '''It will not work on other networks!''' | ||
− | ; - - - - - - - - - - - - - - - - - - - - - - - - - | + | ; - - - - - - - - - - - - - - - - - - - - - - - - - |
− | ; Do | + | ; Do Not Disturb |
− | ; | + | ; |
− | ; Written by Shenghi | + | ; Written by Bart 'Shenghi' van Nierop |
− | ; Contact at: | + | ; Contact at: |
− | ; #help.script @ irc.quakenet.org | + | ; #help.script @ irc.quakenet.org |
− | ; | + | ; |
− | ; dnd.mrc | + | ; dnd.mrc |
− | ; dnd.dnd | + | ; dnd.dnd |
− | ; dnd.ini | + | ; dnd.ini |
− | ; - - - - - - - - - - - - - - - - - - - - - - - - - | + | ; - - - - - - - - - - - - - - - - - - - - - - - - - |
− | ; A QuakeNet pm blocker based on Q auth | + | ; A QuakeNet pm blocker based on Q auth |
− | ; Usage: | + | ; Usage: |
− | ; /dnd [on|off|allow|block|remove | + | ; /dnd [on|off|allow|block|remove] |
− | ; if no argument is passed a configuration dialog will pop up | + | ; if no argument is passed a configuration dialog will pop up |
− | ; this is coming in a later version | + | ; this is coming in a later version |
− | ; | + | ; |
− | ; on|off turns pm blocking on or off | + | ; on|off turns pm blocking on or off |
− | ; | + | ; |
− | ; allow|block allows or blocks a Q auth | + | ; allow|block allows or blocks a Q auth |
− | ; | + | ; |
− | ; remove removes a Q auth | + | ; remove removes a Q auth |
− | ; - - - - - - - - - - - - - - - - - - - - - - - - - | + | ; - - - - - - - - - - - - - - - - - - - - - - - - - |
− | ; Version | + | ; Version 1.10 |
− | + | ; - - - - - - - - - - - - - - - - - - - - - - - - - | |
− | + | ||
− | ; - - - - - - - - - - - - - - - - - - - - - - - - - | + | |
− | + | ;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;; | |
− | + | ||
− | + | ;;;;;;;;;;; | |
− | + | ; on LOAD ; | |
− | + | ;;;;;;;;;;; | |
− | + | on *:load:{ | |
− | + | linesep -s | |
− | + | ||
− | + | ;; writing the default ini | |
− | + | if ($isfile(dnd.ini)) { | |
− | + | echo -s Settings file (dnd.ini) already exists. Unloading script... | |
− | + | unload -rs $script | |
− | + | linesep -s | |
− | + | return | |
− | + | } | |
− | ;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;; | + | |
− | + | writeini -n dnd.ini options cc block | |
− | ;;;;;;;;;;; | + | writeini -n dnd.ini options showcc false |
− | ; on LOAD ; | + | writeini -n dnd.ini options showblocked false |
− | ;;;;;;;;;;; | + | writeini -n dnd.ini options showaccepted true |
− | on *:load:{ | + | writeini -n dnd.ini options showunknown true |
− | linesep -s | + | writeini -n dnd.ini options blockunknown false |
− | + | writeini -n dnd.ini options echoactive true | |
− | ;; writing the default ini | + | writeini -n dnd.ini options nickcolor 1 |
− | if ($isfile(dnd.ini)) { | + | |
− | echo -s Settings file (dnd.ini) already exists. Unloading script... | + | echo -s Loaded Do Not Disturb |
− | unload -rs $script | + | linesep -s |
− | linesep -s | ||
− | return | ||
− | } | ||
− | |||
− | |||
− | writeini -n dnd.ini options cc block | ||
− | writeini -n dnd.ini options showcc false | ||
− | writeini -n dnd.ini options showblocked false | ||
− | writeini -n dnd.ini options showaccepted true | ||
− | writeini -n dnd.ini options showunknown true | ||
− | writeini -n dnd.ini options blockunknown false | ||
− | writeini -n dnd.ini options echoactive true | ||
− | writeini -n dnd.ini options nickcolor 1 | ||
− | |||
− | echo -s Loaded Do | ||
− | linesep -s | ||
} | } | ||
− | + | ||
− | + | ||
− | ;;;;;;;;;;;; | + | ;;;;;;;;;;;; |
− | ; on START ; | + | ; on START ; |
− | ;;;;;;;;;;;; | + | ;;;;;;;;;;;; |
− | on *:start:{ | + | on *:start:{ |
− | ; free and create hDnd hashtable | + | ; free and create hDnd hashtable |
− | if ($hget(hDnd)) hfree hDnd | + | if ($hget(hDnd)) hfree hDnd |
hmake hDnd | hmake hDnd | ||
− | + | ||
− | ; if dnd.dnd file exists, load allow/block hashtables | + | ; if dnd.dnd file exists, load allow/block hashtables |
− | if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd | + | if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd |
− | } | + | } |
− | + | ||
− | + | ||
− | ;;;;;;;;;;; | + | ;;;;;;;;;;; |
− | ; on OPEN ; | + | ; on OPEN ; |
− | ;;;;;;;;;;; | + | ;;;;;;;;;;; |
− | on ^*:OPEN:?:{ | + | on ^*:OPEN:?:{ |
− | ;; check if it happens on QNet | + | ;; check if it happens on QNet |
if (*.??.quakenet.org !iswm $server) || (%dnd == off) return | if (*.??.quakenet.org !iswm $server) || (%dnd == off) return | ||
− | + | ||
− | ;; notice the user that his query is pending | + | ;; notice the user that his query is pending |
− | .notice $nick Query pending... | + | .notice $nick Query pending... |
− | + | ||
− | ;; halt the default opening of the window | + | ;; halt the default opening of the window |
− | haltdef | + | haltdef |
− | + | ||
− | ;; check for control codes -- this should block most porn spam | + | ;; check for control codes -- this should block most porn spam |
− | if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) { | + | if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) { |
− | dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.) | + | dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.) |
− | .notice $nick Query denied, message blocked. | + | .notice $nick Query denied, message blocked. |
} | } | ||
− | + | ||
− | ;; now it's time to check regular messages | + | ;; now it's time to check regular messages |
− | ;; first, the easy part -- check if the user has usermode +x and if so | + | ;; first, the easy part -- check if the user has usermode +x and if so |
− | ;; use it to extract the Q auth | + | ;; use it to extract the Q auth |
if ($right($site,19) == .users.quakenet.org) { | if ($right($site,19) == .users.quakenet.org) { | ||
− | + | ||
− | ;; $gettok($site,1,46) holds the users Q auth | + | ;; $gettok($site,1,46) holds the users Q auth |
− | ;; if the user is allowed to message, notice the query is accepted and let the query window open | + | ;; if the user is allowed to message, notice the query is accepted and let the query window open |
− | if ($hget(hDnd,$gettok($site,1,46)) == allow) { | + | if ($hget(hDnd,$gettok($site,1,46)) == allow) { |
− | dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) | + | dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) |
− | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) | + | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) |
− | query -n $nick | + | query -n $nick |
− | echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- | + | echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- |
− | window -g[1] $nick | + | window -g[1] $nick |
− | .notice $nick Query accepted. | + | .notice $nick Query accepted. |
− | } | + | } |
− | elseif ($hget(hDnd,$gettok($site,1,46)) == block) { | + | elseif ($hget(hDnd,$gettok($site,1,46)) == block) { |
− | dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.) | + | dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.) |
− | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ ) | + | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ ) |
− | .notice $nick Query denied, message blocked. | + | .notice $nick Query denied, message blocked. |
− | } | + | } |
− | + | ||
− | ;; if a user is unknown we let faith (read: options) decide whether to accept or decline | + | ;; if a user is unknown we let faith (read: options) decide whether to accept or decline |
− | else { | + | else { |
− | if ($readini(dnd.ini,options,blockunknown) == true) { | + | if ($readini(dnd.ini,options,blockunknown) == true) { |
− | dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.) | + | dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.) |
− | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ ) | + | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ ) |
− | .notice $nick Query denied. | + | .notice $nick Query denied. |
− | } | + | } |
− | else { | + | else { |
− | dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) | + | dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) |
− | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) | + | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) |
− | query -n $nick | + | query -n $nick |
− | echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- | + | echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- |
− | window -g[1] $nick | + | window -g[1] $nick |
− | .notice $nick Query accepted. | + | .notice $nick Query accepted. |
− | } | + | } |
− | } | + | } |
− | + | ||
− | ;; closing if ($right($site,19) == .users.quakenet.org) | + | ;; closing if ($right($site,19) == .users.quakenet.org) |
− | } | + | } |
− | + | ||
− | ;; if the user wasn't using usermode +x we store the message and send a who to the server | + | ;; if the user wasn't using usermode +x we store the message and send a who to the server |
− | ;; the query window remains closed so far, we can always open it later if the user is allowed to pm | + | ;; the query window remains closed so far, we can always open it later if the user is allowed to pm |
− | else { | + | else { |
− | set %dndQueryAuth [ $+ [ $nick ] ] 1 | + | set %dndQueryAuth [ $+ [ $nick ] ] 1 |
− | set %dndQueryMessage [ $+ [ $nick ] ] $1- | + | set %dndQueryMessage [ $+ [ $nick ] ] $1- |
− | set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress | + | set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress |
− | who $nick n%nat,990 | + | who $nick n%nat,990 |
− | + | ||
− | } | + | } |
− | } | + | } |
− | + | ||
− | ;;;;;;;;;;; | + | ;;;;;;;;;;; |
− | ; RAW 354 ; | + | ; RAW 354 ; |
− | ;;;;;;;;;;; | + | ;;;;;;;;;;; |
− | + | ||
− | ;; RAW 354 is the servers answer to the who request | + | ;; RAW 354 is the servers answer to the who request |
− | ;; reference 990 is used to make sure it came from the on OPEN event | + | ;; reference 990 is used to make sure it came from the on OPEN event |
− | ;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1 | + | ;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1 |
− | raw 354:& 990 & *: { | + | raw 354:& 990 & *: { |
− | set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1) | + | set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1) |
− | halt | + | halt |
− | } | + | } |
− | + | ||
− | ;; | + | ;; reference 991 is used to make sure the raw reply comes from a menu request |
− | + | raw 354:& 991 & *:{ | |
− | ;;;;;;;;;;; | + | set %dndAddAuth [ $+ [ $3 ] ] $iif($4,$v1,1) |
− | + | halt | |
− | ;; | + | } |
− | raw 315:*:{ | + | |
− | ;;;;;;;;;;;;;;;;; | + | ;;;;;;;;;;; |
− | ; QUERY REQUEST ; | + | ; RAW 315 ; |
− | ;;;;;;;;;;;;;;;;; | + | ;;;;;;;;;;; |
− | if (%dndQueryAuth [ $+ [ $2 ] ]) { | + | |
− | + | ;; unfortunately, raw 315 (End of /WHO list) does not have this reference | |
− | ;; if the user was authed | + | raw 315:*:{ |
− | if ($v1 != 1) { | + | ;;;;;;;;;;;;;;;;; |
− | + | ; QUERY REQUEST ; | |
− | ;; run the same check as in the on OPEN event | + | ;;;;;;;;;;;;;;;;; |
− | if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) { | + | if (%dndQueryAuth [ $+ [ $2 ] ]) { |
− | dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) | + | |
− | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) | + | ;; if the user was authed |
− | query -n $2 | + | if ($v1 != 1) { |
− | echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] | + | |
− | window -g[1] $2 | + | ;; run the same check as in the on OPEN event |
− | .notice $2 Query accepted. | + | if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) { |
− | } | + | dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) |
− | elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) { | + | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) |
− | dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) | + | query -n $2 |
− | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) | + | echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] |
− | .notice $2 Query denied, message blocked. | + | window -g[1] $2 |
− | } | + | .notice $2 Query accepted. |
− | + | } | |
− | ;; if a user is unknown we let faith (read: options) decide whether to accept or decline | + | elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) { |
− | else { | + | dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) |
− | if ($readini(dnd.ini,options,blockunknown) == true) { | + | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) |
− | dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) | + | .notice $2 Query denied, message blocked. |
− | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) | + | } |
− | .notice $2 Query denied. | + | |
− | } | + | ;; if a user is unknown we let faith (read: options) decide whether to accept or decline |
− | else { | + | else { |
− | dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) | + | if ($readini(dnd.ini,options,blockunknown) == true) { |
− | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) | + | dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) |
− | query -n $2 | + | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) |
− | echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] | + | .notice $2 Query denied. |
− | window -g[1] $2 | + | } |
− | .notice $2 Query accepted. | + | else { |
− | } | + | dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) |
− | } | + | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) |
− | } | + | query -n $2 |
− | + | echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] | |
− | ;; if the user was not authed | + | window -g[1] $2 |
− | else { | + | .notice $2 Query accepted. |
− | if ($readini(dnd.ini,options,blockunknown) == true) { | + | } |
− | dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) | + | } |
− | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) | + | } |
− | .notice $2 Query denied. | + | |
− | } | + | ;; if the user was not authed |
− | else { | + | else { |
− | dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) | + | if ($readini(dnd.ini,options,blockunknown) == true) { |
− | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) | + | dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) |
− | query -n $2 | + | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) |
− | echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] | + | .notice $2 Query denied. |
− | window -g[1] $2 | + | } |
− | .notice $2 Query accepted. | + | else { |
− | } | + | dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) |
− | } | + | if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) |
− | unset %dndQueryAuth [ $+ [ $2 ] ] | + | query -n $2 |
− | unset %dndQueryMessage [ $+ [ $2 ] ] | + | echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] |
− | unset %dndQueryFulladdress [ $+ [ $2 ] ] | + | window -g[1] $2 |
− | } | + | .notice $2 Query accepted. |
− | + | } | |
− | + | } | |
− | + | unset %dndQueryAuth [ $+ [ $2 ] ] | |
− | + | unset %dndQueryMessage [ $+ [ $2 ] ] | |
− | + | unset %dndQueryFulladdress [ $+ [ $2 ] ] | |
− | + | } | |
− | + | ||
− | + | ;;;;;;;;;;;; | |
− | + | ; ADD USER ; | |
− | + | ;;;;;;;;;;;; | |
− | + | elseif (%dndAddAuth [ $+ [ $2 ] ]) { | |
− | + | if ($v1 != 1) { | |
− | + | if (%dndAddAction [ $+ [ $2 ] ] == remove) { | |
− | + | hdel hDnd %dndAddAuth [ $+ [ $2 ] ] | |
− | + | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth %dndAddAuth [ $+ [ $2 ] ] | |
− | + | hsave -b hDnd dnd.dnd | |
− | + | } | |
− | + | else { | |
− | + | hadd hDnd %dndAddAuth [ $+ [ $2 ] ] %dndAddAction [ $+ [ $2 ] ] | |
− | + | hsave -b hDnd dnd.dnd | |
− | + | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif(%dndAddAction [ $+ [ $2 ] ] == allow,Allowing,Blocking) queries from Q auth %dndAddAuth [ $+ [ $2 ] ] | |
− | + | } | |
− | + | } | |
− | + | else echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� User not authed with Q. | |
− | + | unset %dndAddAuth [ $+ [ $2 ] ] | |
− | + | unset %dndAddAction [ $+ [ $2 ] ] | |
− | + | } | |
− | } | + | halt |
− | + | } | |
− | + | ||
− | + | ||
− | + | ;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; | |
− | + | ||
− | + | ;;;;;;; | |
− | + | ; DND ; | |
− | + | ;;;;;;; | |
− | + | alias dnd { | |
− | ;;;;;;; | + | ;; syntax check |
− | + | ;; turn dnd on/off | |
− | + | if ($regex($1-,/^(on|off)$/)) { | |
− | + | set %dnd $regml(1) | |
− | if ( | + | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off) |
− | + | } | |
− | + | ;; allow/block a user | |
− | + | elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) { | |
− | + | hadd hDnd $regml(2) $regml(1) | |
− | + | hsave -b hDnd dnd.dnd | |
− | + | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2) | |
− | + | } | |
− | + | ;; remove a user | |
+ | elseif ($regex($1-,/^remove\s(\w+)$/)) { | ||
+ | hdel hDnd $regml(1) | ||
+ | hsave -b hDnd dnd.dnd | ||
+ | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1) | ||
+ | } | ||
+ | ;; dialog | ||
+ | elseif (!$0) { } | ||
+ | ;; else the syntax is wrong -- output an error | ||
+ | else echo -s * /dnd - Error: erronious syntax. | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | ;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; | ||
+ | |||
+ | ;;;;;;;;;;;; | ||
+ | ; dnd_echo ; | ||
+ | ;;;;;;;;;;;; | ||
+ | alias -l dnd_echo { | ||
+ | if (!$window(@AllScripts)) { window -hk0nx @AllScripts } | ||
+ | echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1- | ||
+ | } | ||
+ | |||
+ | |||
+ | ;;;;;;;;;;;;;;;;;;;;; | ||
+ | ; dndMenuQueryAllow ; | ||
+ | ;;;;;;;;;;;;;;;;;;;;; | ||
+ | alias -l dndMenuQueryAllow { | ||
+ | ;; check for mode +x | ||
+ | if ($right($ial($1).host,19) == .users.quakenet.org) { | ||
+ | ;; get Q auth from address and add it to hDnd | ||
+ | hadd hDnd $gettok($ial($1).host,1,46) allow | ||
+ | hsave -b hDnd dnd.dnd | ||
+ | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial($1).host,1,46) | ||
+ | } | ||
+ | ;; if the user did not have mode +x do a /WHO | ||
+ | else { | ||
+ | set %dndAddAuth [ $+ [ $1 ] ] 1 | ||
+ | set %dndAddAction [ $+ [ $1 ] ] allow | ||
+ | who $1 n%nat,991 | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ;;;;;;;;;;;;;;;;;;;;; | ||
+ | ; dndMenuQueryBlock ; | ||
+ | ;;;;;;;;;;;;;;;;;;;;; | ||
+ | alias -l dndMenuQueryBlock { | ||
+ | ;; check for mode +x | ||
+ | if ($right($ial($1).host,19) == .users.quakenet.org) { | ||
+ | ;; get Q auth from address and add it to hDnd | ||
+ | hadd hDnd $gettok($ial($1).host,1,46) block | ||
+ | hsave -b hDnd dnd.dnd | ||
+ | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial($1).host,1,46) | ||
+ | } | ||
+ | ;; if the user did not have mode +x do a /WHO | ||
+ | else { | ||
+ | set %dndAddAuth [ $+ [ $1 ] ] 1 | ||
+ | set %dndAddAction [ $+ [ $1 ] ] block | ||
+ | who $1 n%nat,991 | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ;;;;;;;;;;;;;;;;;;;;;; | ||
+ | ; dndMenuQueryRemove ; | ||
+ | ;;;;;;;;;;;;;;;;;;;;;; | ||
+ | alias -l dndMenuQueryRemove { | ||
+ | ;; check for mode +x | ||
+ | if ($right($ial($1).host,19) == .users.quakenet.org) { | ||
+ | ;; get Q auth from address and delete it from hDnd | ||
+ | hdel hDnd $gettok($ial($1).host,1,46) | ||
+ | hsave -b hDnd dnd.dnd | ||
+ | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial($1).host,1,46) | ||
+ | } | ||
+ | ;; if the user did not have mode +x do a /WHO | ||
+ | else { | ||
+ | set %dndAddAuth [ $+ [ $1 ] ] 1 | ||
+ | set %dndAddAction [ $+ [ $1 ] ] remove | ||
+ | who $1 n%nat,991 | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ;;;;; To prevent possible flooding, only 5 nicks will be allowed/blocked/removed at a time ;;;;; | ||
+ | ;;;;;;;;;;;;;;;;;;;;;;;; | ||
+ | ; dndMenuNicklistAllow ; | ||
+ | ;;;;;;;;;;;;;;;;;;;;;;;; | ||
+ | alias -l dndMenuNicklistAllow { | ||
+ | var %i = 1 | ||
+ | while ($gettok($1-,%i,32)) { | ||
+ | var %nick = $v1 | ||
+ | ;; check for mode +x | ||
+ | if ($right($ial(%nick).host,19) == .users.quakenet.org) { | ||
+ | ;; get Q auth from address and add it to hDnd | ||
+ | hadd hDnd $gettok($ial(%nick).host,1,46) allow | ||
+ | hsave -b hDnd dnd.dnd | ||
+ | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial(%nick).host,1,46) | ||
+ | } | ||
+ | ;; if the user did not have mode +x do a /WHO | ||
+ | else { | ||
+ | set %dndAddAuth [ $+ [ %nick ] ] 1 | ||
+ | set %dndAddAction [ $+ [ %nick ] ] allow | ||
+ | who %nick n%nat,991 | ||
+ | } | ||
+ | inc %i | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ;;;;;;;;;;;;;;;;;;;;;;;; | ||
+ | ; dndMenuNicklistBlock ; | ||
+ | ;;;;;;;;;;;;;;;;;;;;;;;; | ||
+ | alias -l dndMenuNicklistBlock { | ||
+ | var %i = 1 | ||
+ | while ($gettok($1-,%i,32)) { | ||
+ | var %nick = $v1 | ||
+ | ;; check for mode +x | ||
+ | if ($right($ial(%nick).host,19) == .users.quakenet.org) { | ||
+ | ;; get Q auth from address and add it to hDnd | ||
+ | hadd hDnd $gettok($ial(%nick).host,1,46) block | ||
+ | hsave -b hDnd dnd.dnd | ||
+ | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial(%nick).host,1,46) | ||
+ | } | ||
+ | ;; if the user did not have mode +x do a /WHO | ||
+ | else { | ||
+ | set %dndAddAuth [ $+ [ %nick ] ] 1 | ||
+ | set %dndAddAction [ $+ [ %nick ] ] block | ||
+ | who %nick n%nat,991 | ||
+ | } | ||
+ | inc %i | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ;;;;;;;;;;;;;;;;;;;;;;;;; | ||
+ | ; dndMenuNicklistRemove ; | ||
+ | ;;;;;;;;;;;;;;;;;;;;;;;;; | ||
+ | alias -l dndMenuNicklistRemove { | ||
+ | var %i = 1 | ||
+ | while ($gettok($1-,%i,32)) { | ||
+ | var %nick = $v1 | ||
+ | ;; check for mode +x | ||
+ | if ($right($ial(%nick).host,19) == .users.quakenet.org) { | ||
+ | ;; get Q auth from address and add it to hDnd | ||
+ | hdel hDnd $gettok($ial(%nick).host,1,46) | ||
+ | hsave -b hDnd dnd.dnd | ||
+ | echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial(%nick).host,1,46) | ||
+ | } | ||
+ | ;; if the user did not have mode +x do a /WHO | ||
+ | else { | ||
+ | set %dndAddAuth [ $+ [ %nick ] ] 1 | ||
+ | set %dndAddAction [ $+ [ %nick ] ] Remove | ||
+ | who %nick n%nat,991 | ||
+ | } | ||
+ | inc %i | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | ;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;; | ||
+ | menu channel,status { | ||
+ | - | ||
+ | DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on) | ||
+ | } | ||
+ | |||
+ | menu query { | ||
+ | - | ||
+ | DnD | ||
+ | .Allow:dndMenuQueryAllow $1 | ||
+ | .Block:dndMenuQueryBlock $1 | ||
+ | .Remove:dndMenuQueryRemove $1 | ||
+ | } | ||
+ | |||
+ | menu nicklist { | ||
+ | - | ||
+ | DnD | ||
+ | .Allow:dndMenuNicklistAllow $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) | ||
+ | .Block:dndMenuNicklistBlock $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) | ||
+ | .Remove:dndMenuNicklistRemove $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) | ||
} | } | ||
[[Category:Script Archive]] | [[Category:Script Archive]] |
Revision as of 22:04, 23 April 2006
Do not Disturb is a QuakeNet pm blocker based on Q account. It will not work on other networks!
; - - - - - - - - - - - - - - - - - - - - - - - - - ; Do Not Disturb ; ; Written by Bart 'Shenghi' van Nierop ; Contact at: ; #help.script @ irc.quakenet.org ; ; dnd.mrc ; dnd.dnd ; dnd.ini ; - - - - - - - - - - - - - - - - - - - - - - - - - ; A QuakeNet pm blocker based on Q auth ; Usage: ; /dnd [on|off|allow|block|remove] ; if no argument is passed a configuration dialog will pop up ; this is coming in a later version ; ; on|off turns pm blocking on or off ; ; allow|block allows or blocks a Q auth ; ; remove removes a Q auth ; - - - - - - - - - - - - - - - - - - - - - - - - - ; Version 1.10 ; - - - - - - - - - - - - - - - - - - - - - - - - - ;;;;;;;;;;;;;;;;;;;;;;;;; EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;; ; on LOAD ; ;;;;;;;;;;; on *:load:{ linesep -s ;; writing the default ini if ($isfile(dnd.ini)) { echo -s Settings file (dnd.ini) already exists. Unloading script... unload -rs $script linesep -s return } writeini -n dnd.ini options cc block writeini -n dnd.ini options showcc false writeini -n dnd.ini options showblocked false writeini -n dnd.ini options showaccepted true writeini -n dnd.ini options showunknown true writeini -n dnd.ini options blockunknown false writeini -n dnd.ini options echoactive true writeini -n dnd.ini options nickcolor 1 echo -s Loaded Do Not Disturb linesep -s } ;;;;;;;;;;;; ; on START ; ;;;;;;;;;;;; on *:start:{ ; free and create hDnd hashtable if ($hget(hDnd)) hfree hDnd hmake hDnd ; if dnd.dnd file exists, load allow/block hashtables if ($isfile(dnd.dnd)) hload -b hDnd dnd.dnd } ;;;;;;;;;;; ; on OPEN ; ;;;;;;;;;;; on ^*:OPEN:?:{ ;; check if it happens on QNet if (*.??.quakenet.org !iswm $server) || (%dnd == off) return ;; notice the user that his query is pending .notice $nick Query pending... ;; halt the default opening of the window haltdef ;; check for control codes -- this should block most porn spam if ($strip($1-) != $1-) && ($readini(dnd.ini,options,cc) == block) { dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) containing control codes $+ $iif($readini(dnd.ini,options,showcc) == true,: $1-,.) .notice $nick Query denied, message blocked. } ;; now it's time to check regular messages ;; first, the easy part -- check if the user has usermode +x and if so ;; use it to extract the Q auth if ($right($site,19) == .users.quakenet.org) { ;; $gettok($site,1,46) holds the users Q auth ;; if the user is allowed to message, notice the query is accepted and let the query window open if ($hget(hDnd,$gettok($site,1,46)) == allow) { dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) query -n $nick echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- window -g[1] $nick .notice $nick Query accepted. } elseif ($hget(hDnd,$gettok($site,1,46)) == block) { dnd_echo Blocked query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: $1-,.) if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $nick ( $+ $fulladdress $+ ) .notice $nick Query denied, message blocked. } ;; if a user is unknown we let faith (read: options) decide whether to accept or decline else { if ($readini(dnd.ini,options,blockunknown) == true) { dnd_echo Denied query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: $1-,.) if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $nick ( $+ $fulladdress $+ ) .notice $nick Query denied. } else { dnd_echo Accepted query from $nick ( $+ $fulladdress $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: $1-,.) if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $nick ( $+ $fulladdress $+ ) query -n $nick echo $nick $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $nick $+ � $+ > $1- window -g[1] $nick .notice $nick Query accepted. } } ;; closing if ($right($site,19) == .users.quakenet.org) } ;; if the user wasn't using usermode +x we store the message and send a who to the server ;; the query window remains closed so far, we can always open it later if the user is allowed to pm else { set %dndQueryAuth [ $+ [ $nick ] ] 1 set %dndQueryMessage [ $+ [ $nick ] ] $1- set %dndQueryFulladdress [ $+ [ $nick ] ] $fulladdress who $nick n%nat,990 } } ;;;;;;;;;;; ; RAW 354 ; ;;;;;;;;;;; ;; RAW 354 is the servers answer to the who request ;; reference 990 is used to make sure it came from the on OPEN event ;; if the user is authed with Q %dndQueryAuth [ $+ [ $nick ] ] is set to the auth, if he is not it remains 1 raw 354:& 990 & *: { set %dndQueryAuth [ $+ [ $3 ] ] $iif($4,$v1,1) halt } ;; reference 991 is used to make sure the raw reply comes from a menu request raw 354:& 991 & *:{ set %dndAddAuth [ $+ [ $3 ] ] $iif($4,$v1,1) halt } ;;;;;;;;;;; ; RAW 315 ; ;;;;;;;;;;; ;; unfortunately, raw 315 (End of /WHO list) does not have this reference raw 315:*:{ ;;;;;;;;;;;;;;;;; ; QUERY REQUEST ; ;;;;;;;;;;;;;;;;; if (%dndQueryAuth [ $+ [ $2 ] ]) { ;; if the user was authed if ($v1 != 1) { ;; run the same check as in the on OPEN event if ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == allow) { dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) query -n $2 echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] window -g[1] $2 .notice $2 Query accepted. } elseif ($hget(hDnd,%dndQueryAuth [ $+ [ $2 ] ]) == block) { dnd_echo Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showblocked) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Blocked query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) .notice $2 Query denied, message blocked. } ;; if a user is unknown we let faith (read: options) decide whether to accept or decline else { if ($readini(dnd.ini,options,blockunknown) == true) { dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) .notice $2 Query denied. } else { dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) query -n $2 echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] window -g[1] $2 .notice $2 Query accepted. } } } ;; if the user was not authed else { if ($readini(dnd.ini,options,blockunknown) == true) { dnd_echo Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showunknown) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Denied query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) .notice $2 Query denied. } else { dnd_echo Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) $+ $iif($readini(dnd.ini,options,showaccepted) == true,: %dndQueryMessage [ $+ [ $2 ] ],.) if ($readini(dnd.ini,options,echoactive) == true) && (!$away) echo -ta �[ DND ]� Accepted query from $2 ( $+ %dndQueryFulladdress [ $+ [ $2 ] ] $+ ) query -n $2 echo $2 $timestamp < $+ � $+ $readini(dnd.ini,options,nickcolor) $+ $2 $+ � $+ > %dndQueryMessage [ $+ [ $2 ] ] window -g[1] $2 .notice $2 Query accepted. } } unset %dndQueryAuth [ $+ [ $2 ] ] unset %dndQueryMessage [ $+ [ $2 ] ] unset %dndQueryFulladdress [ $+ [ $2 ] ] } ;;;;;;;;;;;; ; ADD USER ; ;;;;;;;;;;;; elseif (%dndAddAuth [ $+ [ $2 ] ]) { if ($v1 != 1) { if (%dndAddAction [ $+ [ $2 ] ] == remove) { hdel hDnd %dndAddAuth [ $+ [ $2 ] ] echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth %dndAddAuth [ $+ [ $2 ] ] hsave -b hDnd dnd.dnd } else { hadd hDnd %dndAddAuth [ $+ [ $2 ] ] %dndAddAction [ $+ [ $2 ] ] hsave -b hDnd dnd.dnd echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif(%dndAddAction [ $+ [ $2 ] ] == allow,Allowing,Blocking) queries from Q auth %dndAddAuth [ $+ [ $2 ] ] } } else echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� User not authed with Q. unset %dndAddAuth [ $+ [ $2 ] ] unset %dndAddAction [ $+ [ $2 ] ] } halt } ;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; ; DND ; ;;;;;;; alias dnd { ;; syntax check ;; turn dnd on/off if ($regex($1-,/^(on|off)$/)) { set %dnd $regml(1) echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Do Not Disturb turned $iif($regml(1) == on,on,off) } ;; allow/block a user elseif ($regex($1-,/^(allow|block)\s(\w+)$/)) { hadd hDnd $regml(2) $regml(1) hsave -b hDnd dnd.dnd echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� $iif($regml(1) == allow,Allowing,Blocking) queries from Q auth $regml(2) } ;; remove a user elseif ($regex($1-,/^remove\s(\w+)$/)) { hdel hDnd $regml(1) hsave -b hDnd dnd.dnd echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $regml(1) } ;; dialog elseif (!$0) { } ;; else the syntax is wrong -- output an error else echo -s * /dnd - Error: erronious syntax. } ;;;;;;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;; ; dnd_echo ; ;;;;;;;;;;;; alias -l dnd_echo { if (!$window(@AllScripts)) { window -hk0nx @AllScripts } echo @Allscripts � $+ $color(normal text) $+ $timestamp � $+ $color(info2 text) $+ $chr(91) DND $chr(93) � $+ $color(normal text) $+ $1- } ;;;;;;;;;;;;;;;;;;;;; ; dndMenuQueryAllow ; ;;;;;;;;;;;;;;;;;;;;; alias -l dndMenuQueryAllow { ;; check for mode +x if ($right($ial($1).host,19) == .users.quakenet.org) { ;; get Q auth from address and add it to hDnd hadd hDnd $gettok($ial($1).host,1,46) allow hsave -b hDnd dnd.dnd echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial($1).host,1,46) } ;; if the user did not have mode +x do a /WHO else { set %dndAddAuth [ $+ [ $1 ] ] 1 set %dndAddAction [ $+ [ $1 ] ] allow who $1 n%nat,991 } } ;;;;;;;;;;;;;;;;;;;;; ; dndMenuQueryBlock ; ;;;;;;;;;;;;;;;;;;;;; alias -l dndMenuQueryBlock { ;; check for mode +x if ($right($ial($1).host,19) == .users.quakenet.org) { ;; get Q auth from address and add it to hDnd hadd hDnd $gettok($ial($1).host,1,46) block hsave -b hDnd dnd.dnd echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial($1).host,1,46) } ;; if the user did not have mode +x do a /WHO else { set %dndAddAuth [ $+ [ $1 ] ] 1 set %dndAddAction [ $+ [ $1 ] ] block who $1 n%nat,991 } } ;;;;;;;;;;;;;;;;;;;;;; ; dndMenuQueryRemove ; ;;;;;;;;;;;;;;;;;;;;;; alias -l dndMenuQueryRemove { ;; check for mode +x if ($right($ial($1).host,19) == .users.quakenet.org) { ;; get Q auth from address and delete it from hDnd hdel hDnd $gettok($ial($1).host,1,46) hsave -b hDnd dnd.dnd echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial($1).host,1,46) } ;; if the user did not have mode +x do a /WHO else { set %dndAddAuth [ $+ [ $1 ] ] 1 set %dndAddAction [ $+ [ $1 ] ] remove who $1 n%nat,991 } } ;;;;; To prevent possible flooding, only 5 nicks will be allowed/blocked/removed at a time ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;; ; dndMenuNicklistAllow ; ;;;;;;;;;;;;;;;;;;;;;;;; alias -l dndMenuNicklistAllow { var %i = 1 while ($gettok($1-,%i,32)) { var %nick = $v1 ;; check for mode +x if ($right($ial(%nick).host,19) == .users.quakenet.org) { ;; get Q auth from address and add it to hDnd hadd hDnd $gettok($ial(%nick).host,1,46) allow hsave -b hDnd dnd.dnd echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Allowing queries from Q auth $gettok($ial(%nick).host,1,46) } ;; if the user did not have mode +x do a /WHO else { set %dndAddAuth [ $+ [ %nick ] ] 1 set %dndAddAction [ $+ [ %nick ] ] allow who %nick n%nat,991 } inc %i } } ;;;;;;;;;;;;;;;;;;;;;;;; ; dndMenuNicklistBlock ; ;;;;;;;;;;;;;;;;;;;;;;;; alias -l dndMenuNicklistBlock { var %i = 1 while ($gettok($1-,%i,32)) { var %nick = $v1 ;; check for mode +x if ($right($ial(%nick).host,19) == .users.quakenet.org) { ;; get Q auth from address and add it to hDnd hadd hDnd $gettok($ial(%nick).host,1,46) block hsave -b hDnd dnd.dnd echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Blocking queries from Q auth $gettok($ial(%nick).host,1,46) } ;; if the user did not have mode +x do a /WHO else { set %dndAddAuth [ $+ [ %nick ] ] 1 set %dndAddAction [ $+ [ %nick ] ] block who %nick n%nat,991 } inc %i } } ;;;;;;;;;;;;;;;;;;;;;;;;; ; dndMenuNicklistRemove ; ;;;;;;;;;;;;;;;;;;;;;;;;; alias -l dndMenuNicklistRemove { var %i = 1 while ($gettok($1-,%i,32)) { var %nick = $v1 ;; check for mode +x if ($right($ial(%nick).host,19) == .users.quakenet.org) { ;; get Q auth from address and add it to hDnd hdel hDnd $gettok($ial(%nick).host,1,46) hsave -b hDnd dnd.dnd echo - $+ $iif($readini(dnd.ini,options,echoactive) == true,ta,s) �[ DND ]� Removed Q auth $gettok($ial(%nick).host,1,46) } ;; if the user did not have mode +x do a /WHO else { set %dndAddAuth [ $+ [ %nick ] ] 1 set %dndAddAction [ $+ [ %nick ] ] Remove who %nick n%nat,991 } inc %i } } ;;;;;;;;;;;;;;;;;;;;;;;;; MENU ITEMS ;;;;;;;;;;;;;;;;;;;;;;;;; menu channel,status { - DnD $iif(%dnd == on,off,on):dnd $iif(%dnd == on,off,on) } menu query { - DnD .Allow:dndMenuQueryAllow $1 .Block:dndMenuQueryBlock $1 .Remove:dndMenuQueryRemove $1 } menu nicklist { - DnD .Allow:dndMenuNicklistAllow $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) .Block:dndMenuNicklistBlock $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) .Remove:dndMenuNicklistRemove $snick(#,1) $snick(#,2) $snick(#,3) $snick(#,4) $snick(#,5) }