Check if the user is in room before sending information about nick change. Fixes bug when users have been added to all rooms when they changed their IRC nickname

This commit is contained in:
Jan Kaluza 2012-12-13 12:10:14 +01:00
parent 6cbfab6b72
commit 79b5030035
2 changed files with 10 additions and 0 deletions

View file

@ -129,6 +129,9 @@ void MyIrcSession::on_nickChanged(IrcMessage *message) {
for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
std::string nickname = TO_UTF8(m->sender().name());
if (!hasIRCBuddy(it->second->getChannel(), nickname)) {
continue;
}
IRCBuddy &buddy = getIRCBuddy(it->second->getChannel(), nickname);
LOG4CXX_INFO(logger, user << ": " << nickname << " changed nickname to " << TO_UTF8(m->nick()));
np->handleParticipantChanged(user, nickname, it->second->getChannel() + suffix,(int) buddy.isOp(), pbnetwork::STATUS_ONLINE, "", TO_UTF8(m->nick()));
@ -145,6 +148,9 @@ void MyIrcSession::on_modeChanged(IrcMessage *message) {
return;
LOG4CXX_INFO(logger, user << ": " << nickname << " changed mode to " << mode);
for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
if (!hasIRCBuddy(it->second->getChannel(), nickname)) {
continue;
}
IRCBuddy &buddy = getIRCBuddy(it->second->getChannel(), nickname);
if (mode == "+o") {
buddy.setOp(true);

View file

@ -89,6 +89,10 @@ public:
return m_identify;
}
bool hasIRCBuddy(const std::string &channel, const std::string &name) {
return m_buddies[channel].find(name) != m_buddies[channel].end();
}
IRCBuddy &getIRCBuddy(const std::string &channel, const std::string &name) {
return m_buddies[channel][name];
}