1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 /* $Core: libIRCDchannels */
21 Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) : ServerInstance(Instance)
23 chan_hash::iterator findchan = ServerInstance->chanlist->find(cname);
24 if (findchan != Instance->chanlist->end())
25 throw CoreException("Cannot create duplicate channel " + cname);
27 (*(ServerInstance->chanlist))[cname.c_str()] = this;
28 strlcpy(this->name, cname.c_str(), CHANMAX);
29 this->created = ts ? ts : ServerInstance->Time();
30 this->age = this->created;
35 *topic = *setby = *key = 0;
36 maxbans = topicset = limit = 0;
40 void Channel::SetMode(char mode,bool mode_on)
42 modes[mode-65] = mode_on;
44 this->SetModeParam(mode,"",false);
48 void Channel::SetModeParam(char mode,const char* parameter,bool mode_on)
50 CustomModeList::iterator n = custom_mode_params.find(mode);
54 if (n == custom_mode_params.end())
55 custom_mode_params[mode] = strdup(parameter);
59 if (n != custom_mode_params.end())
62 custom_mode_params.erase(n);
67 bool Channel::IsModeSet(char mode)
69 return modes[mode-65];
72 std::string Channel::GetModeParameter(char mode)
79 return ConvToStr(this->limit);
81 CustomModeList::iterator n = custom_mode_params.find(mode);
82 if (n != custom_mode_params.end())
89 long Channel::GetUserCounter()
91 return (this->internal_userlist.size());
94 void Channel::AddUser(User* user)
96 internal_userlist[user] = user->nick;
99 unsigned long Channel::DelUser(User* user)
101 CUListIter a = internal_userlist.find(user);
103 if (a != internal_userlist.end())
105 internal_userlist.erase(a);
106 /* And tidy any others... */
108 DelHalfoppedUser(user);
112 return internal_userlist.size();
115 bool Channel::HasUser(User* user)
117 return (internal_userlist.find(user) != internal_userlist.end());
120 void Channel::AddOppedUser(User* user)
122 internal_op_userlist[user] = user->nick;
125 void Channel::DelOppedUser(User* user)
127 CUListIter a = internal_op_userlist.find(user);
128 if (a != internal_op_userlist.end())
130 internal_op_userlist.erase(a);
135 void Channel::AddHalfoppedUser(User* user)
137 internal_halfop_userlist[user] = user->nick;
140 void Channel::DelHalfoppedUser(User* user)
142 CUListIter a = internal_halfop_userlist.find(user);
144 if (a != internal_halfop_userlist.end())
146 internal_halfop_userlist.erase(a);
150 void Channel::AddVoicedUser(User* user)
152 internal_voice_userlist[user] = user->nick;
155 void Channel::DelVoicedUser(User* user)
157 CUListIter a = internal_voice_userlist.find(user);
159 if (a != internal_voice_userlist.end())
161 internal_voice_userlist.erase(a);
165 CUList* Channel::GetUsers()
167 return &internal_userlist;
170 CUList* Channel::GetOppedUsers()
172 return &internal_op_userlist;
175 CUList* Channel::GetHalfoppedUsers()
177 return &internal_halfop_userlist;
180 CUList* Channel::GetVoicedUsers()
182 return &internal_voice_userlist;
185 void Channel::SetDefaultModes()
187 irc::spacesepstream list(ServerInstance->Config->DefaultModes);
189 std::string parameter;
191 list.GetToken(modeseq);
193 for (std::string::iterator n = modeseq.begin(); n != modeseq.end(); ++n)
195 ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
198 if (mode->GetNumParams(true))
199 list.GetToken(parameter);
203 mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true);
209 * add a channel to a user, creating the record for it if needed and linking
210 * it to the user record
212 Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool override, const char* key, bool bursting, time_t TS)
223 * We don't restrict the number of channels that remote users or users that are override-joining may be in.
224 * We restrict local users to MaxChans channels.
225 * We restrict local operators to OperMaxChans channels.
226 * This is a lot more logical than how it was formerly. -- w00t
228 if (IS_LOCAL(user) && !override)
230 if (user->GetMaxChans())
232 if (user->chans.size() >= user->GetMaxChans())
234 user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick, cn);
242 if (user->chans.size() >= Instance->Config->OperMaxChans)
244 user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick, cn);
250 if (user->chans.size() >= Instance->Config->MaxChans)
252 user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick, cn);
259 strlcpy(cname, cn, CHANMAX);
260 Ptr = Instance->FindChan(cname);
265 * Fix: desync bug was here, don't set @ on remote users - spanningtree handles their permissions. bug #358. -- w00t
270 Instance->Logs->Log("CHANNEL",DEBUG,"*** BUG *** Channel::JoinUser called for REMOTE user '%s' on channel '%s' but no TS given!", user->nick, cn);
277 if (IS_LOCAL(user) && override == false)
280 FOREACH_RESULT_I(Instance,I_OnUserPreJoin,OnUserPreJoin(user,NULL,cname,privs));
285 Ptr = new Channel(Instance, cname, TS);
289 /* Already on the channel */
290 if (Ptr->HasUser(user))
294 * remote users are allowed us to bypass channel modes
295 * and bans (used by servers)
297 if (IS_LOCAL(user) && override == false)
300 FOREACH_RESULT_I(Instance,I_OnUserPreJoin,OnUserPreJoin(user,Ptr,cname,privs));
305 else if (MOD_RESULT == 0)
310 FOREACH_RESULT_I(Instance,I_OnCheckKey,OnCheckKey(user, Ptr, key ? key : ""));
313 if ((!key) || strcmp(key,Ptr->key))
315 user->WriteNumeric(475, "%s %s :Cannot join channel (Incorrect channel key)",user->nick, Ptr->name);
320 if (Ptr->IsModeSet('i'))
323 FOREACH_RESULT_I(Instance,I_OnCheckInvite,OnCheckInvite(user, Ptr));
326 if (!user->IsInvited(Ptr->name))
328 user->WriteNumeric(473, "%s %s :Cannot join channel (Invite only)",user->nick, Ptr->name);
332 user->RemoveInvite(Ptr->name);
337 FOREACH_RESULT_I(Instance,I_OnCheckLimit,OnCheckLimit(user, Ptr));
340 if (Ptr->GetUserCounter() >= Ptr->limit)
342 user->WriteNumeric(471, "%s %s :Cannot join channel (Channel is full)",user->nick, Ptr->name);
347 if (Ptr->bans.size())
349 if (Ptr->IsBanned(user))
351 user->WriteNumeric(474, "%s %s :Cannot join channel (You're banned)",user->nick, Ptr->name);
359 /* As spotted by jilles, dont bother to set this on remote users */
360 if (IS_LOCAL(user) && Ptr->GetUserCounter() == 1)
361 Ptr->SetDefaultModes();
363 return Channel::ForceChan(Instance, Ptr, user, privs, bursting);
366 Channel* Channel::ForceChan(InspIRCd* Instance, Channel* Ptr, User* user, const std::string &privs, bool bursting)
368 std::string nick = user->nick;
373 /* Just in case they have no permissions */
374 user->chans[Ptr] = 0;
376 for (std::string::const_iterator x = privs.begin(); x != privs.end(); x++)
378 const char status = *x;
379 ModeHandler* mh = Instance->Modes->FindPrefix(status);
382 /* Set, and make sure that the mode handler knows this mode was now set */
383 Ptr->SetPrefix(user, status, mh->GetPrefixRank(), true);
384 mh->OnModeChange(Instance->FakeClient, Instance->FakeClient, Ptr, nick, true);
386 switch (mh->GetPrefix())
388 /* These logic ops are SAFE IN THIS CASE because if the entry doesnt exist,
389 * addressing operator[] creates it. If they do exist, it points to it.
390 * At all other times where we dont want to create an item if it doesnt exist, we
391 * must stick to ::find().
394 user->chans[Ptr] |= UCMODE_OP;
397 user->chans[Ptr] |= UCMODE_HOP;
400 user->chans[Ptr] |= UCMODE_VOICE;
406 FOREACH_MOD_I(Instance,I_OnUserJoin,OnUserJoin(user, Ptr, bursting, silent));
409 Ptr->WriteChannel(user,"JOIN :%s",Ptr->name);
411 /* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */
412 std::string ms = Instance->Modes->ModeString(user, Ptr);
413 if ((Ptr->GetUserCounter() > 1) && (ms.length()))
414 Ptr->WriteAllExceptSender(user, true, 0, "MODE %s +%s", Ptr->name, ms.c_str());
416 /* Major improvement by Brain - we dont need to be calculating all this pointlessly for remote users */
421 user->WriteNumeric(332, "%s %s :%s", user->nick, Ptr->name, Ptr->topic);
422 user->WriteNumeric(333, "%s %s %s %lu", user->nick, Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset);
426 FOREACH_MOD_I(Instance,I_OnPostJoin,OnPostJoin(user, Ptr));
430 bool Channel::IsBanned(User* user)
434 FOREACH_RESULT(I_OnCheckBan,OnCheckBan(user, this));
437 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
438 for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
440 /* This allows CIDR ban matching
442 * Full masked host Full unmasked host IP with/without CIDR
444 if ((match(user->GetFullHost(),i->data)) || (match(user->GetFullRealHost(),i->data)) || (match(mask, i->data, true)))
453 bool Channel::IsExtBanned(User *user, char type)
455 // XXX. do we need events?
459 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
461 for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
463 if (i->data[0] != type || i->data[1] != ':')
466 // Iterate past char and : to get to the mask without doing a data copy(!)
468 maskptr++; // past the char
469 maskptr++; // past the :
471 /* This allows CIDR ban matching
473 * Full masked host Full unmasked host IP with/without CIDR
475 if ((match(user->GetFullHost(), maskptr)) || (match(user->GetFullRealHost(), maskptr)) || (match(mask, maskptr, true)))
485 * remove a channel from a users record, and return the number of users left.
486 * Therefore, if this function returns 0 the caller should delete the Channel.
488 long Channel::PartUser(User *user, const char* reason)
493 return this->GetUserCounter();
495 UCListIter i = user->chans.find(this);
496 if (i != user->chans.end())
498 FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason ? reason : "", silent));
501 this->WriteChannel(user, "PART %s%s%s", this->name, reason ? " :" : "", reason ? reason : "");
503 user->chans.erase(i);
504 this->RemoveAllPrefixes(user);
507 if (!this->DelUser(user)) /* if there are no users left on the channel... */
509 chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
510 /* kill the record */
511 if (iter != ServerInstance->chanlist->end())
514 FOREACH_RESULT_I(ServerInstance,I_OnChannelPreDelete, OnChannelPreDelete(this));
516 return 1; // delete halted by module
517 FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
518 ServerInstance->chanlist->erase(iter);
523 return this->GetUserCounter();
526 long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents, const char* servername)
530 if (!user || !reason)
531 return this->GetUserCounter();
535 if (!this->HasUser(user))
538 return this->GetUserCounter();
542 if (servername == NULL)
543 servername = ServerInstance->Config->ServerName;
547 FOREACH_MOD(I_OnUserKick,OnUserKick(NULL, user, this, reason, silent));
550 UCListIter i = user->chans.find(this);
551 if (i != user->chans.end())
554 this->WriteChannelWithServ(servername, "KICK %s %s :%s", this->name, user->nick, reason);
556 user->chans.erase(i);
557 this->RemoveAllPrefixes(user);
560 if (!this->DelUser(user))
562 chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
563 /* kill the record */
564 if (iter != ServerInstance->chanlist->end())
567 FOREACH_RESULT_I(ServerInstance,I_OnChannelPreDelete, OnChannelPreDelete(this));
569 return 1; // delete halted by module
570 FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
571 ServerInstance->chanlist->erase(iter);
576 return this->GetUserCounter();
579 long Channel::KickUser(User *src, User *user, const char* reason)
583 if (!src || !user || !reason)
584 return this->GetUserCounter();
588 if (!this->HasUser(user))
590 src->WriteNumeric(441, "%s %s %s :They are not on that channel",src->nick, user->nick, this->name);
591 return this->GetUserCounter();
593 if ((ServerInstance->ULine(user->server)) && (!ServerInstance->ULine(src->server)))
595 src->WriteNumeric(482, "%s %s :Only a u-line may kick a u-line from a channel.",src->nick, this->name);
596 return this->GetUserCounter();
600 if (!ServerInstance->ULine(src->server))
603 FOREACH_RESULT(I_OnUserPreKick,OnUserPreKick(src,user,this,reason));
605 return this->GetUserCounter();
607 /* Set to -1 by OnUserPreKick if explicit allow was set */
608 if (MOD_RESULT != -1)
610 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(src,user,this,AC_KICK));
611 if ((MOD_RESULT == ACR_DENY) && (!ServerInstance->ULine(src->server)))
612 return this->GetUserCounter();
614 if ((MOD_RESULT == ACR_DEFAULT) || (!ServerInstance->ULine(src->server)))
616 int them = this->GetStatus(src);
617 int us = this->GetStatus(user);
618 if ((them < STATUS_HOP) || (them < us))
620 src->WriteNumeric(482, "%s %s :You must be a channel %soperator",src->nick, this->name, them == STATUS_HOP ? "" : "half-");
621 return this->GetUserCounter();
627 FOREACH_MOD(I_OnUserKick,OnUserKick(src, user, this, reason, silent));
629 UCListIter i = user->chans.find(this);
630 if (i != user->chans.end())
632 /* zap it from the channel list of the user */
634 this->WriteChannel(src, "KICK %s %s :%s", this->name, user->nick, reason);
636 user->chans.erase(i);
637 this->RemoveAllPrefixes(user);
640 if (!this->DelUser(user))
641 /* if there are no users left on the channel */
643 chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
645 /* kill the record */
646 if (iter != ServerInstance->chanlist->end())
649 FOREACH_RESULT_I(ServerInstance,I_OnChannelPreDelete, OnChannelPreDelete(this));
651 return 1; // delete halted by module
652 FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
653 ServerInstance->chanlist->erase(iter);
658 return this->GetUserCounter();
661 void Channel::WriteChannel(User* user, const char* text, ...)
663 char textbuffer[MAXBUF];
669 va_start(argsPtr, text);
670 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
673 this->WriteChannel(user, std::string(textbuffer));
676 void Channel::WriteChannel(User* user, const std::string &text)
678 CUList *ulist = this->GetUsers();
684 snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
685 std::string out = tb;
687 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
689 if (IS_LOCAL(i->first))
690 i->first->Write(out);
694 void Channel::WriteChannelWithServ(const char* ServName, const char* text, ...)
696 char textbuffer[MAXBUF];
702 va_start(argsPtr, text);
703 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
706 this->WriteChannelWithServ(ServName, std::string(textbuffer));
709 void Channel::WriteChannelWithServ(const char* ServName, const std::string &text)
711 CUList *ulist = this->GetUsers();
714 snprintf(tb,MAXBUF,":%s %s",ServName ? ServName : ServerInstance->Config->ServerName, text.c_str());
715 std::string out = tb;
717 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
719 if (IS_LOCAL(i->first))
720 i->first->Write(out);
724 /* write formatted text from a source user to all users on a channel except
725 * for the sender (for privmsg etc) */
726 void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...)
728 char textbuffer[MAXBUF];
734 va_start(argsPtr, text);
735 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
738 this->WriteAllExceptSender(user, serversource, status, std::string(textbuffer));
741 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...)
743 char textbuffer[MAXBUF];
749 va_start(argsPtr, text);
750 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
753 this->WriteAllExcept(user, serversource, status, except_list, std::string(textbuffer));
756 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &text)
758 CUList *ulist = this->GetUsers();
761 snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
762 std::string out = tb;
764 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
766 if ((IS_LOCAL(i->first)) && (except_list.find(i->first) == except_list.end()))
768 /* User doesnt have the status we're after */
769 if (status && !strchr(this->GetAllPrefixChars(i->first), status))
773 i->first->WriteServ(text);
775 i->first->Write(out);
780 void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const std::string& text)
783 except_list[user] = user->nick;
784 this->WriteAllExcept(user, serversource, status, except_list, std::string(text));
788 * return a count of the users on a specific channel accounting for
789 * invisible users who won't increase the count. e.g. for /LIST
791 int Channel::CountInvisible()
794 CUList *ulist= this->GetUsers();
795 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
797 if (!(i->first->IsModeSet('i')))
804 char* Channel::ChanModes(bool showkey)
806 static char scratch[MAXBUF];
807 static char sparam[MAXBUF];
808 char* offset = scratch;
809 std::string extparam;
814 /* This was still iterating up to 190, Channel::modes is only 64 elements -- Om */
815 for(int n = 0; n < 64; n++)
824 extparam = (showkey ? this->key : "<key>");
827 extparam = ConvToStr(this->limit);
835 /* We know these have no parameters */
838 extparam = this->GetModeParameter(n + 65);
841 if (!extparam.empty())
843 charlcat(sparam,' ',MAXBUF);
844 strlcat(sparam,extparam.c_str(),MAXBUF);
849 /* Null terminate scratch */
851 strlcat(scratch,sparam,MAXBUF);
855 /* compile a userlist of a channel into a string, each nick seperated by
856 * spaces and op, voice etc status shown as @ and +, and send it to 'user'
858 void Channel::UserList(User *user, CUList *ulist)
863 bool call_modules = true;
868 FOREACH_RESULT(I_OnUserList,OnUserList(user, this, ulist));
870 call_modules = false;
872 if (MOD_RESULT != -1)
874 if ((this->IsModeSet('s')) && (!this->HasUser(user)))
876 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, this->name);
881 dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick, this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name);
884 char* ptr = list + dlen;
887 ulist = this->GetUsers();
889 /* Improvement by Brain - this doesnt change in value, so why was it inside
892 bool has_user = this->HasUser(user);
894 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
896 if ((!has_user) && (i->first->IsModeSet('i')))
899 * user is +i, and source not on the channel, does not show
905 if (i->first->Visibility && !i->first->Visibility->VisibleTo(user))
908 std::string prefixlist = this->GetPrefixChar(i->first);
909 std::string nick = i->first->nick;
913 FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->first, this, prefixlist, nick));
915 /* Nick was nuked, a module wants us to skip it */
922 if (curlen > (480-NICKMAX))
924 /* list overflowed into multiple numerics */
925 user->WriteServ(std::string(list));
927 /* reset our lengths */
928 dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick, this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name);
935 ptrlen = snprintf(ptr, MAXBUF, "%s%s ", prefixlist.c_str(), nick.c_str());
943 /* if whats left in the list isnt empty, send it */
946 user->WriteNumeric(353,std::string(list));
949 user->WriteNumeric(366, "%s %s :End of /NAMES list.", user->nick, this->name);
952 long Channel::GetMaxBans()
954 /* Return the cached value if there is one */
956 return this->maxbans;
958 /* If there isnt one, we have to do some O(n) hax to find it the first time. (ick) */
959 for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
961 if (match(this->name,n->first.c_str()))
963 this->maxbans = n->second;
968 /* Screw it, just return the default of 64 */
970 return this->maxbans;
973 void Channel::ResetMaxBans()
978 /* returns the status character for a given user on a channel, e.g. @ for op,
979 * % for halfop etc. If the user has several modes set, the highest mode
980 * the user has must be returned.
982 const char* Channel::GetPrefixChar(User *user)
984 static char pf[2] = {0, 0};
986 prefixlist::iterator n = prefixes.find(user);
987 if (n != prefixes.end())
989 if (n->second.size())
991 /* If the user has any prefixes, their highest prefix
992 * will always be at the head of the list, as the list is
993 * sorted in rank order highest first (see SetPrefix()
996 *pf = n->second.begin()->first;
1006 const char* Channel::GetAllPrefixChars(User* user)
1008 static char prefix[MAXBUF];
1012 prefixlist::iterator n = prefixes.find(user);
1013 if (n != prefixes.end())
1015 for (std::vector<prefixtype>::iterator x = n->second.begin(); x != n->second.end(); x++)
1017 prefix[ctr++] = x->first;
1026 unsigned int Channel::GetPrefixValue(User* user)
1028 prefixlist::iterator n = prefixes.find(user);
1029 if (n != prefixes.end())
1031 if (n->second.size())
1032 return n->second.begin()->second;
1037 int Channel::GetStatusFlags(User *user)
1039 UCListIter i = user->chans.find(this);
1040 if (i != user->chans.end())
1047 int Channel::GetStatus(User *user)
1049 if (ServerInstance->ULine(user->server))
1052 UCListIter i = user->chans.find(this);
1053 if (i != user->chans.end())
1055 if ((i->second & UCMODE_OP) > 0)
1059 if ((i->second & UCMODE_HOP) > 0)
1063 if ((i->second & UCMODE_VOICE) > 0)
1065 return STATUS_VOICE;
1067 return STATUS_NORMAL;
1069 return STATUS_NORMAL;
1072 void Channel::SetPrefix(User* user, char prefix, unsigned int prefix_value, bool adding)
1074 prefixlist::iterator n = prefixes.find(user);
1075 prefixtype pfx = std::make_pair(prefix,prefix_value);
1078 if (n != prefixes.end())
1080 if (std::find(n->second.begin(), n->second.end(), pfx) == n->second.end())
1082 n->second.push_back(pfx);
1083 /* We must keep prefixes in rank order, largest first.
1084 * This is for two reasons, firstly because x-chat *ass-u-me's* this
1085 * state, and secondly it turns out to be a benefit to us later.
1086 * See above in GetPrefix().
1088 std::sort(n->second.begin(), n->second.end(), ModeParser::PrefixComparison);
1095 prefixes.insert(std::make_pair<User*,pfxcontainer>(user, one));
1100 if (n != prefixes.end())
1102 pfxcontainer::iterator x = std::find(n->second.begin(), n->second.end(), pfx);
1103 if (x != n->second.end())
1109 void Channel::RemoveAllPrefixes(User* user)
1111 prefixlist::iterator n = prefixes.find(user);
1112 if (n != prefixes.end())