Skip to content

Instantly share code, notes, and snippets.

@a-raccoon a-raccoon/r_ialfill_auto.mrc Secret
Last active Jan 10, 2019

Embed
What would you like to do?
IAL Auto Fill for mIRC
; r_ialfill_auto.mrc by Raccoon Feb-2017 Dec-2018
; Needs testing. Give feedback. 12/12/2018
; https://gist.github.com/a-raccoon/004dcff7c79bebd15d03387e7d2590bf
; Synchronizes your IAL (Internal Address List) via the /WHO command.
; Synchronizes your IBL (Internal Ban Lists) via /MODE [+bqeI] command.
; If you want to see what's going on, type /ialfill_debug
; Make sure your IAL is turned on with '/ial on', or only the IBL will work.
; These timing settings are conservative and make allowance for unforseeable lag.
ALIAS -l SETTINGS.IALFILL.ON return $true | ; should we fill the IAL?
ALIAS -l SETTINGS.IBLFILL.ON return $true | ; should we fill the IBL?
ALIAS -l SETTINGS.ONLY-OPPED.ON return $false | ; but only in channels we are opped in? (set to $false for all chans)
ALIAS -l SETTINGS.CONNECT.DELAY return 120 | ; wait this long after [re]connect
ALIAS -l SETTINGS.JOIN-OP.DELAY return 60 | ; wait this long after last join or being opped
ALIAS -l SETTINGS.NEXTFILL.DELAY return 15 | ; wait this long between each IAL or IBL fill request
; Use /ialfill_debug to watch all the excitement unfold.
ALIAS ialfill_debug { window -aDoe2iz @ialfill }
; /ialfill_auto is automatically triggered after any of the following events, after a short delay.
; 366 'End of /NAMES list.' (you joined a new channel)
; 315 'End of /WHO list.' (we previously /ialfilled a channel)
; 368 'End of Channel Ban List' (we previously looked up the banlists of a channel)
; 729 'End of Channel Quiet List'
; 349 'End of Channel Exception List'
; 347 'End of Channel Invite List'
; Or when you are given ops in a channel.
; There is generally no need to type this command. This script is automatic.
ALIAS ialfill_auto {
debugger 2 Command: /ialfill_auto $1-
var %ticks = $ticks
; Is this script enabled?
if (!$SETTINGS.IALFILL.ON) && (!$SETTINGS.IBLFILL.ON) {
debugger 4 /ialfill_auto: Filling is disabled.
return
}
; Are we connected to the server?
if ($status != connected) {
debugger 4 /ialfill_auto: Not connected to server. $servertarget
return
}
; Have we been connected long enough for server flood queues to cool down?
var %wait = $calc($SETTINGS.CONNECT.DELAY - $uptime(server,3))
if (%wait isnum 2-9999) {
debugger /ialfill_auto: Delay. Waiting %wait more seconds. $&
[Re]Connected only $v2 seconds ago, delay set to $v1 seconds.
ialfill_timer %wait
return
}
; Have we waited long enough since last join or granted ops? This reduces hammering.
var %wait = $($+(%,IALFILL.JOIN-OP.,$cid),2)
if (%wait isnum 2-9999) {
debugger /ialfill_auto: Delay. Waiting %wait more seconds. $&
Recently Joined or was Opped in a channel. Delay setting is $SETTINGS.JOIN-OP.DELAY $+ .
inc -eu9999z %IALFILL.JOIN-OP. $+ $cid 0
ialfill_timer %wait
return
}
; Let's cycle through all joined channels to find next one that needs filling.
var %i = 1, %chan
while ($chan(%i)) {
var %chan = $v1 | inc %i
; Are we actually joined to this channel?
if ($chan(%chan).status != joined) { continue } ; Skipping stale (banned?) channel.
; Do we need to be opped and are we opped in this channel? $nick($chan,$me,~&@%)
var %isopped = $false
if ($me isop %chan) || (%me ishop %chan) || ($nick(%chan,$me,$gettok($prefix,1,43))) {
var %isopped = $true
}
if ($SETTINGS.ONLY-OPPED.ON) && (!%isopped) { continue } ; Skipping channel, not opped.
; Do we want to automatically /ialfill channels?
; Has this particular channel already been filled?
if ($ial) && ($SETTINGS.IALFILL.ON) && ($chan(%chan).ial == $false) { ; channel ial isn't filled.
; Is there an /ialfill (/WHO) already in progress for this channel? There shouldn't be.
if ($chan(%chan).inwho == $true) {
debugger 4 /ialfill_auto: Waiting. %chan .inwho == $v1 (IAL fill aleady in progress!)
return
}
; Sanity check should calm down strange unforseen endless loops and script conflicts.
if ($count($($+(%,IALFILL.FILLED.,$cid),2),%chan) >= 3) {
debugger 4 /ialfill_auto: !Sanity failure! We IAL filled %chan at least 3 times already. Giving up.
return
}
set -eu600 %IALFILL.FILLED. $+ $cid $($+(%,IALFILL.FILLED.,$cid),2) %chan
; Ok. Let's fill the IAL for this channel.
debugger 3 /ialfill_auto: Sending /ialfill %chan (/WHO command).
.ialfill %chan
return
; ... at 'End of /WHO list.', we will check for next channel that needs filling.
}
; Do we want to automatically fill channel IBL (banlists)?
elseif ($SETTINGS.IBLFILL.ON) {
; beIq
var %banmodes = $mid($gettok(x $+ $chanmodes,1,44),2)
; Does this particular channel have any unfilled banlists?
var %flags
if (b isincs %banmodes) && (!$chan(%chan).ibl) var %flags %flags $+ b
if (q isincs %banmodes) && (!$chan(%chan).iql) var %flags %flags $+ q
if (e isincs %banmodes) && (!$chan(%chan).iel) && (%isopped) var %flags %flags $+ e
if (I isincs %banmodes) && (!$chan(%chan).iil) && (%isopped) var %flags %flags $+ I
; Ok. If there are any unfilled banlists that we should fill, let's do this.
if (%flags) {
; Sanity check should calm down strange unforseen endless loops and script conflicts.
if ($count($($+(%,IBLFILL.FILLED.,$cid),2),%chan) >= 3) {
debugger 4 /ialfill_auto: !Sanity failure! We IBL filled %chan at least 3 times already. Giving up.
return
}
set -eu600 %IBLFILL.FILLED. $+ $cid $($+(%,IALFILL.FILLED.,$cid),2) %chan
; TODO: I need to add code here to send each flag as an individual MODE command for Unreal IRCd. :(
debugger 3 /ialfill_auto: Sending /mode %chan + $+ %flags (filling IBL).
mode %chan + $+ %flags
return
; ... at 'End of (ban) list.', we will check for next channel that needs filling.
}
}
; continue looping through chans.
}
; end of while loop.
debugger /ialfill_auto: Done. $calc(%i -1) Channels. Full loop took $calc($ticks - %ticks) ms.
} ; by Raccoon 2017 2018
ALIAS -l debugger {
var %c | if ($1 isnum) { var %c = $v1 | tokenize 32 $2- }
if ($window(@ialfill)) echo %c -i @ialfill [[ $+ $asctime(HH:nn.ss) $ticks $network $+ . $+ $cid $+ ]] * $1-
}
ALIAS -l ialfill_timer { .timerIALFILL_AUTO. $+ $cid 1 $iif($1 isnum,$1,30) /ialfill_auto }
; --- Event Triggers ---
; End of /NAMES list. (joined a channel)
RAW 366:*: {
set -eu9999z %IALFILL.JOIN-OP. $+ $cid $$SETTINGS.JOIN-OP.DELAY
ialfill_timer $$SETTINGS.JOIN-OP.DELAY
}
; You have been opped in any channel.
On me:*:OP:#: {
set -eu9999z %IALFILL.JOIN-OP. $+ $cid $$SETTINGS.JOIN-OP.DELAY
ialfill_timer $$SETTINGS.JOIN-OP.DELAY
}
; End of /WHO list. (ialfilled a channel; /who #chan)
RAW 315:*: {
ialfill_timer $$SETTINGS.NEXTFILL.DELAY
if ($2 isin $($+(%,IALFILL.FILLED.,$cid),2)) haltdef
}
;(315 didn't work when /ialfill was first added, but now it does)
; 368 'End of Channel Ban List' (/mode #chan +b)
RAW 368:*: {
ialfill_timer $$SETTINGS.NEXTFILL.DELAY
if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef
}
; 349 'End of Channel Exception List' (/mode #chan +e)
RAW 349:*: {
ialfill_timer $$SETTINGS.NEXTFILL.DELAY
if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef
}
; 347 'End of Channel Invite List' (/mode #chan +I)
RAW 347:*: {
ialfill_timer $$SETTINGS.NEXTFILL.DELAY
if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef
}
; 729 'End of Channel Quiet List' (/mode #chan +q)
RAW 729:*: {
ialfill_timer $$SETTINGS.NEXTFILL.DELAY
if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef
}
; -- halt fills from displaying in status window --
; 352 RFC WHO records ; not needed. suppressed by /ialfill.
;RAW 352:*: { if ($2 isin $($+(%,IALFILL.FILLED.,$cid),2)) haltdef }
; 354 WHOX WHO records ; not needed. suppressed by /ialfill.
;RAW 354:*: { if ($2 isin $($+(%,IALFILL.FILLED.,$cid),2)) haltdef }
; 367 +b BAN records
RAW 367:*: { if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
; 348 +e EXEMPT records
RAW 348:*: { if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
; 346 +I INVITE records
RAW 346:*: { if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
; 728 +q QUIET records
RAW 728:*: { if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
; End of script.
; r_ialfill_auto.mrc by Raccoon Feb-2017 Dec-2018
; Needs testing. Give feedback. 12/12/2018
; https://gist.github.com/a-raccoon/004dcff7c79bebd15d03387e7d2590bf
; Synchronizes your IAL (Internal Address List) via the /WHO command.
; Synchronizes your IBL (Internal Ban Lists) via /MODE [+bqeI] command.
; If you want to see what's going on, type /ialfill_debug
; Make sure your IAL is turned on with '/ial on', or only the IBL will work.
; These timing settings are conservative and make allowance for unforseeable lag.
ALIAS -l SETTINGS.IALFILL.ON return $true | ; should we fill the IAL?
ALIAS -l SETTINGS.IBLFILL.ON return $true | ; should we fill the IBL?
ALIAS -l SETTINGS.ONLY-OPPED.ON return $false | ; but only in channels we are opped in? (set to $false for all chans)
ALIAS -l SETTINGS.CONNECT.DELAY return 120 | ; wait this long after [re]connect
ALIAS -l SETTINGS.JOIN-OP.DELAY return 60 | ; wait this long after last join or being opped
ALIAS -l SETTINGS.NEXTFILL.DELAY return 15 | ; wait this long between each IAL or IBL fill request
; There is generally no need to type this command. This script is automatic.
ALIAS ialfill_auto {
if (!$SETTINGS.IALFILL.ON) && (!$SETTINGS.IBLFILL.ON) { return }
if ($status != connected) { return }
var %wait = $calc($SETTINGS.CONNECT.DELAY - $uptime(server,3))
if (%wait isnum 2-9999) { ialfill_timer %wait | return }
var %wait = $($+(%,IALFILL.JOIN-OP.,$cid),2)
if (%wait isnum 2-9999) { inc -eu9999z %IALFILL.JOIN-OP. $+ $cid 0 | ialfill_timer %wait | return }
var %i = 1, %chan
while ($chan(%i)) {
var %chan = $v1 | inc %i
if ($chan(%chan).status != joined) { continue }
var %isopped = $false
if ($me isop %chan) || (%me ishop %chan) || ($nick(%chan,$me,$gettok($prefix,1,43))) { var %isopped = $true }
if ($SETTINGS.ONLY-OPPED.ON) && (!%isopped) { continue } ; Skipping channel, not opped.
if ($ial) && ($SETTINGS.IALFILL.ON) && ($chan(%chan).ial == $false) { ; channel ial isn't filled.
if ($chan(%chan).inwho == $true) { return }
if ($count($($+(%,IALFILL.FILLED.,$cid),2),%chan) >= 3) { return }
set -eu600 %IALFILL.FILLED. $+ $cid $($+(%,IALFILL.FILLED.,$cid),2) %chan
.ialfill %chan
return
}
elseif ($SETTINGS.IBLFILL.ON) {
var %banmodes = $mid($gettok(x $+ $chanmodes,1,44),2)
var %flags
if (b isincs %banmodes) && (!$chan(%chan).ibl) var %flags %flags $+ b
if (q isincs %banmodes) && (!$chan(%chan).iql) var %flags %flags $+ q
if (e isincs %banmodes) && (!$chan(%chan).iel) && (%isopped) var %flags %flags $+ e
if (I isincs %banmodes) && (!$chan(%chan).iil) && (%isopped) var %flags %flags $+ I
if (%flags) {
if ($count($($+(%,IBLFILL.FILLED.,$cid),2),%chan) >= 3) { return }
set -eu600 %IBLFILL.FILLED. $+ $cid $($+(%,IALFILL.FILLED.,$cid),2) %chan
; TODO: I need to add code here to send each flag as an individual MODE command for Unreal IRCd. :(
mode %chan + $+ %flags
return
} }
}
} ; by Raccoon 2017 2018
ALIAS -l ialfill_timer { .timerIALFILL_AUTO. $+ $cid 1 $iif($1 isnum,$1,30) /ialfill_auto }
RAW 366:*: { set -eu9999z %IALFILL.JOIN-OP. $+ $cid $$SETTINGS.JOIN-OP.DELAY | ialfill_timer $$SETTINGS.JOIN-OP.DELAY }
On me:*:OP:#: { set -eu9999z %IALFILL.JOIN-OP. $+ $cid $$SETTINGS.JOIN-OP.DELAY | ialfill_timer $$SETTINGS.JOIN-OP.DELAY }
RAW 315:*: { ialfill_timer $$SETTINGS.NEXTFILL.DELAY | if ($2 isin $($+(%,IALFILL.FILLED.,$cid),2)) haltdef }
RAW 368:*: { ialfill_timer $$SETTINGS.NEXTFILL.DELAY | if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
RAW 349:*: { ialfill_timer $$SETTINGS.NEXTFILL.DELAY | if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
RAW 347:*: { ialfill_timer $$SETTINGS.NEXTFILL.DELAY | if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
RAW 729:*: { ialfill_timer $$SETTINGS.NEXTFILL.DELAY | if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
RAW 367:*: { if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
RAW 348:*: { if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
RAW 346:*: { if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
RAW 728:*: { if ($2 isin $($+(%,IBLFILL.FILLED.,$cid),2)) haltdef }
; End of script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.