ircmirc

If nick isin text file line x


I'm having an issue with my current code.

on *:TEXT:*text*:#:{ 
  if ($nick isin $read(test.txt, 1)) {
    msg $chan working.
  }
}

The issue I am having is if the nick "User1" is in test.txt, and "User12" types text, It will detect it as User1 was in test.txt! How can I make it so "User12" will not say working if "User1" is on line 1.


Solution

  • You problem is that User1 contains in the first line User12 and you're searching by isin.

    You can use regex $+(\b,$nick,\b) with \b word boundary for for making sure there is not text before or after the searched $nick

    on *:TEXT:*text*:#:{ 
      var %line = $read(test.txt, 1)
      if ($regex(%line, $+(\b,$nick,\b))) {
        msg $chan working.
      }
    }