X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fchannels.cpp;h=14b1ea54534b3559750e1e2594db4858ff338575;hb=b25070bf5e9447533bf1a0555c6954740ca12340;hp=6e3bc5e04e4cbe6f21dcbb4104ed9af9e581c588;hpb=2c51a2bf17b6c377f0207f3d89b4b3f399fc0178;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/channels.cpp b/src/channels.cpp index 6e3bc5e04..14b1ea545 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -180,7 +180,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co } if (user->chans.size() >= maxchans) { - user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s :You are on too many channels", cname.c_str()); + user->WriteNumeric(ERR_TOOMANYCHANNELS, cname, "You are on too many channels"); return NULL; } } @@ -240,7 +240,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co if (!MOD_RESULT.check(InspIRCd::TimingSafeCompare(ckey, key))) { // If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled) - user->WriteNumeric(ERR_BADCHANNELKEY, "%s :Cannot join channel (Incorrect channel key)", chan->name.c_str()); + user->WriteNumeric(ERR_BADCHANNELKEY, chan->name, "Cannot join channel (Incorrect channel key)"); return NULL; } } @@ -250,7 +250,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, chan)); if (MOD_RESULT != MOD_RES_ALLOW) { - user->WriteNumeric(ERR_INVITEONLYCHAN, "%s :Cannot join channel (Invite only)", chan->name.c_str()); + user->WriteNumeric(ERR_INVITEONLYCHAN, chan->name, "Cannot join channel (Invite only)"); return NULL; } } @@ -261,14 +261,14 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, chan)); if (!MOD_RESULT.check((chan->GetUserCounter() < atol(limit.c_str())))) { - user->WriteNumeric(ERR_CHANNELISFULL, "%s :Cannot join channel (Channel is full)", chan->name.c_str()); + user->WriteNumeric(ERR_CHANNELISFULL, chan->name, "Cannot join channel (Channel is full)"); return NULL; } } if (chan->IsBanned(user)) { - user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s :Cannot join channel (You're banned)", chan->name.c_str()); + user->WriteNumeric(ERR_BANNEDFROMCHAN, chan->name, "Cannot join channel (You're banned)"); return NULL; } } @@ -405,23 +405,25 @@ ModResult Channel::GetExtBanStatus(User *user, char type) * Remove a channel from a users record, remove the reference to the Membership object * from the channel and destroy it. */ -void Channel::PartUser(User *user, std::string &reason) +bool Channel::PartUser(User* user, std::string& reason) { MemberMap::iterator membiter = userlist.find(user); - if (membiter != userlist.end()) - { - Membership* memb = membiter->second; - CUList except_list; - FOREACH_MOD(OnUserPart, (memb, reason, except_list)); + if (membiter == userlist.end()) + return false; - WriteAllExcept(user, false, 0, except_list, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : " :", reason.c_str()); + Membership* memb = membiter->second; + CUList except_list; + FOREACH_MOD(OnUserPart, (memb, reason, except_list)); - // Remove this channel from the user's chanlist - user->chans.erase(memb); - // Remove the Membership from this channel's userlist and destroy it - this->DelUser(membiter); - } + WriteAllExcept(user, false, 0, except_list, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : " :", reason.c_str()); + + // Remove this channel from the user's chanlist + user->chans.erase(memb); + // Remove the Membership from this channel's userlist and destroy it + this->DelUser(membiter); + + return true; } void Channel::KickUser(User* src, const MemberMap::iterator& victimiter, const std::string& reason) @@ -560,6 +562,13 @@ const char* Channel::ChanModes(bool showkey) return scratch.c_str(); } +void Channel::WriteNotice(const std::string& text) +{ + std::string rawmsg = "NOTICE "; + rawmsg.append(this->name).append(" :").append(text); + WriteChannelWithServ(ServerInstance->Config->ServerName, rawmsg); +} + /* returns the status character for a given user on a channel, e.g. @ for op, * % for halfop etc. If the user has several modes set, the highest mode * the user has must be returned.