1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
20 Channel::Channel(const std::string &cname, time_t ts)
22 chan_hash::iterator findchan = ServerInstance->chanlist->find(cname);
23 if (findchan != ServerInstance->chanlist->end())
24 throw CoreException("Cannot create duplicate channel " + cname);
26 (*(ServerInstance->chanlist))[cname.c_str()] = this;
27 this->name.assign(cname, 0, ServerInstance->Config->Limits.ChanMax);
28 this->age = ts ? ts : ServerInstance->Time();
30 maxbans = topicset = 0;
34 void Channel::SetMode(char mode,bool mode_on)
36 modes[mode-65] = mode_on;
39 void Channel::SetMode(ModeHandler* mh, bool on)
41 modes[mh->GetModeChar() - 65] = on;
44 void Channel::SetModeParam(char mode, const std::string& parameter)
46 CustomModeList::iterator n = custom_mode_params.find(mode);
47 // always erase, even if changing, so that the map gets the new value
48 if (n != custom_mode_params.end())
49 custom_mode_params.erase(n);
50 if (parameter.empty())
52 modes[mode-65] = false;
56 custom_mode_params[mode] = parameter;
57 modes[mode-65] = true;
61 void Channel::SetModeParam(ModeHandler* mode, const std::string& parameter)
63 SetModeParam(mode->GetModeChar(), parameter);
66 std::string Channel::GetModeParameter(char mode)
68 CustomModeList::iterator n = custom_mode_params.find(mode);
69 if (n != custom_mode_params.end())
74 std::string Channel::GetModeParameter(ModeHandler* mode)
76 CustomModeList::iterator n = custom_mode_params.find(mode->GetModeChar());
77 if (n != custom_mode_params.end())
82 int Channel::SetTopic(User *u, std::string &ntopic, bool forceset)
85 u = ServerInstance->FakeClient;
86 if (IS_LOCAL(u) && !forceset)
89 FIRST_MOD_RESULT(OnPreTopicChange, res, (u,this,ntopic));
91 if (res == MOD_RES_DENY)
93 if (res != MOD_RES_ALLOW)
95 if (!this->HasUser(u))
97 u->WriteNumeric(442, "%s %s :You're not on that channel!",u->nick.c_str(), this->name.c_str());
100 if (IsModeSet('t') && !ServerInstance->OnCheckExemption(u,this,"topiclock").check(GetPrefixValue(u) >= HALFOP_VALUE))
102 u->WriteNumeric(482, "%s %s :You do not have access to change the topic on this channel", u->nick.c_str(), this->name.c_str());
108 this->topic.assign(ntopic, 0, ServerInstance->Config->Limits.MaxTopic);
111 this->setby.assign(ServerInstance->Config->FullHostInTopic ? u->GetFullHost() : u->nick, 0, 128);
112 this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
116 this->setby.assign(ServerInstance->Config->ServerName);
117 this->WriteChannelWithServ(ServerInstance->Config->ServerName, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
120 this->topicset = ServerInstance->Time();
122 FOREACH_MOD(I_OnPostTopicChange,OnPostTopicChange(u, this, this->topic));
127 long Channel::GetUserCounter()
129 return userlist.size();
132 Membership* Channel::AddUser(User* user)
134 Membership* memb = new Membership(user, this);
135 userlist[user] = memb;
139 void Channel::DelUser(User* user)
141 UserMembIter a = userlist.find(user);
143 if (a != userlist.end())
150 if (userlist.empty())
153 FIRST_MOD_RESULT(OnChannelPreDelete, res, (this));
154 if (res == MOD_RES_DENY)
156 chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
157 /* kill the record */
158 if (iter != ServerInstance->chanlist->end())
160 FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
161 ServerInstance->chanlist->erase(iter);
163 ServerInstance->GlobalCulls.AddItem(this);
167 bool Channel::HasUser(User* user)
169 return (userlist.find(user) != userlist.end());
172 Membership* Channel::GetUser(User* user)
174 UserMembIter i = userlist.find(user);
175 if (i == userlist.end())
180 const UserMembList* Channel::GetUsers()
185 void Channel::SetDefaultModes()
187 ServerInstance->Logs->Log("CHANNELS", DEBUG, "SetDefaultModes %s",
188 ServerInstance->Config->DefaultModes.c_str());
189 irc::spacesepstream list(ServerInstance->Config->DefaultModes);
191 std::string parameter;
193 list.GetToken(modeseq);
195 for (std::string::iterator n = modeseq.begin(); n != modeseq.end(); ++n)
197 ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
200 if (mode->GetNumParams(true))
201 list.GetToken(parameter);
205 mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true);
211 * add a channel to a user, creating the record for it if needed and linking
212 * it to the user record
214 Channel* Channel::JoinUser(User *user, const char* cn, bool override, const char* key, bool bursting, time_t TS)
216 // Fix: unregistered users could be joined using /SAJOIN
217 if (!user || !cn || user->registered != REG_ALL)
225 * We don't restrict the number of channels that remote users or users that are override-joining may be in.
226 * We restrict local users to MaxChans channels.
227 * We restrict local operators to OperMaxChans channels.
228 * This is a lot more logical than how it was formerly. -- w00t
230 if (IS_LOCAL(user) && !override)
232 if (user->HasPrivPermission("channels/high-join-limit"))
234 if (user->chans.size() >= ServerInstance->Config->OperMaxChans)
236 user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
242 unsigned int maxchans = user->GetClass()->maxchans;
244 maxchans = ServerInstance->Config->MaxChans;
245 if (user->chans.size() >= maxchans)
247 user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
253 strlcpy(cname, cn, ServerInstance->Config->Limits.ChanMax);
254 Ptr = ServerInstance->FindChan(cname);
255 bool created_by_local = false;
260 * Fix: desync bug was here, don't set @ on remote users - spanningtree handles their permissions. bug #358. -- w00t
265 ServerInstance->Logs->Log("CHANNEL",DEBUG,"*** BUG *** Channel::JoinUser called for REMOTE user '%s' on channel '%s' but no TS given!", user->nick.c_str(), cn);
270 created_by_local = true;
273 if (IS_LOCAL(user) && override == false)
275 ModResult MOD_RESULT;
276 FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, NULL, cname, privs, key ? key : ""));
277 if (MOD_RESULT == MOD_RES_DENY)
281 Ptr = new Channel(cname, TS);
285 /* Already on the channel */
286 if (Ptr->HasUser(user))
290 * remote users are allowed us to bypass channel modes
291 * and bans (used by servers)
293 if (IS_LOCAL(user) && override == false)
295 ModResult MOD_RESULT;
296 FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, Ptr, cname, privs, key ? key : ""));
297 if (MOD_RESULT == MOD_RES_DENY)
301 else if (MOD_RESULT == MOD_RES_PASSTHRU)
303 std::string ckey = Ptr->GetModeParameter('k');
304 bool invited = IS_LOCAL(user)->IsInvited(Ptr->name.c_str());
305 bool can_bypass = ServerInstance->Config->InvBypassModes && invited;
309 FIRST_MOD_RESULT(OnCheckKey, MOD_RESULT, (user, Ptr, key ? key : ""));
310 if (!MOD_RESULT.check((key && ckey == key) || can_bypass))
312 // If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled)
313 user->WriteNumeric(ERR_BADCHANNELKEY, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name.c_str());
318 if (Ptr->IsModeSet('i'))
320 FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, Ptr));
321 if (!MOD_RESULT.check(invited))
323 user->WriteNumeric(ERR_INVITEONLYCHAN, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name.c_str());
328 std::string limit = Ptr->GetModeParameter('l');
331 FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, Ptr));
332 if (!MOD_RESULT.check((Ptr->GetUserCounter() < atol(limit.c_str()) || can_bypass)))
334 user->WriteNumeric(ERR_CHANNELISFULL, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name.c_str());
339 if (Ptr->IsBanned(user) && !can_bypass)
341 user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str());
346 * If the user has invites for this channel, remove them now
347 * after a successful join so they don't build up.
351 IS_LOCAL(user)->RemoveInvite(Ptr->name.c_str());
357 if (created_by_local)
359 /* As spotted by jilles, dont bother to set this on remote users */
360 Ptr->SetDefaultModes();
363 return Channel::ForceChan(Ptr, user, privs, bursting, created_by_local);
366 Channel* Channel::ForceChan(Channel* Ptr, User* user, const std::string &privs, bool bursting, bool created)
368 std::string nick = user->nick;
370 Membership* memb = Ptr->AddUser(user);
371 user->chans.insert(Ptr);
373 for (std::string::const_iterator x = privs.begin(); x != privs.end(); x++)
375 const char status = *x;
376 ModeHandler* mh = ServerInstance->Modes->FindMode(status, MODETYPE_CHANNEL);
379 /* Set, and make sure that the mode handler knows this mode was now set */
380 Ptr->SetPrefix(user, mh->GetModeChar(), true);
381 mh->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, Ptr, nick, true);
386 FOREACH_MOD(I_OnUserJoin,OnUserJoin(memb, bursting, created, except_list));
388 Ptr->WriteAllExcept(user, false, 0, except_list, "JOIN :%s", Ptr->name.c_str());
390 /* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */
391 std::string ms = memb->modes;
392 for(unsigned int i=0; i < memb->modes.length(); i++)
393 ms.append(" ").append(user->nick);
394 if ((Ptr->GetUserCounter() > 1) && (ms.length()))
395 Ptr->WriteAllExceptSender(user, ServerInstance->Config->CycleHostsFromUser, 0, "MODE %s +%s", Ptr->name.c_str(), ms.c_str());
401 user->WriteNumeric(RPL_TOPIC, "%s %s :%s", user->nick.c_str(), Ptr->name.c_str(), Ptr->topic.c_str());
402 user->WriteNumeric(RPL_TOPICTIME, "%s %s %s %lu", user->nick.c_str(), Ptr->name.c_str(), Ptr->setby.c_str(), (unsigned long)Ptr->topicset);
406 FOREACH_MOD(I_OnPostJoin,OnPostJoin(memb));
410 bool Channel::IsBanned(User* user)
413 FIRST_MOD_RESULT(OnCheckChannelBan, result, (user, this));
415 if (result != MOD_RES_PASSTHRU)
416 return (result == MOD_RES_DENY);
418 for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
420 if (CheckBan(user, i->data))
426 bool Channel::CheckBan(User* user, const std::string& mask)
429 FIRST_MOD_RESULT(OnCheckBan, result, (user, this, mask));
430 if (result != MOD_RES_PASSTHRU)
431 return (result == MOD_RES_DENY);
433 // extbans were handled above, if this is one it obviously didn't match
437 std::string::size_type at = mask.find('@');
438 if (at == std::string::npos)
441 char tomatch[MAXBUF];
442 snprintf(tomatch, MAXBUF, "%s!%s", user->nick.c_str(), user->ident.c_str());
443 std::string prefix = mask.substr(0, at);
444 if (InspIRCd::Match(tomatch, prefix, NULL))
446 std::string suffix = mask.substr(at + 1);
447 if (InspIRCd::Match(user->host, suffix, NULL) ||
448 InspIRCd::Match(user->dhost, suffix, NULL) ||
449 InspIRCd::MatchCIDR(user->GetIPString(), suffix, NULL))
455 ModResult Channel::GetExtBanStatus(User *user, char type)
458 FIRST_MOD_RESULT(OnExtBanCheck, rv, (user, this, type));
459 if (rv != MOD_RES_PASSTHRU)
461 for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
463 if (i->data[0] == type && i->data[1] == ':')
465 std::string val = i->data.substr(2);
466 if (CheckBan(user, val))
470 return MOD_RES_PASSTHRU;
474 * remove a channel from a users record, and return the number of users left.
475 * Therefore, if this function returns 0 the caller should delete the Channel.
477 void Channel::PartUser(User *user, std::string &reason)
482 Membership* memb = GetUser(user);
487 FOREACH_MOD(I_OnUserPart,OnUserPart(memb, reason, except_list));
489 WriteAllExcept(user, false, 0, except_list, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : " :", reason.c_str());
491 user->chans.erase(this);
492 this->RemoveAllPrefixes(user);
498 void Channel::KickUser(User *src, User *user, const char* reason)
500 if (!src || !user || !reason)
503 Membership* memb = GetUser(user);
508 src->WriteNumeric(ERR_USERNOTINCHANNEL, "%s %s %s :They are not on that channel",src->nick.c_str(), user->nick.c_str(), this->name.c_str());
511 if ((ServerInstance->ULine(user->server)) && (!ServerInstance->ULine(src->server)))
513 src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Only a u-line may kick a u-line from a channel.",src->nick.c_str(), this->name.c_str());
518 if (ServerInstance->ULine(src->server))
521 FIRST_MOD_RESULT(OnUserPreKick, res, (src,memb,reason));
523 if (res == MOD_RES_DENY)
526 if (res == MOD_RES_PASSTHRU)
528 int them = this->GetPrefixValue(src);
529 char us = GetPrefixChar(user)[0];
530 ModeHandler* mh = ServerInstance->Modes->FindMode(us, MODETYPE_CHANNEL);
531 int min = mh ? mh->GetLevelRequired() : HALFOP_VALUE;
532 if (them < HALFOP_VALUE || them < min)
534 src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator",
535 src->nick.c_str(), this->name.c_str(), min > HALFOP_VALUE ? "" : "half-");
544 FOREACH_MOD(I_OnUserKick,OnUserKick(src, memb, reason, except_list));
546 WriteAllExcept(src, false, 0, except_list, "KICK %s %s :%s", name.c_str(), user->nick.c_str(), reason);
548 user->chans.erase(this);
549 this->RemoveAllPrefixes(user);
555 void Channel::WriteChannel(User* user, const char* text, ...)
557 char textbuffer[MAXBUF];
563 va_start(argsPtr, text);
564 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
567 this->WriteChannel(user, std::string(textbuffer));
570 void Channel::WriteChannel(User* user, const std::string &text)
577 snprintf(tb,MAXBUF,":%s %s", user->GetFullHost().c_str(), text.c_str());
578 std::string out = tb;
580 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
582 if (IS_LOCAL(i->first))
583 i->first->Write(out);
587 void Channel::WriteChannelWithServ(const std::string& ServName, const char* text, ...)
589 char textbuffer[MAXBUF];
595 va_start(argsPtr, text);
596 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
599 this->WriteChannelWithServ(ServName, std::string(textbuffer));
602 void Channel::WriteChannelWithServ(const std::string& ServName, const std::string &text)
606 snprintf(tb,MAXBUF,":%s %s", ServName.empty() ? ServerInstance->Config->ServerName.c_str() : ServName.c_str(), text.c_str());
607 std::string out = tb;
609 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
611 if (IS_LOCAL(i->first))
612 i->first->Write(out);
616 /* write formatted text from a source user to all users on a channel except
617 * for the sender (for privmsg etc) */
618 void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...)
620 char textbuffer[MAXBUF];
626 va_start(argsPtr, text);
627 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
630 this->WriteAllExceptSender(user, serversource, status, std::string(textbuffer));
633 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...)
635 char textbuffer[MAXBUF];
641 int offset = snprintf(textbuffer,MAXBUF,":%s ", user->GetFullHost().c_str());
643 va_start(argsPtr, text);
644 vsnprintf(textbuffer + offset, MAXBUF - offset, text, argsPtr);
647 this->RawWriteAllExcept(user, serversource, status, except_list, std::string(textbuffer));
650 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &text)
654 snprintf(tb,MAXBUF,":%s %s", serversource ? ServerInstance->Config->ServerName.c_str() : user->GetFullHost().c_str(), text.c_str());
655 std::string out = tb;
657 this->RawWriteAllExcept(user, serversource, status, except_list, std::string(tb));
660 void Channel::RawWriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &out)
662 unsigned int minrank = 0;
665 ModeHandler* mh = ServerInstance->Modes->FindPrefix(status);
667 minrank = mh->GetPrefixRank();
669 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
671 if (IS_LOCAL(i->first) && (except_list.find(i->first) == except_list.end()))
673 /* User doesn't have the status we're after */
674 if (minrank && i->second->getRank() < minrank)
677 i->first->Write(out);
682 void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const std::string& text)
685 except_list.insert(user);
686 this->WriteAllExcept(user, serversource, status, except_list, std::string(text));
690 * return a count of the users on a specific channel accounting for
691 * invisible users who won't increase the count. e.g. for /LIST
693 int Channel::CountInvisible()
696 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
698 if (!(i->first->IsModeSet('i')))
705 char* Channel::ChanModes(bool showkey)
707 static char scratch[MAXBUF];
708 static char sparam[MAXBUF];
709 char* offset = scratch;
710 std::string extparam;
715 /* This was still iterating up to 190, Channel::modes is only 64 elements -- Om */
716 for(int n = 0; n < 64; n++)
722 if (n == 'k' - 65 && !showkey)
728 extparam = this->GetModeParameter(n + 65);
730 if (!extparam.empty())
732 charlcat(sparam,' ',MAXBUF);
733 strlcat(sparam,extparam.c_str(),MAXBUF);
738 /* Null terminate scratch */
740 strlcat(scratch,sparam,MAXBUF);
744 /* compile a userlist of a channel into a string, each nick seperated by
745 * spaces and op, voice etc status shown as @ and +, and send it to 'user'
747 void Channel::UserList(User *user)
755 if (this->IsModeSet('s') && !this->HasUser(user) && !user->HasPrivPermission("channels/auspex"))
757 user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), this->name.c_str());
761 dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name.c_str());
764 char* ptr = list + dlen;
766 /* Improvement by Brain - this doesnt change in value, so why was it inside
769 bool has_user = this->HasUser(user);
771 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
773 if ((!has_user) && (i->first->IsModeSet('i')))
776 * user is +i, and source not on the channel, does not show
782 std::string prefixlist = this->GetPrefixChar(i->first);
783 std::string nick = i->first->nick;
785 FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->second, prefixlist, nick));
787 /* Nick was nuked, a module wants us to skip it */
793 if (curlen + prefixlist.length() + nick.length() + 1 > 480)
795 /* list overflowed into multiple numerics */
796 user->WriteNumeric(RPL_NAMREPLY, std::string(list));
798 /* reset our lengths */
799 dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name.c_str());
806 ptrlen = snprintf(ptr, MAXBUF, "%s%s ", prefixlist.c_str(), nick.c_str());
814 /* if whats left in the list isnt empty, send it */
817 user->WriteNumeric(RPL_NAMREPLY, std::string(list));
820 user->WriteNumeric(RPL_ENDOFNAMES, "%s %s :End of /NAMES list.", user->nick.c_str(), this->name.c_str());
823 long Channel::GetMaxBans()
825 /* Return the cached value if there is one */
827 return this->maxbans;
829 /* If there isnt one, we have to do some O(n) hax to find it the first time. (ick) */
830 for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
832 if (InspIRCd::Match(this->name, n->first, NULL))
834 this->maxbans = n->second;
839 /* Screw it, just return the default of 64 */
841 return this->maxbans;
844 void Channel::ResetMaxBans()
849 /* returns the status character for a given user on a channel, e.g. @ for op,
850 * % for halfop etc. If the user has several modes set, the highest mode
851 * the user has must be returned.
853 const char* Channel::GetPrefixChar(User *user)
855 static char pf[2] = {0, 0};
857 unsigned int bestrank = 0;
859 UserMembIter m = userlist.find(user);
860 if (m != userlist.end())
862 for(unsigned int i=0; i < m->second->modes.length(); i++)
864 char mchar = m->second->modes[i];
865 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
866 if (mh && mh->GetPrefixRank() > bestrank && mh->GetPrefix())
868 bestrank = mh->GetPrefixRank();
869 pf[0] = mh->GetPrefix();
876 unsigned int Membership::getRank()
878 char mchar = modes.c_str()[0];
882 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
884 rv = mh->GetPrefixRank();
889 const char* Channel::GetAllPrefixChars(User* user)
891 static char prefix[64];
894 UserMembIter m = userlist.find(user);
895 if (m != userlist.end())
897 for(unsigned int i=0; i < m->second->modes.length(); i++)
899 char mchar = m->second->modes[i];
900 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
901 if (mh && mh->GetPrefix())
902 prefix[ctr++] = mh->GetPrefix();
910 unsigned int Channel::GetPrefixValue(User* user)
912 UserMembIter m = userlist.find(user);
913 if (m == userlist.end())
915 return m->second->getRank();
918 bool Channel::SetPrefix(User* user, char prefix, bool adding)
920 ModeHandler* delta_mh = ServerInstance->Modes->FindMode(prefix, MODETYPE_CHANNEL);
923 UserMembIter m = userlist.find(user);
924 if (m == userlist.end())
926 for(unsigned int i=0; i < m->second->modes.length(); i++)
928 char mchar = m->second->modes[i];
929 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
930 if (mh && mh->GetPrefixRank() <= delta_mh->GetPrefixRank())
933 m->second->modes.substr(0,i) +
934 (adding ? std::string(1, prefix) : "") +
935 m->second->modes.substr(mchar == prefix ? i+1 : i);
936 return adding != (mchar == prefix);
940 m->second->modes += std::string(1, prefix);
944 void Channel::RemoveAllPrefixes(User* user)
946 UserMembIter m = userlist.find(user);
947 if (m != userlist.end())
949 m->second->modes.clear();