|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
on *:TEXT:*:#: {
var %x = /^(hello|hey|hi)\s $+ $me $+ /Si
if ($regex($1-,%x)) {
if $right($me,4) != -afk {
describe # Hello $nick $+ , hows it going ? :)
}
else {
describe # Sorry $nick $+ , but I'm not able to have a conversation with you at this time :)
}
} This works, just wondered if there was a better way to do it, such as having it all in the ON TEXT event, or if it makes any difference.
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
Nice one, RusselB. It works very well. I made a previous post attempting to use something else but to no avail, compared to yours. However, the var can be omitted and gathered in the on text event as such: on $*:TEXT:$(/^(hello|hey|hi|hello,|hey,|hi,)\s( $+ $me $+ )$/Si):#: {
if ($regex($1-,$regml(2))) { if ($right($me,4) != -afk) { describe # Hello $nick $+ , hows it going ? :) }
else { describe # Sorry $nick $+ , but I'm not able to have a conversation with you at this time :) }
}
} Comma match is added in case people use hi, <nickname> instead of hi <nickname>
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
Well I used a testing script I got off of here last year to test the evaluation time of different identifiers and comparisons. The conclusion was that 'isin' was actually the fastest. I also found using "else" is slower than alternative methods. on *:TEXT:*:#:{
if ($1 isin hi.hello.hey) && ($2 == $me) {
if {$right($me,4) == -afk) { describe # Sorry $nick $+ , but I'm not able to have a conversation with you at this time :) | return }
describe # Hello $nick $+ , hows it going ? :)
}
} Something I have to ask though is about the -afk. If you are indeed afk this would require the user to say Hey -afkRusselB ! Also, no punctuation afterwards would be allowed. Hey RusselB! wouldnt work since $2 is RusselB! and not $me which is RusselB. Any thoughts about this?
Last edited by DJ_Sol; 30/10/08 10:19 PM.
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
I believe his away nickname is RusselB-afk //echo -a $right(ResselB-afk,4) I think regex works decently well in this case for matching purposes. I have addressed the ! and . punctuation so that people can call hi RusselB! or hi, RusselB. or Hi russellb or without any. The nickname being called is not case sensitive because of /i modifier. And it will not trigger when someone calls out in this fashion: hi russelb <followed by words> on $*:TEXT:$(/^(hello|hey|hi|hello,|hey,|hi,)\s( $+ $me $+ )(!|.|)$/Si):#: {
if ($regex($1-,$regml(2))) { if ($right($me,4) != -afk) { describe # Hello $nick $+ , hows it going ? :) }
else { describe # Sorry $nick $+ , but I'm not able to have a conversation with you at this time :) }
}
}
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
Yeah thats a good use of regex.
|
|
|
|
|
|