1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 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::SetModeParam(char mode, std::string parameter)
41 CustomModeList::iterator n = custom_mode_params.find(mode);
42 // always erase, even if changing, so that the map gets the new value
43 if (n != custom_mode_params.end())
44 custom_mode_params.erase(n);
45 if (parameter.empty())
47 modes[mode-65] = false;
51 custom_mode_params[mode] = parameter;
52 modes[mode-65] = true;
56 std::string Channel::GetModeParameter(char mode)
58 CustomModeList::iterator n = custom_mode_params.find(mode);
59 if (n != custom_mode_params.end())
64 int Channel::SetTopic(User *u, std::string &ntopic, bool forceset)
71 /* 0: check status, 1: don't, -1: disallow change silently */
73 FIRST_MOD_RESULT(OnPreTopicChange, res, (u,this,ntopic));
75 if (res == MOD_RES_DENY)
77 if (res != MOD_RES_ALLOW)
79 if (!this->HasUser(u))
81 u->WriteNumeric(442, "%s %s :You're not on that channel!",u->nick.c_str(), this->name.c_str());
84 if ((this->IsModeSet('t')) && (this->GetPrefixValue(u) < HALFOP_VALUE))
86 u->WriteNumeric(482, "%s %s :You must be at least a half-operator to change the topic on this channel", u->nick.c_str(), this->name.c_str());
93 this->topic.assign(ntopic, 0, ServerInstance->Config->Limits.MaxTopic);
96 this->setby.assign(ServerInstance->Config->FullHostInTopic ? u->GetFullHost() : u->nick, 0, 128);
97 this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
101 this->setby.assign(ServerInstance->Config->ServerName);
102 this->WriteChannelWithServ(ServerInstance->Config->ServerName, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
105 this->topicset = ServerInstance->Time();
107 // XXX: this check for 'u' is probably pre-fake-user, and it fucking sucks anyway. we need to change this.
110 FOREACH_MOD(I_OnPostTopicChange,OnPostTopicChange(u, this, this->topic));
116 long Channel::GetUserCounter()
118 return userlist.size();
121 Membership* Channel::AddUser(User* user)
123 Membership* memb = new Membership(user, this);
124 userlist[user] = memb;
128 void Channel::DelUser(User* user)
130 UserMembIter a = userlist.find(user);
132 if (a != userlist.end())
139 if (userlist.empty())
142 FIRST_MOD_RESULT(OnChannelPreDelete, res, (this));
143 if (res == MOD_RES_DENY)
145 chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
146 /* kill the record */
147 if (iter != ServerInstance->chanlist->end())
149 FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
150 ServerInstance->chanlist->erase(iter);
152 ServerInstance->GlobalCulls.AddItem(this);
156 bool Channel::HasUser(User* user)
158 return (userlist.find(user) != userlist.end());
161 Membership* Channel::GetUser(User* user)
163 UserMembIter i = userlist.find(user);
164 if (i == userlist.end())
169 const UserMembList* Channel::GetUsers()
174 void Channel::SetDefaultModes()
176 ServerInstance->Logs->Log("CHANNELS", DEBUG, "SetDefaultModes %s",
177 ServerInstance->Config->DefaultModes.c_str());
178 irc::spacesepstream list(ServerInstance->Config->DefaultModes);
180 std::string parameter;
182 list.GetToken(modeseq);
184 for (std::string::iterator n = modeseq.begin(); n != modeseq.end(); ++n)
186 ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
189 if (mode->GetNumParams(true))
190 list.GetToken(parameter);
194 mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true);
200 * add a channel to a user, creating the record for it if needed and linking
201 * it to the user record
203 Channel* Channel::JoinUser(User *user, const char* cn, bool override, const char* key, bool bursting, time_t TS)
205 // Fix: unregistered users could be joined using /SAJOIN
206 if (!user || !cn || user->registered != REG_ALL)
214 * We don't restrict the number of channels that remote users or users that are override-joining may be in.
215 * We restrict local users to MaxChans channels.
216 * We restrict local operators to OperMaxChans channels.
217 * This is a lot more logical than how it was formerly. -- w00t
219 if (IS_LOCAL(user) && !override)
221 // Checking MyClass exists because we *may* get here with NULL, not 100% sure.
222 if (user->MyClass && user->MyClass->maxchans)
224 if (user->HasPrivPermission("channels/high-join-limit"))
226 if (user->chans.size() >= ServerInstance->Config->OperMaxChans)
228 user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
234 if (user->chans.size() >= user->MyClass->maxchans)
236 user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
243 strlcpy(cname, cn, ServerInstance->Config->Limits.ChanMax);
244 Ptr = ServerInstance->FindChan(cname);
245 bool created_by_local = false;
250 * Fix: desync bug was here, don't set @ on remote users - spanningtree handles their permissions. bug #358. -- w00t
255 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);
260 created_by_local = true;
263 if (IS_LOCAL(user) && override == false)
265 ModResult MOD_RESULT;
266 FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, NULL, cname, privs, key ? key : ""));
267 if (MOD_RESULT == MOD_RES_DENY)
271 Ptr = new Channel(cname, TS);
275 /* Already on the channel */
276 if (Ptr->HasUser(user))
280 * remote users are allowed us to bypass channel modes
281 * and bans (used by servers)
283 if (IS_LOCAL(user) && override == false)
285 ModResult MOD_RESULT;
286 FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, Ptr, cname, privs, key ? key : ""));
287 if (MOD_RESULT == MOD_RES_DENY)
291 else if (MOD_RESULT == MOD_RES_PASSTHRU)
293 std::string ckey = Ptr->GetModeParameter('k');
294 bool invited = user->IsInvited(Ptr->name.c_str());
295 bool can_bypass = ServerInstance->Config->InvBypassModes && invited;
299 FIRST_MOD_RESULT(OnCheckKey, MOD_RESULT, (user, Ptr, key ? key : ""));
300 if (!MOD_RESULT.check((key && ckey == key) || can_bypass))
302 // If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled)
303 user->WriteNumeric(ERR_BADCHANNELKEY, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name.c_str());
308 if (Ptr->IsModeSet('i'))
310 FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, Ptr));
311 if (!MOD_RESULT.check(invited))
313 user->WriteNumeric(ERR_INVITEONLYCHAN, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name.c_str());
318 std::string limit = Ptr->GetModeParameter('l');
321 FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, Ptr));
322 if (!MOD_RESULT.check((Ptr->GetUserCounter() < atol(limit.c_str()) || can_bypass)))
324 user->WriteNumeric(ERR_CHANNELISFULL, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name.c_str());
329 if (Ptr->IsBanned(user) && !can_bypass)
331 user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str());
336 * If the user has invites for this channel, remove them now
337 * after a successful join so they don't build up.
341 user->RemoveInvite(Ptr->name.c_str());
347 if (created_by_local)
349 /* As spotted by jilles, dont bother to set this on remote users */
350 Ptr->SetDefaultModes();
353 return Channel::ForceChan(Ptr, user, privs, bursting, created_by_local);
356 Channel* Channel::ForceChan(Channel* Ptr, User* user, const std::string &privs, bool bursting, bool created)
358 std::string nick = user->nick;
360 Membership* memb = Ptr->AddUser(user);
361 user->chans.insert(Ptr);
363 for (std::string::const_iterator x = privs.begin(); x != privs.end(); x++)
365 const char status = *x;
366 ModeHandler* mh = ServerInstance->Modes->FindMode(status, MODETYPE_CHANNEL);
369 /* Set, and make sure that the mode handler knows this mode was now set */
370 Ptr->SetPrefix(user, mh->GetModeChar(), true);
371 mh->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, Ptr, nick, true);
376 FOREACH_MOD(I_OnUserJoin,OnUserJoin(memb, bursting, created, except_list));
378 Ptr->WriteAllExcept(user, false, 0, except_list, "JOIN :%s", Ptr->name.c_str());
380 /* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */
381 std::string ms = ServerInstance->Modes->ModeString(user, Ptr);
382 if ((Ptr->GetUserCounter() > 1) && (ms.length()))
383 Ptr->WriteAllExceptSender(user, true, 0, "MODE %s +%s", Ptr->name.c_str(), ms.c_str());
385 /* Major improvement by Brain - we dont need to be calculating all this pointlessly for remote users */
390 user->WriteNumeric(RPL_TOPIC, "%s %s :%s", user->nick.c_str(), Ptr->name.c_str(), Ptr->topic.c_str());
391 user->WriteNumeric(RPL_TOPICTIME, "%s %s %s %lu", user->nick.c_str(), Ptr->name.c_str(), Ptr->setby.c_str(), (unsigned long)Ptr->topicset);
395 FOREACH_MOD(I_OnPostJoin,OnPostJoin(memb));
399 bool Channel::IsBanned(User* user)
402 FIRST_MOD_RESULT(OnCheckChannelBan, result, (user, this));
404 if (result != MOD_RES_PASSTHRU)
405 return (result == MOD_RES_DENY);
407 for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
409 if (CheckBan(user, i->data))
415 bool Channel::CheckBan(User* user, const std::string& mask)
418 FIRST_MOD_RESULT(OnCheckBan, result, (user, this, mask));
419 if (result != MOD_RES_PASSTHRU)
420 return (result == MOD_RES_DENY);
422 // extbans were handled above, if this is one it obviously didn't match
426 std::string::size_type at = mask.find('@');
427 if (at == std::string::npos)
430 char tomatch[MAXBUF];
431 snprintf(tomatch, MAXBUF, "%s!%s", user->nick.c_str(), user->ident.c_str());
432 std::string prefix = mask.substr(0, at);
433 if (InspIRCd::Match(tomatch, prefix, NULL))
435 std::string suffix = mask.substr(at + 1);
436 if (InspIRCd::Match(user->host, suffix, NULL) ||
437 InspIRCd::Match(user->dhost, suffix, NULL) ||
438 InspIRCd::MatchCIDR(user->GetIPString(), suffix, NULL))
444 ModResult Channel::GetExtBanStatus(User *user, char type)
447 FIRST_MOD_RESULT(OnExtBanCheck, rv, (user, this, type));
448 if (rv != MOD_RES_PASSTHRU)
450 for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
452 if (i->data[0] == type && i->data[1] == ':')
454 std::string val = i->data.substr(2);
455 if (CheckBan(user, val))
459 return MOD_RES_PASSTHRU;
463 * remove a channel from a users record, and return the number of users left.
464 * Therefore, if this function returns 0 the caller should delete the Channel.
466 void Channel::PartUser(User *user, std::string &reason)
471 Membership* memb = GetUser(user);
476 FOREACH_MOD(I_OnUserPart,OnUserPart(memb, reason, except_list));
478 WriteAllExcept(user, false, 0, except_list, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : " :", reason.c_str());
480 user->chans.erase(this);
481 this->RemoveAllPrefixes(user);
487 void Channel::ServerKickUser(User* user, const char* reason, const std::string& servername)
489 if (servername.empty() || !ServerInstance->Config->HideWhoisServer.empty())
490 ServerInstance->FakeClient->server = ServerInstance->Config->ServerName;
492 ServerInstance->FakeClient->server = servername;
494 KickUser(ServerInstance->FakeClient, user, reason);
497 void Channel::KickUser(User *src, User *user, const char* reason)
499 if (!src || !user || !reason)
502 Membership* memb = GetUser(user);
507 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());
510 if ((ServerInstance->ULine(user->server)) && (!ServerInstance->ULine(src->server)))
512 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());
517 if (ServerInstance->ULine(src->server))
520 FIRST_MOD_RESULT(OnUserPreKick, res, (src,memb,reason));
522 if (res == MOD_RES_DENY)
525 if (res == MOD_RES_PASSTHRU)
527 int them = this->GetPrefixValue(src);
528 int us = this->GetPrefixValue(user);
529 if ((them < HALFOP_VALUE) || (them < us))
531 src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator",src->nick.c_str(), this->name.c_str(), them >= HALFOP_VALUE ? "" : "half-");
540 FOREACH_MOD(I_OnUserKick,OnUserKick(src, memb, reason, except_list));
542 WriteAllExcept(src, false, 0, except_list, "KICK %s %s :%s", name.c_str(), user->nick.c_str(), reason);
544 user->chans.erase(this);
545 this->RemoveAllPrefixes(user);
551 void Channel::WriteChannel(User* user, const char* text, ...)
553 char textbuffer[MAXBUF];
559 va_start(argsPtr, text);
560 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
563 this->WriteChannel(user, std::string(textbuffer));
566 void Channel::WriteChannel(User* user, const std::string &text)
573 snprintf(tb,MAXBUF,":%s %s", user->GetFullHost().c_str(), text.c_str());
574 std::string out = tb;
576 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
578 if (IS_LOCAL(i->first))
579 i->first->Write(out);
583 void Channel::WriteChannelWithServ(const std::string& ServName, const char* text, ...)
585 char textbuffer[MAXBUF];
591 va_start(argsPtr, text);
592 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
595 this->WriteChannelWithServ(ServName, std::string(textbuffer));
598 void Channel::WriteChannelWithServ(const std::string& ServName, const std::string &text)
602 snprintf(tb,MAXBUF,":%s %s", ServName.empty() ? ServerInstance->Config->ServerName.c_str() : ServName.c_str(), text.c_str());
603 std::string out = tb;
605 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
607 if (IS_LOCAL(i->first))
608 i->first->Write(out);
612 /* write formatted text from a source user to all users on a channel except
613 * for the sender (for privmsg etc) */
614 void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...)
616 char textbuffer[MAXBUF];
622 va_start(argsPtr, text);
623 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
626 this->WriteAllExceptSender(user, serversource, status, std::string(textbuffer));
629 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...)
631 char textbuffer[MAXBUF];
637 int offset = snprintf(textbuffer,MAXBUF,":%s ", user->GetFullHost().c_str());
639 va_start(argsPtr, text);
640 vsnprintf(textbuffer + offset, MAXBUF - offset, text, argsPtr);
643 this->RawWriteAllExcept(user, serversource, status, except_list, std::string(textbuffer));
646 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &text)
650 snprintf(tb,MAXBUF,":%s %s", serversource ? ServerInstance->Config->ServerName.c_str() : user->GetFullHost().c_str(), text.c_str());
651 std::string out = tb;
653 this->RawWriteAllExcept(user, serversource, status, except_list, std::string(tb));
656 void Channel::RawWriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &out)
661 ModeHandler* mh = ServerInstance->Modes->FindPrefix(status);
663 statmode = mh->GetModeChar();
665 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
667 if ((IS_LOCAL(i->first)) && (except_list.find(i->first) == except_list.end()))
669 /* User doesnt have the status we're after */
670 if (statmode && !i->second->hasMode(statmode))
673 i->first->Write(out);
678 void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const std::string& text)
681 except_list.insert(user);
682 this->WriteAllExcept(user, serversource, status, except_list, std::string(text));
686 * return a count of the users on a specific channel accounting for
687 * invisible users who won't increase the count. e.g. for /LIST
689 int Channel::CountInvisible()
692 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
694 if (!(i->first->IsModeSet('i')))
701 char* Channel::ChanModes(bool showkey)
703 static char scratch[MAXBUF];
704 static char sparam[MAXBUF];
705 char* offset = scratch;
706 std::string extparam;
711 /* This was still iterating up to 190, Channel::modes is only 64 elements -- Om */
712 for(int n = 0; n < 64; n++)
721 // Unfortunately this must be special-cased, as we definitely don't want to always display key.
724 extparam = this->GetModeParameter('k');
737 /* We know these have no parameters */
740 extparam = this->GetModeParameter(n + 65);
743 if (!extparam.empty())
745 charlcat(sparam,' ',MAXBUF);
746 strlcat(sparam,extparam.c_str(),MAXBUF);
751 /* Null terminate scratch */
753 strlcat(scratch,sparam,MAXBUF);
757 /* compile a userlist of a channel into a string, each nick seperated by
758 * spaces and op, voice etc status shown as @ and +, and send it to 'user'
760 void Channel::UserList(User *user)
764 ModResult call_modules;
769 FIRST_MOD_RESULT(OnUserList, call_modules, (user, this));
771 if (call_modules != MOD_RES_ALLOW)
773 if ((this->IsModeSet('s')) && (!this->HasUser(user)))
775 user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), this->name.c_str());
780 dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name.c_str());
783 char* ptr = list + dlen;
785 /* Improvement by Brain - this doesnt change in value, so why was it inside
788 bool has_user = this->HasUser(user);
790 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
792 if ((!has_user) && (i->first->IsModeSet('i')))
795 * user is +i, and source not on the channel, does not show
801 std::string prefixlist = this->GetPrefixChar(i->first);
802 std::string nick = i->first->nick;
804 if (call_modules != MOD_RES_DENY)
806 FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->second, prefixlist, nick));
808 /* Nick was nuked, a module wants us to skip it */
815 if (curlen + prefixlist.length() + nick.length() + 1 > 480)
817 /* list overflowed into multiple numerics */
818 user->WriteNumeric(RPL_NAMREPLY, std::string(list));
820 /* reset our lengths */
821 dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name.c_str());
828 ptrlen = snprintf(ptr, MAXBUF, "%s%s ", prefixlist.c_str(), nick.c_str());
836 /* if whats left in the list isnt empty, send it */
839 user->WriteNumeric(RPL_NAMREPLY, std::string(list));
842 user->WriteNumeric(RPL_ENDOFNAMES, "%s %s :End of /NAMES list.", user->nick.c_str(), this->name.c_str());
845 long Channel::GetMaxBans()
847 /* Return the cached value if there is one */
849 return this->maxbans;
851 /* If there isnt one, we have to do some O(n) hax to find it the first time. (ick) */
852 for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
854 if (InspIRCd::Match(this->name, n->first, NULL))
856 this->maxbans = n->second;
861 /* Screw it, just return the default of 64 */
863 return this->maxbans;
866 void Channel::ResetMaxBans()
871 /* returns the status character for a given user on a channel, e.g. @ for op,
872 * % for halfop etc. If the user has several modes set, the highest mode
873 * the user has must be returned.
875 const char* Channel::GetPrefixChar(User *user)
877 static char pf[2] = {0, 0};
879 unsigned int bestrank = 0;
881 UserMembIter m = userlist.find(user);
882 if (m != userlist.end())
884 for(unsigned int i=0; i < m->second->modes.length(); i++)
886 char mchar = m->second->modes[i];
887 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
888 if (mh && mh->GetPrefixRank() > bestrank && mh->GetPrefix())
890 bestrank = mh->GetPrefixRank();
891 pf[0] = mh->GetPrefix();
898 unsigned int Membership::getRank()
900 char mchar = modes.c_str()[0];
904 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
906 rv = mh->GetPrefixRank();
911 const char* Channel::GetAllPrefixChars(User* user)
913 static char prefix[64];
916 UserMembIter m = userlist.find(user);
917 if (m != userlist.end())
919 for(unsigned int i=0; i < m->second->modes.length(); i++)
921 char mchar = m->second->modes[i];
922 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
923 if (mh && mh->GetPrefix())
924 prefix[ctr++] = mh->GetPrefix();
932 unsigned int Channel::GetPrefixValue(User* user)
934 UserMembIter m = userlist.find(user);
935 if (m == userlist.end())
937 return m->second->getRank();
940 void Channel::SetPrefix(User* user, char prefix, bool adding)
942 ModeHandler* delta_mh = ServerInstance->Modes->FindMode(prefix, MODETYPE_CHANNEL);
945 UserMembIter m = userlist.find(user);
946 if (m == userlist.end())
948 for(unsigned int i=0; i < m->second->modes.length(); i++)
950 char mchar = m->second->modes[i];
951 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
952 if (mh && mh->GetPrefixRank() <= delta_mh->GetPrefixRank())
955 m->second->modes.substr(0,i) +
956 (adding ? std::string(1, prefix) : "") +
957 m->second->modes.substr(mchar == prefix ? i+1 : i);
962 m->second->modes += std::string(1, prefix);
965 void Channel::RemoveAllPrefixes(User* user)
967 UserMembIter m = userlist.find(user);
968 if (m != userlist.end())
970 m->second->modes.clear();