#13 Topic Change Bug (And Fix)

closed-fixed
nobody
None
5
2004-03-12
2004-03-12
No

I am currently creating a logging add on (mIRC style) for
this IRC bot, when i found a strange problem in the data
returned using SMARTIRC_TYPE_TOPICCHANGE

Basically, the channel was missing from the data array
as shown by this debugging output:
$data->type => 512
$data->channel => ""

After a bit of digging around, I found two problems in
SmartIRC.php, both in the function _rawreceive.

Here is the code before:
if ($ircdata->type & (SMARTIRC_TYPE_CHANNEL|
SMARTIRC_TYPE_ACTION|
SMARTIRC_TYPE_MODECHANGE|
SMARTIRC_TYPE_KICK|
SMARTIRC_TYPE_PART|
SMARTIRC_TYPE_JOIN))
{
$ircdata->channel = $lineex[2];
}
else if ($ircdata->type & (SMARTIRC_TYPE_WHO|
SMARTIRC_TYPE_BANLIST|
SMARTIRC_TYPE_TOPIC|

SMARTIRC_TYPE_CHANNELMODE))
{
$ircdata->channel = $lineex[3];
}

Here is the working version:
if ($ircdata->type & (SMARTIRC_TYPE_CHANNEL|
SMARTIRC_TYPE_ACTION|
SMARTIRC_TYPE_MODECHANGE|
SMARTIRC_TYPE_KICK|
SMARTIRC_TYPE_PART|
SMARTIRC_TYPE_TOPICCHANGE|
SMARTIRC_TYPE_JOIN))
{
$ircdata->channel = $lineex[2];
}
else if ($ircdata->type & (SMARTIRC_TYPE_WHO|
SMARTIRC_TYPE_BANLIST|

SMARTIRC_TYPE_CHANNELMODE))
{
$ircdata->channel = $lineex[3];
}

As you can see, the constant used was wrong
(SMARTIRC_TYPE_TOPIC instead of
SMARTIRC_TYPE_TOPICCHANGE), and the wrong part of
$lineex was being assigned as the channel (3 instead of
2).

Discussion

  • Mirco Bauer

    Mirco Bauer - 2004-03-12

    Logged In: YES
    user_id=598557

    this is already fixed in the CVS version:
    http://cvs.php.net/diff.php/pear/Net_SmartIRC/SmartIRC.php?r1=1.73&r2=1.74&ty=h

    TOPIC != TOPICCHANGE
    TOPIC means a topic request was sent the the the reply of
    that is the current topic, this is SMARTIRC_TYPE_TOPIC

    TOPICCHANGE means it was changed by a user, that is a
    different event and the rawmessage looks different.

    anyhow thanks for your bugreport

     
  • Mirco Bauer

    Mirco Bauer - 2004-03-12
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks