Alias away

By Zsadist on Jan 31, 2011

Meh, simple /away snippet. Load it into alias' or simple put the beginning 'Alias Away' and throw it into remotes. From there just type /away , or just /away if you are returning.

away { 
  if ($1-) {
    if (!$away) { 
      tnick $me $+ $chr(124) $+ $$?="Please enter an Addon for your nick (away/sleep/brb):"
      msg $active [Away] I am now away. Reason: $1- - Time: $time(hh:nn:sstt)
      away $1-
      halt
    }
    else { echo -a [Away] Error: You are already away - To return, just type: /away | halt }
  }
  elseif ($away) {
    nick $mnick
    msg $active [Away] I have returned from: $awaymsg ( $+ $duration($awaytime) $+ )
    away
    halt
  }
  else { echo -a [Away] Error: You are not away - To go away: /away reason | halt }
}

Comments

Sign in to comment.
Zsadist   -  Feb 01, 2011

It's just become an instinct to always put a halt per if unless I needed it to -not- have a halt. I've only recently gotten back into mSL, the last thing I ever did was two years ago, and trying to re-study everything.

 Respond  
Jethro   -  Feb 01, 2011

lol Zsadist, you're not alone. Many people dislike goto. It was served as a way of proceeding your snippet and nothing more. One last thing you really don't need is the /halt command in each if and else statement. Your code works fine without it.

 Respond  
Zsadist   -  Feb 01, 2011

Whoops, thought I missed something. I'll get on that.

Also, I hate goto's and won't use them unless absolutely necessary.

 Respond  
Jethro   -  Jan 31, 2011

Also, I found a bug though. If you are not away and then you enter /away, you'll get the output of > [Away] I have returned from: (0secs)So you need to make the else an elseif to check that if you are in fact away instead:

elseif ($away) {
    nick $mnick
    msg $active [Away] I have returned from: $awaymsg ( $+ $duration($awaytime) $+ )
    away
    halt
  }

This also ensures that you don't start the nick $mnick change and /away routine for nothing upon entering /away when you aren't away by accident.

 Respond  
Jethro   -  Jan 31, 2011

Seeing all the halts, which aren't really needed, you might as well use goto if you fancy them:

away {
  goto $iif($1-,x,y) 
  :x
  if (!$away) { 
    tnick $me $+ $(|) $+ $$?="Please enter an Addon for your nick (away/sleep/brb):"
    msg $active [Away] I am now away. Reason: $1- - Time: $time(hh:nn:sstt)
    away $1-
  }
  else echo -a [Away] Error: You are already away - To return, just type: /away 
  halt
  :y
  nick $mnick
  msg $active [Away] I have returned from: $awaymsg ( $+ $duration($awaytime) $+ )
  away
  halt
}
 Respond  
Zsadist   -  Jan 31, 2011

...lol Yes @ napa

 Respond  
Jethro   -  Jan 31, 2011

Oh right. My mistake. I don't reckon the $1- will work for nicks with spaces anyway.

 Respond  
napa182   -  Jan 31, 2011

Jethro_ I think he is using $1- for the away message not the nick...

 Respond  
Jethro   -  Jan 31, 2011

You know, I've just realized that the $$? isn't necessary, because you can specify it through $1 as such:

tnick $+($me,|,$1-)

so when you enter, for example, /away brb, the script will then change it to the temp nick Jethro|brb

I just don't see the necessity to go the extra mile to engage in a popup prompt, especially this is simply a self-trigger alias.

 Respond  
napa182   -  Jan 31, 2011

Zsadist Wrote:

tnick and mnick, which btw was very useful. Thanks.

You are welcome...

 Respond  
Jethro   -  Jan 31, 2011

mIRC doesn't allow the use of recursive aliases anymoreOk I didn't know of the change, nor did RusselB, I suppose.

 Respond  
Zsadist   -  Jan 31, 2011

And there you go, tnick and mnick, which btw was very useful. Thanks.

 Respond  
sunslayer   -  Jan 31, 2011

mIRC will just keep calling the alias rather than the internal commandIt's not completely necessary since mIRC doesn't allow the use of recursive aliases anymore

 Respond  
Zsadist   -  Jan 31, 2011

Well, if you notice that this snippet works just fine even without the !, it does the internal command.

 Respond  
MoshMage   -  Jan 31, 2011

AAH! i understood what you mean now. I always found strange that we could call an alias from within that alias.

Thanks :)

 Respond  
Jethro   -  Jan 31, 2011

Well, it'll work, but according to RusselB, and I assisted someone at the forum awhile back, and I quote, "If you don't use the ! in front of the command in these circumstances, mIRC will just keep calling the alias rather than the internal command." That is to say, if your alias command is the same as mirc's default one. You can reference to this post below and you'll see what I mean:

http://www.hawkee.com/phpBB2/viewtopic.php?p=109349&highlight=#109349

/tnick is a command; it's not an identifier. MoshMage, I didn't make the rule; it's part of mIRC's coding grammar.

 Respond  
Zsadist   -  Jan 31, 2011

Also, I can't find anything in the mIRC help file for $tnick or tnick itself, found $mnick though.

 Respond  
Zsadist   -  Jan 31, 2011

Uh, no you don't. I'm on mIRC 7.14 and it works absolutely fine the way it is. And I'll look into the tnick mnick. You do -not- have to use a ! infront of away. So why don't you go try it and see that it works :)

 Respond  
MoshMage   -  Jan 31, 2011

oi? how come?! you lost me there (is that a new rule or sumfin?)

 Respond  
Jethro   -  Jan 31, 2011

Since the /away is mIRC's internal command, you need to put an exclamation mark for:

!away $1-

and

!away
 Respond  
MoshMage   -  Jan 31, 2011

Never occured to me the use for tnick and mnick. lol. But now that i think about it, it does make sense using that x)

sweet snippet nonetheless :)

 Respond  
napa182   -  Jan 31, 2011

maybe take advantage of tnick tempnick and nick $mnick when doing the nick changes and no need to set that %nick var.

 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.