Change bot nick & join channels, while connected

Back to Module Development

Page: 1  
From User Message Body
eagle
Post #1003
Member
Date: 1:16 pm, Jan 18 2010
Posts: 7


I've read the readme, searched the web and the forums but I cant find this so here's a topic.

1. I'd like to change the nickname of the bot while connected. Currently I stop the bot, edit the config file and start the bot. This is too technical for some of my ops and frankly, it's a hassle for myself as well.

I know how to make a working trigger, I just need the command to change the bots name.
Code
public function nick($line, $args)
{
    $channel = "#mychannel";
    if( $this->ircClass->isMode($line['fromNick'], $channel, "o") )
    {
        // change botnick code here
        $this->ircClass->notice($line['fromNick'], "Done.");
    }
    else
    {
        $msg = "You are not allowed to give this command.";
        $this->ircClass->notice($line['fromNick'], $msg);
    }
    return;
}


2. In the same way I would like to use a trigger to make the bot join a channel instead of having to edit the config files and restart the bot.

The code for this is almost identical:
Code
public function join($line, $args)
{
    $channel = "#mychannel";
    if( $this->ircClass->isMode($line['fromNick'], $channel, "o") )
    {
        // join channel code here
        $this->ircClass->notice($line['fromNick'], "Done.");
    }
    else
    {
        $msg = "You are not allowed to give this command.";
        $this->ircClass->notice($line['fromNick'], $msg);
    }
    return;
}


If you read this and know the answer, please reply. These forums are not very popular so you might be the only one able to help me before my hair turns gray. ;)

Thanks.

Mad_Clog
Post #1004 - Reply to (#1003) by eagle
user avatar
Member
Date: 7:04 pm, Jan 18 2010
Posts: 176


1)
$this->ircClass->setClientConfigVar('nick', 'NewNickName');
Do keep in mind the changes don't actually get written to the config, so if you restart the bot the nickname set in the config will be used again.

2)
$this->ircClass->maintainChannel('#channel', 'channelKey');
The second parameter is optional and the same applies as above, restart == channel lost

Both of these commands (and many more) can be found in the command_reference.txt by the way ;)

Good luck!


eagle
Post #1005
Member
Date: 2:39 pm, Jan 19 2010
Posts: 7


Thank you very much, it worked.

   

Back to Module Development