raisedragon / pircbotx

Automatically exported from code.google.com/p/pircbotx
0 stars 0 forks source link

onPart not called when the bot itself parts a channel #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Source code for handling the PART command at line 1691 of PircBotX.java:
else if (command.equals("PART"))
        // Someone is parting from a channel.
        if (sourceNick.equals(getNick()))
                //We parted the channel
                userChanInfo.deleteA(channel);
        else {
                //Just remove the user from memory
                userChanInfo.dissociate(channel, getUser(sourceNick));
                getListenerManager().dispatchEvent(new PartEvent(this, channel, source, message));
        }
According to the above codes, onPart will not be called when the bot itself 
parts a channel, but in the original PircBot, it will be called.

I do think that onPart should be called even if it is us (the bot) parts a 
channel. So the code should be:

else if (command.equals("PART")) {
        // Someone is parting from a channel.
        if (sourceNick.equals(getNick()))
                //We parted the channel
                userChanInfo.deleteA(channel);
        else 
                //Just remove the user from memory
                userChanInfo.dissociate(channel, getUser(sourceNick));
        //Instead of just calling the partEvent when other users parted, also call it when we part
        getListenerManager().dispatchEvent(new PartEvent(this, channel, source, message));
}

Thanks

Original issue reported on code.google.com by lduckd...@gmail.com on 5 Dec 2012 at 9:46

GoogleCodeExporter commented 9 years ago
Interesting. Spelunking through the repository it seems way back in Revision 
68eb613f301f (Rev 11!) in 2010 I commented out the code that ran in the else 
block, then autformat pushed it into the else block. From then on I guess I 
assumed that's how it worked. Can't believe its been like that since then

Fixed in Revision 90d3e4916866, and added test in Revision 99a646ea7450

Original comment by Lord.Qua...@gmail.com on 5 Dec 2012 at 11:29