mIRC Homepage

Wildcards with on TEXT

Posted By: zigress

Wildcards with on TEXT - 19/03/19 07:59 PM

Example Code:
ON *:TEXT:!test*:#: {
  if ($3) && ($3 !isnum) { echo 3 is not num | return }
  if ($2 == $null) { echo use !test [word] [number] | return }
  else { echo good }

If I want $1 (the command, !test) to be exact match but not $2 and $3, what wildcard (e.g. * or &, etc) should I use with this command? In its current form, I can use the following line to cause the command to run, which is not what I want:
!testhello hello 2

Thank you in advance!
Posted By: Wims

Re: Wildcards with on TEXT - 19/03/19 08:18 PM

Wildcards cannot express condition, you cannot tell it that the first word should be !test and that the second word is optional without accepting a match such as "!test ", with only a space after it

* meaning anything, !test* does match !testhello, you want at least !test * but as said, it matches on "!test " which can be problematic.
You can use a general * for the matchtext and then check that $1 == !test, but that means the on text event triggers for any text spoken before deciding to do nothing on irrelevant text, meaning more processing, so using !test * is still the best idea, to avoid matching on any messages, and then you check for $2 and $3

on *:text:!test *:#:{
  if ($2 == $null) {
    echo use !test [word] [number]
    ;return is not really required in this simple example.
  elseif ($3 != $null) && ($3 !isnum) {
    echo $!3 is not num
  else { 
    echo good
Posted By: zigress

Re: Wildcards with on TEXT - 19/03/19 10:56 PM

Ah, I understand. I'll just go ahead and use test * then. Thank you for your explanation!
© 2020 mIRC Discussion Forums