mIRC Remote (SwiftIRC Only)

By Savage_CL on May 25, 2011

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 <server number>
~com <command>
~kill

In PM:

~part <#channel>
~join <#channel>
 both ~list commands
 ~com <command>
~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.
}

Comments

Sign in to comment.
Jethro   -  May 26, 2011

Shut up and bite my dust, napa. :P All of a sudden I sound like a savage. lol

Our good old brainy friend jaytea has spoken with his matter-of-fact analogy upon this so-called accused "repetitive" snippet. Thanks for your time as usual. ^^ It ain't hurt to learn.

More
 Respond  
napa182   -  May 26, 2011

edited... it posted twice =/

More
 Respond  
napa182   -  May 26, 2011

well if you read what i wrote right you would have seen I was calling Jethro_ a smart-ass an not Savage_CL

More
 Respond  
jaytea   -  May 26, 2011

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?

More
 Respond  
Jethro   -  May 25, 2011

To me, doing goto is better than doing if conditions, cause it takes less doing passing the if comparison, ya know? It's long and spaghetti-like. For some reason, me sounds promiscuous. lol

More
 Respond  
napa182   -  May 25, 2011

true, but as most people say goto's look like crap lol I guess its all a matter of preference.

More
 Respond  
Jethro   -  May 25, 2011

You can do goto too:

on $*:text:/^~(kill|part|join|com|list)/iS:*:{
  if ($istok($names,$nick,32)) {
    var %nickserv msg nickserv status $nick
    goto $regml(1)
    :kill
    blah code here
    halt
    :part
    code here
  }
}
More
 Respond  
napa182   -  May 25, 2011

Savage_CL Wrote:

I don't use regex lol i was referring to that smart-ass =P

More
 Respond  
Jethro   -  May 25, 2011

LOL I don't "do" regex. What do you "do" then?

More
 Respond  
napa182   -  May 25, 2011
on $*:text:/^~(kill|part|join|com|list)/iS:*:{
  if ($istok($names,$nick,32)) {
    if ($regml(1) = kill) { 
      blah code here
    }
    if ($regml(1) = part) {
      code here
    }
  }
}

an so on.. I know you don't do regexs but it does look cleaner.. tbh

More
 Respond  
blackvenomm666   -  May 25, 2011

and your right jeth fixed :D

More
 Respond  
blackvenomm666   -  May 25, 2011

oh yea and less lines of code

More
 Respond  
Jethro   -  May 25, 2011

Oh guys, you only need one > if ($istok($names,$nick,32)) {and> msg nickserv status $nickinstead of one per each if you fancy one text event with the if condition.

More
 Respond  
Jethro   -  May 25, 2011

I think it looks less noob-ish. lol

More
 Respond  
blackvenomm666   -  May 25, 2011

less repetition? looks neater? looks better? better coding habits?

More
 Respond  
Savage_CL   -  May 25, 2011

You're right, I could. but what do I gain doing that?

More
 Respond  
blackvenomm666   -  May 25, 2011

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.
}
More
 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.