|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Feb 05, 2009 10:56 pm
Odd Regex Issue [Solved] |
I copied and pasted the pattern from Spellbot-t into Spellbot-t2 and yet the pattern:
Diamante tells you 'cc: perm'
fails to match.
Spellbot-t
Code: |
<trigger name="Spellbot-t" priority="1910" regex="true" enabled="false" id="94">
<pattern>^(?:\(Imm\) )?(?:The ghost of )?([\w']+|A masked swashbuckler|\(An Imm\)){1,2} tells you (?:\([^\)]+\) )?'(cc:(?: )?(.*))'</pattern>
<value>#IF ((%begins("permanency",%3)) OR (%begins("chain lightning", %3)) OR (%begins("fireball", %3)) OR (%begins("disjunction", %3)) OR (%begins("acid blast", %3)) OR (%begins("blizzra", %3)) OR (%begins("disjunction", %3)) OR (%begins("acid blast", %3)) OR (%begins("blizzra", %3)))
{
#send {"reply Not on your life, try another. (ooc: Automated response to spellbot request)"}
}
{
$cur_posn=@posn
#send {"stand"}
#send {"c '"%3"' "%1}
#send {$cur_posn @bed}
regen
}
</value>
</trigger>
|
Spellbot-t2
Code: |
<trigger name="spellbot-t2" priority="980" enabled="false" id="98">
<pattern>^(?:\(Imm\) )?(?:The ghost of )?([\w']+|A masked swashbuckler|\(An Imm\)){1,2} tells you (?:\([^\)]+\) )?'(cc:(?: )?(.*))'</pattern>
<value>#IF ((%begins("permanency",%3)) OR (%begins("chain lightning", %3)) OR (%begins("fireball", %3)) OR (%begins("disjunction", %3)) OR (%begins("acid blast", %3)) OR (%begins("blizzra", %3)) OR (%begins("disjunction", %3)) OR (%begins("acid blast", %3)) OR (%begins("blizzra", %3)))
{
#send {"reply Not on your life, try another. (ooc: Automated response to spellbot request)"}
}
{
$cur_posn=@posn
#send {"stand"}
#send {"c '"%3"' "%4}
#send {$cur_posn @bed}
regen
}
</value>
</trigger>
|
I did this because the regex I had made for spellbot-t2 which was similar to spellbot-t wasn't working. So I tried having them the same, but it didn't work. |
|
_________________ Listen to my Guitar - If you like it, listen to more
Last edited by chamenas on Thu Feb 05, 2009 11:57 pm; edited 1 time in total |
|
|
|
calesta Apprentice
Joined: 07 Dec 2008 Posts: 102 Location: New Hampshire, USA
|
Posted: Thu Feb 05, 2009 11:44 pm |
Spellbot-t2 doesn't appear to have the regex flag turned on.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Feb 05, 2009 11:57 pm |
doh... man I'm stupid.
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Fri Feb 06, 2009 12:01 am |
Er. Matches for me? Do you mean that it fails to function inside the trigger?
Btw, I think you can clean up your pattern a lot... I would use
Code: |
^(?:\(Imm\) )?(?:The ghost of )?([\w']+|A masked swashbuckler|\(An Imm\)) tells you .*'cc: *([A-Za-z ]+)' |
Although I was unsure about the section where you had used {1,2}, as it didn't make sense to me that you would be able to have more than one "name" in a tell. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Feb 06, 2009 12:08 am |
First name and Last name Also, sometimes the Imms use mobs with first and last names, most players dont. I dont think any do.
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Fri Feb 06, 2009 1:42 am |
Oh, yeah, that makes sense. Well you should fix it, since it wouldn't work anyway--it'll need a space inside the parentheses.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Feb 06, 2009 2:10 am |
This regex above would work the same way as mine? What if the tell contains - ', I would likely add those in to the [A-Za-z ]+ as well, no?
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Fri Feb 06, 2009 5:54 am |
Code: |
^(?:\(Imm\) )?(?:The ghost of )?([\w']+(?: [\w']+)?|A masked swashbuckler|\(An Imm\)) tells you .*'cc: *([-'A-Za-z ]+)' |
Fixed to account for having two names, or the characters - or ' in the spell name. The reason why I switched to using a character class as opposed to just .* for the name of the spell that they want you to cast is so they can't do something like
tell chamenas cc: heal';give all gold to gamma;
which could then cause you to do something you didn't intend to do (and potentially make me rich). Anyway, you can never be too careful. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Feb 06, 2009 6:14 am |
lol, yes, that's why, in the other thread, I have an exception list. But I can certainly see how they could try to abuse it that way too. Thanks.
|
|
|
|
|
|