Channel relay

By Qc
Platform:  mIRC
Published  Dec 30, 2006
Updated  Jan 27, 2007
Purpose:
Uutputs all events happening on a set network,channel combinations to another set.

How to use:
Edit the ON START event to set the channels.
- Variable %relay_in contains the channels the script uses as source.
- Variable %relay_out contains those where the events are relayed to.
- Variable %relay_delay holds the amount millisec between every output line (per network), setting this too low may result in flood disconnects.
on *:START: {
; put here networks and channels in form Network1,Channel1 Network2,Channel2 Network3,Channel3
; the couples <Network><comma><Channel> should be separated by a space.

; Net/channels to relay FROM:
set %relay_in QuakeNet,#source1 QuakeNet,#source2 QuakeNet,#source3

; Net/channels to relay TO:
set %relay_out UnderNet,#target1 DALnet,#target2

; Delay between two outputs (in ms):
set %relay_delay 2000

window -he @RY_Queue
}
on *:MODE:#: { checkchan MODE $1- }
on *:TOPIC:#: { checkchan TOPIC $1- }
on *:BAN:#: { checkchan BAN }
on *:UNBAN:#: { checkchan UNBAN }
on *:OP:#: { checkchan OP }
on *:DEOP:#: { checkchan DEOP }
on *:VOICE:#: { checkchan VOICE }
on *:DEVOICE:#: { checkchan DEVOICE }
CTCP *:*:#: { checkchan CTCP $1- }
on *:TEXT:*:#: { checkchan TEXT $1- }
on *:ACTION:*:#: { checkchan ACTION $1- }
on *:NOTICE:*:#: { checkchan NOTICE $1- }
on *:INPUT:#: {
if ($1 == /me) { checkchan ME $1- }
if (/* !iswm $1) && (!$ctrlenter) { checkchan INPUT $1- }
}
on *:NICK: { checkchan NICK }
on *:JOIN:#: { checkchan JOIN }
on *:PART:#: { checkchan PART $1- }
on *:KICK:#: { checkchan KICK $1- }
on *:QUIT: { checkchan QUIT $1- }
alias -l checkchan {
if (!$istok(NICK QUIT,$1,32)) { if ($istok(%relay_in,$+($network,$chr(44),$chan),32)) { broadcast $network $chan $1- } | return }
var %total = $comchan($nick,0), %i = 1
while (%i <= %total) { if ($istok(%relay_in,$+($network,$chr(44),$comchan($nick,%i)),32)) { broadcast $network <none> $1- | return } | inc %i }
}
alias -l broadcast {
var %net = $1, %chan = $2, %event = $3, %data = $4-
var %total = $numtok(%relay_out,32), %i = 1
while (%i <= %total) {
tokenize 44 $gettok(%relay_out,%i,32) | if ($1 == %net) && ($2 == %chan) { inc %i | continue }
var %cid = $net2cid($1) | if (%cid == NOTCON) { inc %i | continue }
if ($cid != %cid) { scid %cid } | if ($me !ison $2) { inc %i | continue }
if (%event == QUIT) && ($nick ison $2) { inc %i | continue }
var %nc = $+([,%net,][,%chan,]) | goto %event
:MODE | var %com = msg $2 %nc $nick sets mode: %data | goto output
:TOPIC | var %com = msg $2 %nc $nick changes topic to $+(',%data,') | goto output
:BAN | var %com = msg $2 %nc $nick sets mode: +b $banmask | goto output
:UNBAN | var %com = msg $2 %nc $nick sets mode: -b $banmask | goto output
:OP | var %com = msg $2 %nc $nick sets mode: +o $opnick | goto output
:DEOP | var %com = msg $2 %nc $nick sets mode: -o $opnick | goto output
:VOICE | var %com = msg $2 %nc $nick sets mode: +v $vnick | goto output
:DEVOICE | var %com = msg $2 %nc $nick sets mode: -v $vnick | goto output
:CTCP | ctcp $2 %nc $+(<,$nick,>) %data | goto output
:TEXT | :INPUT | var %com = msg $2 %nc $+(<,$nick,>) %data | goto output
:ACTION | :ME | var %com = describe $2 %nc $+(<,$nick,>) %data | goto output
:NOTICE | var %com = notice $2 %nc $+(<,$nick,>) %data | goto output
:JOIN | var %com = msg $2 %nc $nick ( $+ $gettok($fulladdress,2-,33) $+ ) has joined. | goto output
:PART
if (%data != $null) { var %datai = ( $+ %data $+ ) }
var %com = msg $2 %nc $nick ( $+ $gettok($fulladdress,2-,33) $+ ) has left %datai | goto output
:NICK
if ($newnick ison $2) { inc %i | continue }
var %com = msg $2 $+([,%net,]) $nick is now known as $newnick | goto output
:KICK | var %com = msg $2 %nc $knick was kicked by $nick ( $+ %data $+ ). | goto output
:QUIT | var %com = msg $2 %nc $nick ( $+ $gettok($fulladdress,2-,33) $+ ) Quit ( $+ %data $+ ) | goto output
:output | RY_Qadd $1 %com | inc %i
}
}

; Input: $1 = network $2 = command $3 = target $4- = msg
alias RY_Qadd { aline -p @RY_Queue $1- | RY_Qnext $1 }
alias RY_Qclean {
if ($1 == $null) { var %wm = * } | else { var %wm = $1 * }
var %w = @RY_Queue | filter -wwcx %w %w %wm
}
alias RY_Qnext {
var %net = $1 | if (%net == $null) { var %net = * } | elseif ($timer(RY_Queue. $+ %net)) && ($ctimer != RY_Queue. $+ %net) { return }
var %w = @RY_Queue, %l = $fline(%w,%net *),1,0) | if (!%l) { return }
tokenize 32 $line(%w,%l) | if ($timer(RY_Queue. $+ $1)) && ($ctimer != RY_Queue. $+ $1) { return }
var %cid = $net2cid($1) | if ($cid != %cid) { scid %cid }
goto $2

:MSG | :NOTICE | :DESCRIBE | if ($me ison $3) { msg $3 $4- } | elseif ($comchan($3,1)) { $2 $3 $4- } | goto end

:end
dline %w %l | var %delay = $calc(%relay_delay / 1000)
if ($numtok(%delay,46) == 1) { var %sw } | else { var %sw = -oh, %delay = $calc(%delay * 1000) }
.timerRY_Queue. $+ $1 %sw 1 %delay RY_Qnext $1
}
on *:DISCONNECT: { RY_Qclean $network }
alias -l net2cid { var %total = $scon(0), %i = 1 | while (%i <= %total) { if ($scon(%i).network == $1) && ($scon(%i).status == connected) { return $scon(%i) } | inc %i } | return

Comments

Sign in to comment.
KindOne   -  Apr 05, 2011
Does not follow nick changes. I am using mIRC 7.19
 Respond  
BigBen   -  Apr 07, 2007
Its a good script, but it seems to repeat it self.
 Respond  
Qc   -  Dec 31, 2006
If it does not work for you, try to be more specific than \'it doesn\'t work\'.
Without information regarding how you configured and tested it, I can do little to help you.

Nevertheless, I noticed a bug:
:NICK | if ($newnick ison $2) { goto nexti } | var %com = msg $2 $+([,%net,]) $nick is now known as $newnick | goto output

should be:

:NICK | if ($newnick ison $2) { inc %i | continue } | var %com = msg $2 $+([,%net,]) $nick is now known as $newnick | goto output

An earlier version of this jumped to a label instead of immediately continuing the loop like it does now, and this occurence of the goto was forgotten.
It\'s not related to your problem however, since it would just spit out an error in case of a nickchange combined with a relay output channel on the same network as the nickchange where the nick is als present, this to avoid seeing a nickchange AND a message from the script (=double reporting).
 Respond  
Marshtomp   -  Dec 31, 2006
Testing now, and i think it only works on channels that are on Alt + O servers then groups? it doesn\'t work.
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.