mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2010
Posts: 4
I
Self-satisified door
OP Offline
Self-satisified door
I
Joined: May 2010
Posts: 4
Sorry about the messy topic title. Tried to make it describe my issue. My sincerest apologies if it worked against it's purpose.

I've searched high and low and experimented with so many different variables of commands without any success that my head is spinning. If there is anyone here who could kindly point me in the right direction I would be more than grateful!

I'm no master coder - I will admit that - so my description of my problem might seem a bit vague. I will attempt to clear up any confusion to the best of my effort.


I'm trying to run a "check" of my current nickname to see if it contains a certain string (word/value) and if it does contain this specific string it will {halt}.

I don't have examples from everything I've tried since it's been hours, but I have the last one I attempted to use:
Code:
/alias afk {
  /var %anck1 = [AFK]
  /var %anck2 = $me
  if ($regex($me,^(/[AFK/]))) { halt }
  else { nick $+(%anck1,%anck2) }
}

For the above snippet I also attempted replacing $me with the second /var I created and also a bucket of other expressions in my dire attempt to make thing baby work.

I think you see what I'm going for here and I'm sure I'll get a lot of criticism for thinking I could make it this simple, but I want to check if I'm already "AFK"-tagged in my nick. If I am, it shall NOT apply [AFK] in front of my nick (It will simply duplicate). If it isn't it WILL add [AFK] to my nick.


#
To make matters worse, I would also need to check-if and then also potentially remove the [AFK] value in my nickname when doing:
alias BACK {
...
}


Thank you for your time!

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
There really isn't any need to use regex here unless you might have some other format for [AFK]. Otherwise, just use this:

Code:
alias afk {
  if ([AFK] !isin $me) { nick [AFK] $+ $me }
}
alias back {
  if ([AFK] isin $me) { nick $remove($me,[AFK]) }
}


One of the main reasons your regex isn't working is that []'s are special characters. To include them in a match, you need to escape them using \ . For example /\[AFK\]/ . Or, in the regex... $regex($me,/\[AFK\]/)

Technically, you probably don't need the \ before the ], but it is required before the [ and it's a good idea to also include in before the ] even if it doesn't change the output.

Last edited by Riamus2; 10/08/11 03:59 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: May 2010
Posts: 4
I
Self-satisified door
OP Offline
Self-satisified door
I
Joined: May 2010
Posts: 4
Oi, that WAS very simple.. Argh..

Well many, many thanks to you Riamus2 for your time AND help in actually completing the code for me.

+1


Edit: I might attempt to try regex once more though, just to see if I an get it to work at all and perhaps sometime soon understand it as well. Thanks for your tip regarding it.

Last edited by IrinaWylder; 10/08/11 04:15 PM.
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You can use the /tnick command to change $me to a temporary nickname of your choice. It won't affect your main nickname like this:
Code:
alias back { nick $mnick }
alias afk { tnick $+([AFK],$me) }
Then you can change it back to $mnick


Link Copied to Clipboard