diff options
| author | 2010-10-28 17:31:32 -0400 | |
|---|---|---|
| committer | 2010-10-28 17:31:32 -0400 | |
| commit | 452d3232481c2f9249b7467680ca10d1e56a5d31 (patch) | |
| tree | b206f32edec3914f7f23f548705d277f94d160e0 /src/modules/m_opflags.cpp | |
| parent | Add m_ghost and update serverbots config (diff) | |
Allow listing of all opflags on a channel
Diffstat (limited to 'src/modules/m_opflags.cpp')
| -rw-r--r-- | src/modules/m_opflags.cpp | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/modules/m_opflags.cpp b/src/modules/m_opflags.cpp index 27f43b3c4..e5af67836 100644 --- a/src/modules/m_opflags.cpp +++ b/src/modules/m_opflags.cpp @@ -93,21 +93,54 @@ class FlagCmd : public Command OpFlagProviderImpl prov; unsigned int conflevel; unsigned int usermax; - FlagCmd(Module* parent) : Command(parent, "OPFLAGS", 2), prov(parent) + FlagCmd(Module* parent) : Command(parent, "OPFLAGS", 1), prov(parent) { - syntax = "<channel> <nick> {+-=}[<flags>]"; + syntax = "<channel> [nick] {+-=}[<flags>]"; TRANSLATE4(TR_TEXT, TR_NICK, TR_TEXT, TR_END); } CmdResult Handle(const std::vector<std::string> ¶meters, User *src) { Channel* chan = ServerInstance->FindChan(parameters[0]); - User* user = ServerInstance->FindNick(parameters[1]); + if (!chan) + { + src->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", + src->nick.c_str(), parameters[0].c_str()); + return CMD_FAILURE; + } + + if (parameters.size() == 1) + { + std::map<std::string, std::vector<std::string> > opflags; + std::string tmp; + for(UserMembCIter i = chan->GetUsers()->begin(); i != chan->GetUsers()->end(); ++i) + { + irc::commasepstream flags(prov.GetFlags(i->second)); + while(flags.GetToken(tmp)) + opflags[tmp].push_back(i->first->nick); + } + for(std::map<std::string, std::vector<std::string> >::iterator i = opflags.begin(); i != opflags.end(); ++i) + { + for(std::vector<std::string>::iterator j = i->second.begin(); j != i->second.end(); ++j) + { + if(j == i->second.begin()) + tmp.clear(); + else + tmp.push_back(','); + tmp.append(*j); + } + src->WriteNumeric(926, "%s %s %s %s :Opflag is held by these users", src->nick.c_str(), + chan->name.c_str(), i->first.c_str(), tmp.c_str()); + } + src->WriteNumeric(925, "%s %s :End of channel opflags", src->nick.c_str(), chan->name.c_str()); + return CMD_SUCCESS; + } - if (!user || !chan) + User* user = ServerInstance->FindNick(parameters[1]); + if (!user) { src->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", - src->nick.c_str(), parameters[chan ? 1 : 0].c_str()); + src->nick.c_str(), parameters[1].c_str()); return CMD_FAILURE; } |
