Telnet Relay — File Browser
TelnetRelayv1.1 / TelnetRelayv1.1 / relay.mrc
relay.mrc — 19.05 KB — Download this file
on *:socklisten:bnclisten:{
if ($sock(bnc) == $null) {
aline @relay Connection initatiated.
if ($bncsetting(log) == 1) {
write bnc.log $time([hh:nntt mm/dd/yy]) Connection initiated.
}
set %bnc.authing 1
set %bnc.on 1
set %bnc.cid $cid
$iif(%bnc.active == $null,set %bnc.active $chan(1))
sockaccept bnc
sockwrite -n bnc Please enter your password to continue.
.timer 1 20 bnc.checkauth
}
}
alias relay {
if ($bncsetting(port) != $null) {
if ($bncsetting(pass) != $null) {
window -ek0 @relay
socklisten bnclisten $bncsetting(port)
}
}
}
alias relay.settings {
dialog -dm relay.setting relay.setting
}
alias -l bkspace {
var %i = 1
var %bkspace = $replace($1-,$chr(32),$chr(255))
while (%i < $_numtok($1-,8)) {
var %bkspace = $left($_gettok(%bkspace,1,8),$calc($len($_gettok(%bkspace,1,8)) - 1)) $+ $_gettok(%bkspace,2-,8)
inc %i
}
return $replace(%bkspace,$chr(255),$str($chr(32),2))
}
alias -l _numtok return $calc($pos($1,$chr($2),0)+1)
alias -l _gettok {
var %out, %ct = 0, %tt = $calc($pos($1,$chr($3),0) + 1)
while (%ct < %tt) {
if ($calc(%ct + 1) isnum $2) {
if (%ct == 0) var %tstart = 1
else var %tstart = $calc($pos($1,$chr($3),%ct)+1)
inc %ct
if (%ct == %tt) var %tlen = $calc($len($1) - %tstart + 1)
else var %tlen = $calc($pos($1,$chr($3),%ct) - %tstart)
var %out = %out $+ $chr($3) $+ $iif(%tlen > 0,$mid($1,%tstart,%tlen))
}
else inc %ct
}
return $right(%out,-1)
}
alias -l bncsetting {
return $readini($shortfn($scriptdirbnc.settings.ini),n,setting,$1)
}
alias bnc.checkauth {
if (%bnc.authing == 1) {
sockclose bnc
}
}
on *:sockread:bnc:{
sockread %bnc.read
set %bnc.read $bkspace(%bnc.read)
if (%bnc.read != $null) {
tokenize 32 %bnc.read
if (%bnc.authing == 1) {
if ($encode(%bnc.read,m) != $bncsetting(pass)) {
unset %bnc.authing
unset %bnc.on
var %log.temp = 1
if ($bncsetting(log) == 1) {
write bnc.log $time([hh:nntt mm/dd/yy]) $sock($sockname).ip entered an incorrect password.
}
sockwrite -n $sockname You specified a wrong password.
sockclose $sockname
}
else {
unset %bnc.authing
var %log.temp = 1
if ($bncsetting(log) == 1) {
write bnc.log $time([hh:nntt mm/dd/yy]) $sock($sockname).ip successfully logged in.
}
sockwrite -n $sockname You are now logged in.
sockwrite -n $sockname For a list of commands type /commands
if ($status != connected) {
sockwrite -n $sockname WARNING: You might not be connected to irc.
}
else {
sockwrite -n $sockname You are currently connected to $network on $+($server,:,$port) as $me
}
}
}
else {
if ($mid($1,1,1) != $chr(47)) {
if (%bnc.active != $null) {
if ($mid(%bnc.active,1,1) == $chr(35)) {
if ($me ison %bnc.active) {
sockwrite -n $sockname $chr(91) $+ %bnc.active $+ $chr(93) < $+ $nick(%bnc.active,$me).pnick $+ > %bnc.read
msg %bnc.active %bnc.read
}
}
else {
sockwrite -n $sockname $chr(91) $+ PM $+ $chr(93) < $+ $me $+ > %bnc.read
msg %bnc.active %bnc.read
}
}
}
else {
if ($1 == /quit) {
aline @relay Connection to $sock($sockname).ip closed.
sockwrite -n $sockname You have been disconnected from the bnc.
sockclose bnc
unset %bnc.on
}
elseif ($1 == /list) {
var %i = 1
sockwrite -n $sockname Channel and pm list:
while (%i <= $chan(0)) {
sockwrite -n $sockname ( $+ %i $+ ) $chan(%i) $+ : relaying = $iif($readini($scriptdirbnc.ini,$chan(%i),focus) == $null,yes,no)
inc %i
}
var %i = 1
while (%i <= $query(0)) {
sockwrite -n $sockname ( $+ $calc($chan(0) + %i) $+ ) $query(%i)
inc %i
}
}
elseif ($1 == /msg) {
if ($2 != $null) {
if ($3 != $null) {
if ($mid($2,1,1) == $chr(35)) {
if ($me ison $2) {
msg $2 $3-
}
else {
sockwrite -n $sockname I am not on $2 $+ .
}
}
else {
msg $2 $3-
}
}
else {
sockwrite -n $sockname Usage: /msg #chan/name msg
}
}
else {
sockwrite -n $sockname Usage: /msg #chan/name msg
}
}
elseif (($1 == /a) || ($1 == /active)) {
if ($2 != $null) {
if ($mid($2,1,1) == $chr(35)) {
if ($me ison $2) {
sockwrite -n $sockname Msgs are now being sent to $2 $+ .
set %bnc.active $2
}
else {
sockwrite -n $sockname I am not on $2 $+ .
}
}
else {
if ($2 !isnum) {
sockwrite -n $sockname Msgs are now being sent to $2
set %bnc.active $2
}
else {
if ($2 <= $chan(0)) {
sockwrite -n $sockname Msgs are now being set to $chan($2)
set %bnc.active $chan($2)
}
else {
if ($calc($2 - $chan(0)) >= 1) {
if ($query($calc($2 - $chan(0))) != $null) {
set %bnc.active $query($calc($2 - $chan(0)))
sockwrite -n $sockname Active messages are now being sent to $query($calc($2 - $chan(0)))
}
else {
sockwrite -n $sockname There is no such chan or pm with the id $2 $+ .
}
}
}
}
else {
sockwrite -n $sockname There is no such chan or pm with the id $2 $+ .
}
}
}
else {
sockwrite -n $sockname Usage: /active #chan/nick
sockwrite -n $sockname Current active $iif($mid(%bnc.active,1,1) == $chr(35),chan,pm) is: %bnc.active
}
}
elseif ($1 == /me) {
if ($2 != $null) {
describe %bnc.active $2-
sockwrite -n $sockname $chr(91) $+ %bnc.active $+ $chr(93) * $iif($mid(%bnc.active,1,1) == $chr(35),$nick(%bnc.active,$me).pnick,$me) $2-
}
else {
sockwrite -n $sockname Usage: /me text here
}
}
elseif ($1 == /whois) {
if ($2 != $null) {
whois $2-
set %bnc.whois 1
}
else {
sockwrite -n $sockname Usage: /whois nick
}
}
elseif ($1 == /join) {
if ($2 != $null) {
if ($me !ison $2) {
join $2 $3-
set %bnc.active $2
sockwrite -n $sockname Joining $2 $+ .
}
else {
sockwrite -n $sockname Already in $2 $+ , setting active chan to $2 $+ .
set %bnc.active $2
}
}
else {
sockwrite -n $sockname Usage: /join #chan
}
}
elseif ($1 == /part) {
if ($2 != $null) {
if ($me ison $2) {
part $2
$iif(%bnc.active == $2,set %bnc.active $chan(1))
sockwrite -n $sockname Parting $2 $+ .
}
else {
sockwrite -n $sockname You are not currently on $2 $+ .
}
}
else {
sockwrite -n $sockname Usage: /part #chan
}
}
elseif ($1 == /addchan) {
if ($2 != $null) {
if ($mid($2,1,1) == $chr(35)) {
if ($readini($scriptdirbnc.ini,$2,focus) == off) {
remini " $+ $scriptdirbnc.ini" $2
sockwrite -n $sockname $2 has been added to the list.
}
else {
sockwrite -n $sockname $2 is already on the list.
}
}
else {
if ($2 isnum) {
if ($2 <= $chan(0)) {
if ($readini($scriptdirbnc.ini,$chan($2),focus) == off) {
remini " $+ $scriptdirbnc.ini" $chan($2)
sockwrite -n $sockname $chan($2) has been added to the list.
}
else {
sockwrite -n $sockname $chan($2) is already on the list.
}
}
else {
sockwrite -n $sockname There is no such chan with the id $2
}
}
}
}
else {
sockwrite -n $sockname Usage: /addchan #chan
}
}
elseif ($1 == /delchan) {
if ($2 != $null) {
if ($mid($2,1,1) == $chr(35)) {
if ($readini($scriptdirbnc.ini,$2,focus) != off) {
sockwrite -n $sockname $2 deleted from the list.
writeini " $+ $scriptdirbnc.ini" $2 focus off
}
else {
sockwrite -n $sockname $2 is not on the list.
}
}
else {
if ($2 isnum) {
if ($2 <= $chan(0)) {
if ($readini($scriptdirbnc.ini,$chan($2),focus) != off) {
sockwrite -n $sockname $chan($2) deleted from the list.
writeini " $+ $scriptdirbnc.ini" $chan($2) focus off
}
else {
sockwrite -n $sockname $chan($2) is not on the list.
}
}
else {
sockwrite -n $sockname There is no such chan with the id $2
}
}
}
}
else {
sockwrite -n $sockname Usage: /delchan #chan
}
}
elseif ($1 == /commands) {
sockwrite -n $sockname Commands:
sockwrite -n $sockname /quit - disconnects you from the relay
sockwrite -n $sockname /list - lists channels and their relaying status
sockwrite -n $sockname /msg - sends a msg to a channel
sockwrite -n $sockname /active - sets channel/nick messages will be sent to
sockwrite -n $sockname /addchan - readds a channel to the relay list
sockwrite -n $sockname /delchan - deletes chan from the relay list
}
else {
$1-
}
}
}
aline @relay $chr(91) $+ IN $+ $chr(93) %bnc.read
if ($bncsetting(log) == 1) {
if (%bnc.authing != 1) {
if (%log.temp != 1) {
write bnc.log $time([hh:nntt mm/dd/yy]) $iif($mid(%bnc.read,1,1) != /,$chr(91) $+ %bnc.active $+ $chr(93) %bnc.read,%bnc.read)
}
}
}
}
}
on *:input:@relay:{
if ($sock(bnc) != $null) {
if ($mid($1,1,1) != $chr(47)) {
sockwrite -n bnc $chr(91) $+ ADMIN $+ $chr(93) $1-
aline @relay $chr(91) $+ OUT $+ $chr(93) $1-
}
}
}
on *:text:*:*:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
if ($readini($scriptdirbnc.ini,$chan,focus) != off) {
sockwrite -n bnc $chr(91) $+ $iif($chan != $null,$chan,PM) $+ $chr(93) < $+ $iif($chan != $null,$nick($chan,$nick).pnick,$nick) $+ > $strip($1-)
}
}
}
}
}
on *:join:*:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
if ($readini($scriptdirbnc.ini,$chan,focus) != off) {
if ($nick != $me) {
sockwrite -n bnc $chr(91) $+ $chan $+ $chr(93) * Joins: $nick ( $+ $gettok($address($nick,5),2-,33) $+ )
}
else {
var %bnc.temp = $chan
sockwrite -n bnc $chr(91) $+ $chan $+ $chr(93) * Now talking in $chan $+ .
set %bnc. [ $+ [ $chan ] $+ .join ] 1
}
}
}
}
}
}
on *:part:*:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
if ($readini($scriptdirbnc.ini,$chan,focus) != off) {
if ($nick != $me) {
sockwrite -n bnc $chr(91) $+ $chan $+ $chr(93) * Parts: $nick($chan,$nick).pnick ( $+ $gettok($address($nick,5),2-,33) $+ ) $iif($1- != $null,( $+ $strip($1-) $+ ))
}
else {
sockwrite -n bnc $chr(91) $+ $chan $+ $chr(93) * You have left $chan
}
}
}
}
}
}
on *:rawmode:*:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
if ($readini($scriptdirbnc.ini,$chan,focus) != off) {
sockwrite -n bnc $chr(91) $+ $chan $+ $chr(93) * $nick($chan,$nick).pnick sets mode: $strip($1-)
}
}
}
}
}
on *:kick:*:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
if ($readini($scriptdirbnc.ini,$chan,focus) != off) {
sockwrite -n bnc $chr(91) $+ $chan $+ $chr(93) * $knick was kicked by $nick $iif($1- != $null,( $+ $strip($1-) $+ ))
}
}
}
}
}
on *:topic:*:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
if ($readini($scriptdirbnc.ini,$chan,focus) != off) {
sockwrite -n bnc $chr(91) $+ $chan $+ $chr(93) * $nick sets topic to ' $+ $strip($1-) $+ '
}
}
}
}
}
on *:notice:*:*:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
if ($chan == $null) {
sockwrite -n bnc $chr(91) $+ NOTICE $+ $chr(93) $+(-,$nick,-) $1-
}
else {
if ($readini($scriptdirbnc.ini,$chan,focus) != off) {
sockwrite -n bnc $chr(91) $+ NOTICE $+ $chr(93) $+(-,$nick($chan,$nick).pnick,:,$chan,-) $1-
}
}
}
}
}
}
on *:action:*:*:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
if ($readini($scriptdirbnc.ini,$chan,focus) != off) {
sockwrite -n bnc $chr(91) $+ $iif($chan != $null,$chan,PM) $+ $chr(93) * $iif($chan != $null,$nick($chan,$nick).pnick,$nick) $strip($1-)
}
}
}
}
}
on *:nick:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
var %i = 1
while (%i <= $comchan($newnick,0)) {
if ($readini($scriptdirbnc.ini,$comchan($newnick,%i),focus) == $null) {
var %bnc.nick.relay = 1
}
inc %i
}
if (%bnc.nick.relay == 1) {
sockwrite -n bnc $chr(91) $+ NICK $+ $chr(93) * $nick is now known as $newnick
}
}
}
}
}
on *:quit:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
var %i = 1
while (%i <= $comchan($nick,0)) {
if ($readini($scriptdirbnc.ini,$comchan($nick,%i),focus) == $null) {
var %bnc.quit.relay = 1
}
inc %i
}
if (%bnc.quit.relay == 1) {
sockwrite -n bnc $chr(91) $+ QUIT $+ $chr(93) * Quits: $nick ( $+ $gettok($address($nick,5),2,33) $+ ) $iif($1- != $null,( $+ $strip($1-) $+ ))
}
}
}
}
}
raw *:*:{
if (%bnc.cid == $cid) {
if (%bnc.on == 1) {
if (%bnc.authing != 1) {
if (%bnc.whois == 1) {
if ($numeric == 311) {
sockwrite -n bnc $chr(91) $+ WHOIS $+ $chr(93) $2 is $3 $+ @ $+ $4 $5-
}
elseif ($numeric == 319) {
sockwrite -n bnc $chr(91) $+ WHOIS $+ $chr(93) $2 on $3-
}
elseif ($numeric == 318) {
sockwrite -n bnc $chr(91) $+ WHOIS $+ $chr(93) $2-
unset %bnc.whois
}
elseif ($numeric == 312) {
sockwrite -n bnc $chr(91) $+ WHOIS $+ $chr(93) $2 using $3-
}
elseif ($numeric == 330) {
sockwrite -n bnc $chr(91) $+ WHOIS $+ $chr(93) $2 is logged in as $3
}
elseif ($numeric == 313) {
sockwrite -n bnc $chr(91) $+ WHOIS $+ $chr(93) $2-
}
}
if ($numeric == 421) {
sockwrite -n bnc $chr(91) $+ ERROR $+ $chr(93) $2-
}
elseif ($numeric == 366) {
if (%bnc. [ $+ [ $2 ] $+ .join ] == 1) {
var %i = 1
while (%i <= $nick($2,0)) {
var %bnc.nicks = %bnc.nicks $nick($2,%i).pnick
inc %i
}
sockwrite -n bnc $chr(91) $+ $2 $+ $chr(93) * Current users in chan: %bnc.nicks
}
unset %bnc. [ $+ [ $2 ] $+ .join ]
}
elseif ($numeric == 332) {
if (%bnc. [ $+ [ $2 ] $+ .join ] == 1) {
sockwrite -n bnc $chr(91) $+ $2 $+ $chr(93) * Topic is $strip($chan($2).topic)
}
}
else {
sockwrite -n bnc $1-
}
}
}
}
}
on *:sockclose:bnc:{
unset %bnc.on
unset %bnc.authing
aline @relay Connection to $sock($sockname).ip closed.
}
on *:close:@relay:{
unset %bnc.on
unset %bnc.authing
sockclose bnc
sockclose bnclisten
}
on *:start:{
if ($bncsetting(autostart) == 1) {
relay
}
}
menu @relay {
Settings:dialog -dm relay.setting relay.setting
Disconnect active client:{
if ($sock(bnc) != $null) {
aline @relay Closed connection to $sock(bnc).ip $+ .
unset unset %bnc.on
sockwrite -n bnc Admin closed your connection.
sockclose bnc
}
}
}
on *:load:{
dialog -dm relay.setting relay.setting
}
dialog relay.setting {
title "Telnet Relay - Settings"
size -1 -1 100 62
option dbu
edit "", 1, 33 10 33 10
edit "", 2, 33 23 60 10, pass
text "Port:", 3, 20 11 13 8
box "Settings", 4, 3 1 94 45
text "Password:", 5, 7 24 26 8
check "Start when mIRC starts", 6, 7 34 67 10
check "Log", 7, 75 34 21 10
button "OK", 8, 21 48 37 12, ok cancel
button "Cancel", 9, 60 48 37 12, cancel
}
on *:dialog:relay.setting:*:*:{
if ($devent == init) {
did -ra $dname 1 $bncsetting(port)
did -ra $dname 2 $decode($bncsetting(pass),m)
did - $+ $iif($bncsetting(log) == 1,c,u) $dname 7
did - $+ $iif($bncsetting(autostart) == 1,c,u) $dname 6
}
elseif ($devent == sclick) {
if ($did == 8) {
$iif($did($dname,1) != $null,writeini $shortfn($scriptdir) $+ bnc.settings.ini setting port $did($dname,1))
$iif($did($dname,2) != $null,writeini $shortfn($scriptdir) $+ bnc.settings.ini setting pass $encode($did($dname,2),m))
writeini $shortfn($scriptdir) $+ bnc.settings.ini setting autostart $did($dname,6).state
writeini $shortfn($scriptdir) $+ bnc.settings.ini setting log $did($dname,7).state
}
}
;$iif($devent != mouse,echo -a $devent $did)
}