reacting to actions in the channel

Back to PHP-IRC Support

Page: 1  
From User Message Body
Juice
Post #138
Member
Date: 5:57 pm, Mar 12 2006
Posts: 40


How do i get the bot to send a notice to a person when they join the channel?

Have a Great Day!

Juice
Administrator
http://ww4.GameSoda.net
Juice
Post #139
Member
Date: 6:00 pm, Mar 12 2006
Posts: 40


nm, i got it working.

Have a Great Day!

Juice
Administrator
http://ww4.GameSoda.net
Juice
Post #140
Member
Date: 6:48 pm, Mar 12 2006
Posts: 40


ok, got another one though...how do I get the bot to notice a nick change? say I want the bot to change a variable called $playernick whenever the player changes their nick during a game.

I don't know the exact code, but it should be something like this:

in the conf file

nickchange game_mod nickChange

in the mod file

Code

public function nickChange($line, $args)
if ($line['fromHost'] == $playerhost)
{
     $playernick = $line['fromNick'];
     $this->ircClass->notice($chan, "$oldNick has been changed to $playernick.", 1);
}


I don't know the exacts, but this should basically exaplin what I am trying to do. Thanks.

Have a Great Day!

Juice
Administrator
http://ww4.GameSoda.net
Manick
Post #142 - Reply to (#140) by Juice
user avatar
Admin
Date: 8:03 pm, Mar 12 2006
Posts: 223


IRC uses the 'nick' command when people change nicks. I'm not entirely sure on the syntax, but basically you would have something like:

nick game_mod nickChange

in your config file, and then $line['fromNick'] holds the old nick, and either $line['params'] or $line['text'] holds the new nick.

--Manick
PHP-IRC Developer
Juice
Post #155
Member
Date: 4:47 pm, Mar 25 2006
Posts: 40


This is my .conf file:
Code
file    ww_mod modules/werewolf/werewolf.php

join    ww_mod    onJoin
nick    ww_mod  onNickChange

priv    !ww true true true 0 ww_mod parse_ww
priv    alive true true true 0 ww_mod alive
priv    join true true true 0 ww_mod joinhunt
priv    kill true true true 0 ww_mod kill
priv    role true true true 0 ww_mod role
priv    see true true true 0 ww_mod see
priv    vote true true true 0 ww_mod vote


This is a section of my werewolf.php:
Code
    public function onJoin($line, $args)
    {
        // $this->ircClass->notice($chan, "Welcome to $chan!  Please go to http://ww4.gamesoda.com/index.php and give World War IV a try!", 1);
        if (($gamestarted == 1) && ($joining == 0))
            $this->ircClass->notice($line['fromNick'], "A game is currently underway. Please wait for it to finish before attempting to join.", 1);

    }

    //if the player changed their nick and they're in the game, changed the listed name
    public function onNickChange($line, $args)
    {
        $chan = "#werewolf";
        $oldnick = $line['fromNick'];
        $playernick = $line['params'];
        $playernick2 = $line['text'];
        $this->ircClass->notice("Juicebot", "$oldNick has been changed to $playernick or $playernick2.", 1);
    }



As of right now, when someone joins the channel, it works when it is supposed to.

With the current code, whenever someone changes their nick, it is supposed to announce the nickchange to Juicebot (another bot I have in the channel using mIRC). I have tried to have it announce it to the channel also.

Neither of these work. I figure that even if the variables were wrong, it should still send "has been changed to or" to the channel or Juicebot, depending on which one I have it set to at the time.

I can't figure out how join works but nick does not.

Have a Great Day!

Juice
Administrator
http://ww4.GameSoda.net
Manick
Post #156
user avatar
Admin
Date: 6:55 pm, Mar 25 2006
Posts: 223


Try adding:

Code
type nick module function


to typedefs.conf

--Manick
PHP-IRC Developer
proof_of_death
Post #157
Member
Date: 10:53 pm, Mar 25 2006
Posts: 12


just as a note, since you seem to be working on an irc version of werewolf (while i work on an irc version of vampire), if you have access to mysql, you might want to just add a table for irc, with the player's character id, ident, and host as fields. then when the player signs on, they register with the bot.


I'm just adding the finishing touches to the bot at the moment, so my aim's joeCOTterranova if you want to compare notes.

Juice
Post #158
Member
Date: 1:22 am, Mar 26 2006
Posts: 40


Thank you yet again Manick, that has fixed it.

Also, to note...$line['text'] = the new nick.

Have a Great Day!

Juice
Administrator
http://ww4.GameSoda.net
Juice
Post #159
Member
Date: 1:34 am, Mar 26 2006
Posts: 40


ok, apparently on a nick change, it doesn't recognize $line['fromNick'] as being the original nick. Any suggestions?

Have a Great Day!

Juice
Administrator
http://ww4.GameSoda.net
Manick
Post #161
user avatar
Admin
Date: 7:19 am, Mar 26 2006
Posts: 223


Can you double check that? I'm just about totally sure that it has to be stored in $line['fromNick']....

--Manick
PHP-IRC Developer
   

  Pages (2) [ 1 2 ] Next Page

Back to PHP-IRC Support