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)
89 /* 0: check status, 1: don't, -1: disallow change silently */
91 FIRST_MOD_RESULT(OnPreTopicChange, res, (u,this,ntopic));
93 if (res == MOD_RES_DENY)
95 if (res != MOD_RES_ALLOW)
97 if (!this->HasUser(u))
99 u->WriteNumeric(442, "%s %s :You're not on that channel!",u->nick.c_str(), this->name.c_str());
102 if ((this->IsModeSet('t')) && (this->GetPrefixValue(u) < HALFOP_VALUE))
104 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());
111 this->topic.assign(ntopic, 0, ServerInstance->Config->Limits.MaxTopic);
114 this->setby.assign(ServerInstance->Config->FullHostInTopic ? u->GetFullHost() : u->nick, 0, 128);
115 this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
119 this->setby.assign(ServerInstance->Config->ServerName);
120 this->WriteChannelWithServ(ServerInstance->Config->ServerName, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
123 this->topicset = ServerInstance->Time();
125 // XXX: this check for 'u' is probably pre-fake-user, and it fucking sucks anyway. we need to change this.
128 FOREACH_MOD(I_OnPostTopicChange,OnPostTopicChange(u, this, this->topic));
134 long Channel::GetUserCounter()
136 return userlist.size();
139 Membership* Channel::AddUser(User* user)
141 Membership* memb = new Membership(user, this);
142 userlist[user] = memb;
146 void Channel::DelUser(User* user)
148 UserMembIter a = userlist.find(user);
150 if (a != userlist.end())
157 if (userlist.empty())
160 FIRST_MOD_RESULT(OnChannelPreDelete, res, (this));
161 if (res == MOD_RES_DENY)
163 chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
164 /* kill the record */
165 if (iter != ServerInstance->chanlist->end())
167 FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
168 ServerInstance->chanlist->erase(iter);
170 ServerInstance->GlobalCulls.AddItem(this);
174 bool Channel::HasUser(User* user)
176 return (userlist.find(user) != userlist.end());
179 Membership* Channel::GetUser(User* user)
181 UserMembIter i = userlist.find(user);
182 if (i == userlist.end())
187 const UserMembList* Channel::GetUsers()
192 void Channel::SetDefaultModes()
194 ServerInstance->Logs->Log("CHANNELS", DEBUG, "SetDefaultModes %s",
195 ServerInstance->Config->DefaultModes.c_str());
196 irc::spacesepstream list(ServerInstance->Config->DefaultModes);
198 std::string parameter;
200 list.GetToken(modeseq);
202 for (std::string::iterator n = modeseq.begin(); n != modeseq.end(); ++n)
204 ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
207 if (mode->GetNumParams(true))
208 list.GetToken(parameter);
212 mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true);
218 * add a channel to a user, creating the record for it if needed and linking
219 * it to the user record
221 Channel* Channel::JoinUser(User *user, const char* cn, bool override, const char* key, bool bursting, time_t TS)
223 // Fix: unregistered users could be joined using /SAJOIN
224 if (!user || !cn || user->registered != REG_ALL)
232 * We don't restrict the number of channels that remote users or users that are override-joining may be in.
233 * We restrict local users to MaxChans channels.
234 * We restrict local operators to OperMaxChans channels.
235 * This is a lot more logical than how it was formerly. -- w00t
237 if (IS_LOCAL(user) && !override)
239 if (user->HasPrivPermission("channels/high-join-limit"))
241 if (user->chans.size() >= ServerInstance->Config->OperMaxChans)
243 user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
249 unsigned int maxchans = user->GetClass()->maxchans;
251 maxchans = ServerInstance->Config->MaxChans;
252 if (user->chans.size() >= maxchans)
254 user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
260 strlcpy(cname, cn, ServerInstance->Config->Limits.ChanMax);
261 Ptr = ServerInstance->FindChan(cname);
262 bool created_by_local = false;
267 * Fix: desync bug was here, don't set @ on remote users - spanningtree handles their permissions. bug #358. -- w00t
272 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);
277 created_by_local = true;
280 if (IS_LOCAL(user) && override == false)
282 ModResult MOD_RESULT;
283 FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, NULL, cname, privs, key ? key : ""));
284 if (MOD_RESULT == MOD_RES_DENY)
288 Ptr = new Channel(cname, TS);
292 /* Already on the channel */
293 if (Ptr->HasUser(user))
297 * remote users are allowed us to bypass channel modes
298 * and bans (used by servers)
300 if (IS_LOCAL(user) && override == false)
302 ModResult MOD_RESULT;
303 FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, Ptr, cname, privs, key ? key : ""));
304 if (MOD_RESULT == MOD_RES_DENY)
308 else if (MOD_RESULT == MOD_RES_PASSTHRU)
310 std::string ckey = Ptr->GetModeParameter('k');
311 bool invited = IS_LOCAL(user)->IsInvited(Ptr->name.c_str());
312 bool can_bypass = ServerInstance->Config->InvBypassModes && invited;
316 FIRST_MOD_RESULT(OnCheckKey, MOD_RESULT, (user, Ptr, key ? key : ""));
317 if (!MOD_RESULT.check((key && ckey == key) || can_bypass))
319 // If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled)
320 user->WriteNumeric(ERR_BADCHANNELKEY, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name.c_str());
325 if (Ptr->IsModeSet('i'))
327 FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, Ptr));
328 if (!MOD_RESULT.check(invited))
330 user->WriteNumeric(ERR_INVITEONLYCHAN, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name.c_str());
335 std::string limit = Ptr->GetModeParameter('l');
338 FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, Ptr));
339 if (!MOD_RESULT.check((Ptr->GetUserCounter() < atol(limit.c_str()) || can_bypass)))
341 user->WriteNumeric(ERR_CHANNELISFULL, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name.c_str());
346 if (Ptr->IsBanned(user) && !can_bypass)
348 user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str());
353 * If the user has invites for this channel, remove them now
354 * after a successful join so they don't build up.
358 IS_LOCAL(user)->RemoveInvite(Ptr->name.c_str());
364 if (created_by_local)
366 /* As spotted by jilles, dont bother to set this on remote users */
367 Ptr->SetDefaultModes();
370 return Channel::ForceChan(Ptr, user, privs, bursting, created_by_local);
373 Channel* Channel::ForceChan(Channel* Ptr, User* user, const std::string &privs, bool bursting, bool created)
375 std::string nick = user->nick;
377 Membership* memb = Ptr->AddUser(user);
378 user->chans.insert(Ptr);
380 for (std::string::const_iterator x = privs.begin(); x != privs.end(); x++)
382 const char status = *x;
383 ModeHandler* mh = ServerInstance->Modes->FindMode(status, MODETYPE_CHANNEL);
386 /* Set, and make sure that the mode handler knows this mode was now set */
387 Ptr->SetPrefix(user, mh->GetModeChar(), true);
388 mh->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, Ptr, nick, true);
393 FOREACH_MOD(I_OnUserJoin,OnUserJoin(memb, bursting, created, except_list));
395 Ptr->WriteAllExcept(user, false, 0, except_list, "JOIN :%s", Ptr->name.c_str());
397 /* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */
398 std::string ms = memb->modes;
399 for(unsigned int i=0; i < memb->modes.length(); i++)
400 ms.append(" ").append(user->nick);
401 if ((Ptr->GetUserCounter() > 1) && (ms.length()))
402 Ptr->WriteAllExceptSender(user, true, 0, "MODE %s +%s", Ptr->name.c_str(), ms.c_str());
404 /* Major improvement by Brain - we dont need to be calculating all this pointlessly for remote users */
409 user->WriteNumeric(RPL_TOPIC, "%s %s :%s", user->nick.c_str(), Ptr->name.c_str(), Ptr->topic.c_str());
410 user->WriteNumeric(RPL_TOPICTIME, "%s %s %s %lu", user->nick.c_str(), Ptr->name.c_str(), Ptr->setby.c_str(), (unsigned long)Ptr->topicset);
414 FOREACH_MOD(I_OnPostJoin,OnPostJoin(memb));
418 bool Channel::IsBanned(User* user)
421 FIRST_MOD_RESULT(OnCheckChannelBan, result, (user, this));
423 if (result != MOD_RES_PASSTHRU)
424 return (result == MOD_RES_DENY);
426 for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
428 if (CheckBan(user, i->data))
434 bool Channel::CheckBan(User* user, const std::string& mask)
437 FIRST_MOD_RESULT(OnCheckBan, result, (user, this, mask));
438 if (result != MOD_RES_PASSTHRU)
439 return (result == MOD_RES_DENY);
441 // extbans were handled above, if this is one it obviously didn't match
445 std::string::size_type at = mask.find('@');
446 if (at == std::string::npos)
449 char tomatch[MAXBUF];
450 snprintf(tomatch, MAXBUF, "%s!%s", user->nick.c_str(), user->ident.c_str());
451 std::string prefix = mask.substr(0, at);
452 if (InspIRCd::Match(tomatch, prefix, NULL))
454 std::string suffix = mask.substr(at + 1);
455 if (InspIRCd::Match(user->host, suffix, NULL) ||
456 InspIRCd::Match(user->dhost, suffix, NULL) ||
457 InspIRCd::MatchCIDR(user->GetIPString(), suffix, NULL))
463 ModResult Channel::GetExtBanStatus(User *user, char type)
466 FIRST_MOD_RESULT(OnExtBanCheck, rv, (user, this, type));
467 if (rv != MOD_RES_PASSTHRU)
469 for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
471 if (i->data[0] == type && i->data[1] == ':')
473 std::string val = i->data.substr(2);
474 if (CheckBan(user, val))
478 return MOD_RES_PASSTHRU;
482 * remove a channel from a users record, and return the number of users left.
483 * Therefore, if this function returns 0 the caller should delete the Channel.
485 void Channel::PartUser(User *user, std::string &reason)
490 Membership* memb = GetUser(user);
495 FOREACH_MOD(I_OnUserPart,OnUserPart(memb, reason, except_list));
497 WriteAllExcept(user, false, 0, except_list, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : " :", reason.c_str());
499 user->chans.erase(this);
500 this->RemoveAllPrefixes(user);
506 void Channel::KickUser(User *src, User *user, const char* reason)
508 if (!src || !user || !reason)
511 Membership* memb = GetUser(user);
516 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());
519 if ((ServerInstance->ULine(user->server)) && (!ServerInstance->ULine(src->server)))
521 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());
526 if (ServerInstance->ULine(src->server))
529 FIRST_MOD_RESULT(OnUserPreKick, res, (src,memb,reason));
531 if (res == MOD_RES_DENY)
534 if (res == MOD_RES_PASSTHRU)
536 int them = this->GetPrefixValue(src);
537 int us = this->GetPrefixValue(user);
538 if ((them < HALFOP_VALUE) || (them < us))
540 src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator",src->nick.c_str(), this->name.c_str(), them >= HALFOP_VALUE ? "" : "half-");
549 FOREACH_MOD(I_OnUserKick,OnUserKick(src, memb, reason, except_list));
551 WriteAllExcept(src, false, 0, except_list, "KICK %s %s :%s", name.c_str(), user->nick.c_str(), reason);
553 user->chans.erase(this);
554 this->RemoveAllPrefixes(user);
560 void Channel::WriteChannel(User* user, const char* text, ...)
562 char textbuffer[MAXBUF];
568 va_start(argsPtr, text);
569 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
572 this->WriteChannel(user, std::string(textbuffer));
575 void Channel::WriteChannel(User* user, const std::string &text)
582 snprintf(tb,MAXBUF,":%s %s", user->GetFullHost().c_str(), text.c_str());
583 std::string out = tb;
585 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
587 if (IS_LOCAL(i->first))
588 i->first->Write(out);
592 void Channel::WriteChannelWithServ(const std::string& ServName, const char* text, ...)
594 char textbuffer[MAXBUF];
600 va_start(argsPtr, text);
601 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
604 this->WriteChannelWithServ(ServName, std::string(textbuffer));
607 void Channel::WriteChannelWithServ(const std::string& ServName, const std::string &text)
611 snprintf(tb,MAXBUF,":%s %s", ServName.empty() ? ServerInstance->Config->ServerName.c_str() : ServName.c_str(), text.c_str());
612 std::string out = tb;
614 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
616 if (IS_LOCAL(i->first))
617 i->first->Write(out);
621 /* write formatted text from a source user to all users on a channel except
622 * for the sender (for privmsg etc) */
623 void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...)
625 char textbuffer[MAXBUF];
631 va_start(argsPtr, text);
632 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
635 this->WriteAllExceptSender(user, serversource, status, std::string(textbuffer));
638 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...)
640 char textbuffer[MAXBUF];
646 int offset = snprintf(textbuffer,MAXBUF,":%s ", user->GetFullHost().c_str());
648 va_start(argsPtr, text);
649 vsnprintf(textbuffer + offset, MAXBUF - offset, text, argsPtr);
652 this->RawWriteAllExcept(user, serversource, status, except_list, std::string(textbuffer));
655 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &text)
659 snprintf(tb,MAXBUF,":%s %s", serversource ? ServerInstance->Config->ServerName.c_str() : user->GetFullHost().c_str(), text.c_str());
660 std::string out = tb;
662 this->RawWriteAllExcept(user, serversource, status, except_list, std::string(tb));
665 void Channel::RawWriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &out)
667 unsigned int minrank = 0;
670 ModeHandler* mh = ServerInstance->Modes->FindPrefix(status);
672 minrank = mh->GetPrefixRank();
674 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
676 if (IS_LOCAL(i->first) && (except_list.find(i->first) == except_list.end()))
678 /* User doesn't have the status we're after */
679 if (minrank && i->second->getRank() < minrank)
682 i->first->Write(out);
687 void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const std::string& text)
690 except_list.insert(user);
691 this->WriteAllExcept(user, serversource, status, except_list, std::string(text));
695 * return a count of the users on a specific channel accounting for
696 * invisible users who won't increase the count. e.g. for /LIST
698 int Channel::CountInvisible()
701 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
703 if (!(i->first->IsModeSet('i')))
710 char* Channel::ChanModes(bool showkey)
712 static char scratch[MAXBUF];
713 static char sparam[MAXBUF];
714 char* offset = scratch;
715 std::string extparam;
720 /* This was still iterating up to 190, Channel::modes is only 64 elements -- Om */
721 for(int n = 0; n < 64; n++)
727 if (n == 'k' - 65 && !showkey)
733 extparam = this->GetModeParameter(n + 65);
735 if (!extparam.empty())
737 charlcat(sparam,' ',MAXBUF);
738 strlcat(sparam,extparam.c_str(),MAXBUF);
743 /* Null terminate scratch */
745 strlcat(scratch,sparam,MAXBUF);
749 /* compile a userlist of a channel into a string, each nick seperated by
750 * spaces and op, voice etc status shown as @ and +, and send it to 'user'
752 void Channel::UserList(User *user)
756 ModResult call_modules;
761 FIRST_MOD_RESULT(OnUserList, call_modules, (user, this));
763 if (call_modules != MOD_RES_ALLOW)
765 if ((this->IsModeSet('s')) && (!this->HasUser(user)))
767 user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), this->name.c_str());
772 dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name.c_str());
775 char* ptr = list + dlen;
777 /* Improvement by Brain - this doesnt change in value, so why was it inside
780 bool has_user = this->HasUser(user);
782 for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
784 if ((!has_user) && (i->first->IsModeSet('i')))
787 * user is +i, and source not on the channel, does not show
793 std::string prefixlist = this->GetPrefixChar(i->first);
794 std::string nick = i->first->nick;
796 if (call_modules != MOD_RES_DENY)
798 FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->second, prefixlist, nick));
800 /* Nick was nuked, a module wants us to skip it */
807 if (curlen + prefixlist.length() + nick.length() + 1 > 480)
809 /* list overflowed into multiple numerics */
810 user->WriteNumeric(RPL_NAMREPLY, std::string(list));
812 /* reset our lengths */
813 dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name.c_str());
820 ptrlen = snprintf(ptr, MAXBUF, "%s%s ", prefixlist.c_str(), nick.c_str());
828 /* if whats left in the list isnt empty, send it */
831 user->WriteNumeric(RPL_NAMREPLY, std::string(list));
834 user->WriteNumeric(RPL_ENDOFNAMES, "%s %s :End of /NAMES list.", user->nick.c_str(), this->name.c_str());
837 long Channel::GetMaxBans()
839 /* Return the cached value if there is one */
841 return this->maxbans;
843 /* If there isnt one, we have to do some O(n) hax to find it the first time. (ick) */
844 for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
846 if (InspIRCd::Match(this->name, n->first, NULL))
848 this->maxbans = n->second;
853 /* Screw it, just return the default of 64 */
855 return this->maxbans;
858 void Channel::ResetMaxBans()
863 /* returns the status character for a given user on a channel, e.g. @ for op,
864 * % for halfop etc. If the user has several modes set, the highest mode
865 * the user has must be returned.
867 const char* Channel::GetPrefixChar(User *user)
869 static char pf[2] = {0, 0};
871 unsigned int bestrank = 0;
873 UserMembIter m = userlist.find(user);
874 if (m != userlist.end())
876 for(unsigned int i=0; i < m->second->modes.length(); i++)
878 char mchar = m->second->modes[i];
879 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
880 if (mh && mh->GetPrefixRank() > bestrank && mh->GetPrefix())
882 bestrank = mh->GetPrefixRank();
883 pf[0] = mh->GetPrefix();
890 unsigned int Membership::getRank()
892 char mchar = modes.c_str()[0];
896 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
898 rv = mh->GetPrefixRank();
903 const char* Channel::GetAllPrefixChars(User* user)
905 static char prefix[64];
908 UserMembIter m = userlist.find(user);
909 if (m != userlist.end())
911 for(unsigned int i=0; i < m->second->modes.length(); i++)
913 char mchar = m->second->modes[i];
914 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
915 if (mh && mh->GetPrefix())
916 prefix[ctr++] = mh->GetPrefix();
924 unsigned int Channel::GetPrefixValue(User* user)
926 UserMembIter m = userlist.find(user);
927 if (m == userlist.end())
929 return m->second->getRank();
932 bool Channel::SetPrefix(User* user, char prefix, bool adding)
934 ModeHandler* delta_mh = ServerInstance->Modes->FindMode(prefix, MODETYPE_CHANNEL);
937 UserMembIter m = userlist.find(user);
938 if (m == userlist.end())
940 for(unsigned int i=0; i < m->second->modes.length(); i++)
942 char mchar = m->second->modes[i];
943 ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
944 if (mh && mh->GetPrefixRank() <= delta_mh->GetPrefixRank())
947 m->second->modes.substr(0,i) +
948 (adding ? std::string(1, prefix) : "") +
949 m->second->modes.substr(mchar == prefix ? i+1 : i);
950 return adding != (mchar == prefix);
954 m->second->modes += std::string(1, prefix);
958 void Channel::RemoveAllPrefixes(User* user)
960 UserMembIter m = userlist.find(user);
961 if (m != userlist.end())
963 m->second->modes.clear();