magic word reply module

Back to Module Development

Page: 1  
From User Message Body
eagle
Post #1052
Member
Date: 5:10 pm, Jun 19 2010
Posts: 7


Hi all. I've hit another wall and judging by my past topics it's probably another easy solution.

The idea

I'd like to make the bot respond to a magic word, no matter where it is in the other users' text. So I already have triggers down, user says foo, bot says bar. But now the bot needs to reply bar also for lines like:
abcfoo
abc FoOAbC
abcfooabc

What I've got so far

ModName.conf
Code
priv    foo true true true 0 ModName test

ModName.php
Code
class ModName extends module {
    public function test($line, $args)
    {
        if (preg_match('/foo/i',$line['text']))
        {
            $this->ircClass->privMsg($line['to'], "bar! (success)");
            return;
        }
        else
        {
            $this->ircClass->privMsg($line['to'], "rab (failure)");
            return;
        }
    }
}


The results are
foo -> success
abcfoo -> no response
abc FoOAbC -> no response
abcfooabc -> no response

Where's the problem?

Last edited by eagle at 5:29 pm, Jun 19 2010

   

Back to Module Development