mIRC Home    About    Download    Register    News    Help

Print Thread
#221592 24/05/10 10:19 PM
D
Dertikter
Dertikter
D
Hi there,

I tried a few different solutions to try and get an on text trigger for $me, but to no avail.

Basically, the code I have now looks something like
Code:
on $999:text:/^[!@.`~^](do|bot)/Si:#:{

With 'bot' being the bots name, but certain factors need me to refine that to the current nick, instead of a set string, something like:
Code:
on $999:text:/^[!@.`~^](do|$me)/Si:#:{


Would prefer not to have * and use an if statement to do it, but I guess I might have to if it isn't possible any other way.

Any help is appreciated.
Thanks.

#221593 24/05/10 11:03 PM
A
asdfasdf
asdfasdf
A
Try
Code:
on $999:text:$($+(/^[!@.`~^],$chr(40),do|,$me,$chr(41),/Si)):#:{

#221595 25/05/10 12:06 AM
D
Dertikter
Dertikter
D
Tested and appears to work fine, thanks!

EDIT: Not knowing much about regex, is it possible to make it match only its nick and nothing close to?

Example: The code above will work with say !bot, but it would also work with !botbanana and the such.

Thanks again.

Last edited by Dertikter; 25/05/10 12:16 AM.
#221599 25/05/10 04:22 AM
A
asdfasdf
asdfasdf
A
Try
Code:
on $999:text:$($+(/^[!@.`~^],$chr(40),do|,$me,$chr(41),$chr(40),$chr(32),|,$chr(36),$chr(41),/Si)):#:{

Makes sure that !do or !$me is either followed by nothing or a space.

#221614 25/05/10 06:01 PM
D
Dertikter
Dertikter
D
Works to perfection, thanks again!

#221617 25/05/10 07:42 PM
A
asdfasdf
asdfasdf
A
You're welcome.

#221619 25/05/10 08:16 PM
Joined: Jul 2007
Posts: 1,124
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,124
That is a long regex. You could have done it like so:
Code:
on $999:text:$(/^[!@.`~^](do|bot|\Q $+ $me $+ \E)$/Si):#:{
\Q and \E in regex makes special characters literal. A nick can consist of them. This will trigger upon
Quote:
!,@,.,',~,or ^Dertikter, do, and me
Just the way you want it.

Tomao #221622 25/05/10 08:56 PM
A
asdfasdf
asdfasdf
A
I should've used \Q\E as well as $+ instead of $+() to avoid the $chr() mess, yeah, thanks.

Enforcing the end of line-$ is not what he wants, though,
he wants !do or !$me (not !bot, he wanted to replace !hisbotname by !$me) followed by bot commands.

So I'd suggest
Code:
on $999:text:$(/^[!@.`~^](do|\Q $+ $me $+ \E)( |$)/Si):#:{


Link Copied to Clipboard