mIRC Home    About    Download    Register    News    Help

Print Thread
#221592 24/05/10 10:19 PM
Joined: Nov 2004
Posts: 21
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
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.

Joined: Dec 2008
Posts: 95
A
Babel fish
Offline
Babel fish
A
Joined: Dec 2008
Posts: 95
Try
Code:
on $999:text:$($+(/^[!@.`~^],$chr(40),do|,$me,$chr(41),/Si)):#:{

Joined: Nov 2004
Posts: 21
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
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.
Joined: Dec 2008
Posts: 95
A
Babel fish
Offline
Babel fish
A
Joined: Dec 2008
Posts: 95
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.

Joined: Nov 2004
Posts: 21
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
Works to perfection, thanks again!

Joined: Dec 2008
Posts: 95
A
Babel fish
Offline
Babel fish
A
Joined: Dec 2008
Posts: 95
You're welcome.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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
Joined: Dec 2008
Posts: 95
A
Babel fish
Offline
Babel fish
A
Joined: Dec 2008
Posts: 95
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