I wrote this because a lot of times I'm at a computer away from home and would like to have some control over mIRC.
This only works on swiftIRC (or another server with /ns status )
-Note: to use another network you have to change line 31. Only recommended for those experienced in mSL, as entering the wrong server could be a major security flaw.
This script uses NickServ to authenticate. you (not your home computer) must be using a nick in line 1 and be identified for this to work.
For the ~list command, I recommend first using ~list servers to find out what number your server is, and then moving on to ~list chans
WARNING: ~kill will cause mIRC to quit all servers, but not close the application. This is irreversible until you get access to said computer.
Command list:
In channel:
~part
~list servers
~list chans
~com
~kill
In PM:
~part <#channel>
~join <#channel>
both ~list commands
~com
~kill
alias -l names { return NICK1 NICK2 NICK3 }
on *:TEXT:~kill:*:{
if ($istok($names,$nick,32)) {
msg NickServ status $nick
set -u3 %killorder $nick
set -u3 %command scon -at1 quit
}
}
on *:TEXT:~part:*:{
if ($istok($names,$nick,32)) {
msg NickServ status $nick
set -u3 %killorder $nick
set -u3 %command part $iif($2 == $null,$chan,$$2)
}
}
on *:TEXT:~join*:*:{
if ($istok($names,$nick,32)) {
msg NickServ status $nick
set -u3 %killorder $nick
set -u3 %command join $$2
}
}
on *:TEXT:~com*:*:{
if ($istok($names,$nick,32)) {
msg NickServ status $nick
set -u3 %killorder $nick
set -u3 %command $$2-
}
}
on *:NOTICE:*:?:{
if ($nick == NickServ) && ($network == SwiftIRC) && ($$1 == STATUS) && ($$2 == %killorder) && ($$3 == 3) {
%command
}
}
on *:TEXT:~list*:*:{
if ($istok($names,$nick,32)) {
msg nickserv status $nick
set -u3 %killorder $nick
set -u3 %type $$2
set -u3 %thing $3
set -u3 %cid $cid
set -u3 %command sendlist
}
}
alias -l sendlist {
if (%type == servers) {
var %temp 1
var %total $scon(0)
msg %killorder Server List:
while (%temp <= %total) {
msg %killorder $chr(45) %temp $chr(45) $scon(%temp).network $chr(45) $scon(%temp).server
inc %temp
}
msg %killorder Done.
}
elseif (%type == chans) || (%type == channels) {
if (%thing isnum) {
scon %thing chanreturn
}
}
}
alias -l chanreturn {
var %temp 1
var %total $chan(0)
scid %cid msg %killorder Channel List for $network $+ :
while (%temp <= %total) {
scid %cid msg %killorder - %temp - $chan(%temp)
inc %temp
}
scid %cid msg %killorder Done.
}
less repetition? looks neater? looks better? better coding habits?
less repetition? you've replaced text events with if conditions and kept the contents of those groups of commands the same. you are 'repeating' if statements in the same way that the OP was 'repeating' text events. each of those events do different things, why must we try to take away from its simplicity by combining them?
the purpose of combining code is not to just eliminate any and all repeated code - this is a mechanical process that anyone can learn to do and does not require a great deal of thought - what is more important is deciding what to combine and why.
in this case, every text event contains 3 identical lines of code that can be abstracted and put into a single alias. but not just for the sake of it: those 3 lines together constitute a clear identifiable function, namely 'validate the user and memorize his nick'. it is a function that is the same regardless of where it appears in the code, and becomes easier to manage if its kept in one place:
on *:TEXT:~kill:*:{
validateAndSave
set -u3 %command scon -at1 quit
}
on *:TEXT:~part:*:{
validateAndSave
set -u3 %command part $iif($2 == $null,$chan,$$2)
}
...
alias -l validateAndSave {
if (!$istok($names,$nick,32)) halt
.msg NickServ status $nick
set -u3 %killorder $nick
}
now, if the validation method ever changes, or the variable/identifier names should be changed, only one portion of code needs to be modified.
[quote]
I don't use regex
lol i was referring to that smart-ass =P
[/quote]
he doesn't want to use a bit of code he doesn't understand, i think that's perfectly reasonable. he may have a certain unwillingness to learn it, but that doesn't make him a smart ass. in his place, i wouldn't be sold either if all i'm shown is that regex has the ability to eliminate a few very basic if statements for me ;P in a day where regex is used for all the wrong reasons, can you really blame him for his POV?
you can get rid of all the on text events and group it into one event like so
alias -l names { return NICK1 NICK2 NICK3 }
on *:TEXT:*:*:{
tokenize 32 $strip($1-)
if ($1 == ~kill) {
if ($istok($names,$nick,32)) {
msg NickServ status $nick
set -u3 %killorder $nick
set -u3 %command scon -at1 quit
}
}
if ($1 == ~part) {
msg NickServ status $nick
set -u3 %killorder $nick
set -u3 %command part $iif($2 == $null,$chan,$$2)
}
if ($1 == ~join) {
msg NickServ status $nick
set -u3 %killorder $nick
set -u3 %command join $$2
}
if ($1 == ~com) {
msg NickServ status $nick
set -u3 %killorder $nick
set -u3 %command $$2-
}
if ($1 == ~list) {
msg nickserv status $nick
set -u3 %killorder $nick
set -u3 %type $$2
set -u3 %thing $3
set -u3 %cid $cid
set -u3 %command sendlist
}
}
on *:NOTICE:*:?:{
if ($nick == NickServ) && ($network == SwiftIRC) && ($$1 == STATUS) && ($$2 == %killorder) && ($$3 == 3) {
%command
}
}
alias -l sendlist {
if (%type == servers) {
var %temp 1
var %total $scon(0)
msg %killorder Server List:
while (%temp <= %total) {
msg %killorder $chr(45) %temp $chr(45) $scon(%temp).network $chr(45) $scon(%temp).server
inc %temp
}
msg %killorder Done.
}
elseif (%type == chans) || (%type == channels) {
if (%thing isnum) {
scon %thing chanreturn
}
}
}
alias -l chanreturn {
var %temp 1
var %total $chan(0)
scid %cid msg %killorder Channel List for $network $+ :
while (%temp <= %total) {
scid %cid msg %killorder - %temp - $chan(%temp)
inc %temp
}
scid %cid msg %killorder Done.
}