mIRC Home    About    Download    Register    News    Help

Topic Options
#233382 - 10/08/11 04:18 PM Question regarding phrase check in $me before cmmd
IrinaWylder Offline
Self-satisified door

Registered: 11/05/10
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:
/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!

#233383 - 10/08/11 04:52 PM Re: Question regarding phrase check in $me before cmmd [Re: IrinaWylder]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
There really isn't any need to use regex here unless you might have some other format for [AFK]. Otherwise, just use this:

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.

Edited by Riamus2 (10/08/11 04:59 PM)
Invision Support
#Invision on irc.irchighway.net

#233386 - 10/08/11 05:14 PM Re: Question regarding phrase check in $me before cmmd [Re: Riamus2]
IrinaWylder Offline
Self-satisified door

Registered: 11/05/10
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.


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.

Edited by IrinaWylder (10/08/11 05:15 PM)

#233388 - 10/08/11 06:47 PM Re: Question regarding phrase check in $me before cmmd [Re: IrinaWylder]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
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:
alias back { nick $mnick }
alias afk { tnick $+([AFK],$me) }
Then you can change it back to $mnick