summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/cmd_list.cpp16
-rw-r--r--src/commands/cmd_names.cpp12
-rw-r--r--src/commands/cmd_privmsg.cpp9
-rw-r--r--src/commands/cmd_topic.cpp17
-rw-r--r--src/commands/cmd_who.cpp36
-rw-r--r--src/commands/cmd_whois.cpp15
6 files changed, 78 insertions, 27 deletions
diff --git a/src/commands/cmd_list.cpp b/src/commands/cmd_list.cpp
index 2f417bc04..5962e2547 100644
--- a/src/commands/cmd_list.cpp
+++ b/src/commands/cmd_list.cpp
@@ -27,10 +27,20 @@
*/
class CommandList : public Command
{
+ ChanModeReference secretmode;
+ ChanModeReference privatemode;
+
public:
/** Constructor for list.
*/
- CommandList ( Module* parent) : Command(parent,"LIST", 0, 0) { Penalty = 5; }
+ CommandList(Module* parent)
+ : Command(parent,"LIST", 0, 0)
+ , secretmode(creator, "secret")
+ , privatemode(creator, "private")
+ {
+ Penalty = 5;
+ }
+
/** Handle command.
* @param parameters The parameters to the comamnd
* @param pcnt The number of parameters passed to teh command
@@ -82,14 +92,14 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User
// if the channel is not private/secret, OR the user is on the channel anyway
bool n = (i->second->HasUser(user) || user->HasPrivPermission("channels/auspex"));
- if (!n && i->second->IsModeSet('p'))
+ if (!n && i->second->IsModeSet(privatemode))
{
/* Channel is +p and user is outside/not privileged */
user->WriteNumeric(322, "%s * %ld :",user->nick.c_str(), users);
}
else
{
- if (n || !i->second->IsModeSet('s'))
+ if (n || !i->second->IsModeSet(secretmode))
{
/* User is in the channel/privileged, channel is not +s */
user->WriteNumeric(322, "%s %s %ld :[+%s] %s",user->nick.c_str(),i->second->name.c_str(),users,i->second->ChanModes(n),i->second->topic.c_str());
diff --git a/src/commands/cmd_names.cpp b/src/commands/cmd_names.cpp
index 1f0de91f1..c74d18c23 100644
--- a/src/commands/cmd_names.cpp
+++ b/src/commands/cmd_names.cpp
@@ -27,10 +27,18 @@
*/
class CommandNames : public Command
{
+ ChanModeReference secretmode;
+
public:
/** Constructor for names.
*/
- CommandNames ( Module* parent) : Command(parent,"NAMES",0,0) { syntax = "{<channel>{,<channel>}}"; }
+ CommandNames(Module* parent)
+ : Command(parent, "NAMES", 0, 0)
+ , secretmode(parent, "secret")
+ {
+ syntax = "{<channel>{,<channel>}}";
+ }
+
/** Handle command.
* @param parameters The parameters to the comamnd
* @param pcnt The number of parameters passed to teh command
@@ -58,7 +66,7 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User
c = ServerInstance->FindChan(parameters[0]);
if (c)
{
- if ((c->IsModeSet('s')) && (!c->HasUser(user)))
+ if ((c->IsModeSet(secretmode)) && (!c->HasUser(user)))
{
user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp
index 7de3bf924..5519be2fa 100644
--- a/src/commands/cmd_privmsg.cpp
+++ b/src/commands/cmd_privmsg.cpp
@@ -28,9 +28,14 @@ namespace
class MessageCommandBase : public Command
{
+ ChanModeReference moderatedmode;
+ ChanModeReference noextmsgmode;
+
public:
MessageCommandBase(Module* parent, MessageType mt)
: Command(parent, MessageTypeString[mt], 2, 2)
+ , moderatedmode(parent, "moderated")
+ , noextmsgmode(parent, "noextmsg")
{
syntax = "<target>{,<target>} <message>";
}
@@ -105,13 +110,13 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
{
if (localuser && chan->GetPrefixValue(user) < VOICE_VALUE)
{
- if (chan->IsModeSet('n') && !chan->HasUser(user))
+ if (chan->IsModeSet(noextmsgmode) && !chan->HasUser(user))
{
user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick.c_str(), chan->name.c_str());
return CMD_FAILURE;
}
- if (chan->IsModeSet('m'))
+ if (chan->IsModeSet(moderatedmode))
{
user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name.c_str());
return CMD_FAILURE;
diff --git a/src/commands/cmd_topic.cpp b/src/commands/cmd_topic.cpp
index e8c555e90..997fb6a91 100644
--- a/src/commands/cmd_topic.cpp
+++ b/src/commands/cmd_topic.cpp
@@ -29,10 +29,21 @@
*/
class CommandTopic : public Command
{
+ ChanModeReference secretmode;
+ ChanModeReference topiclockmode;
+
public:
/** Constructor for topic.
*/
- CommandTopic ( Module* parent) : Command(parent,"TOPIC",1, 2) { syntax = "<channel> [<topic>]"; Penalty = 2; }
+ CommandTopic(Module* parent)
+ : Command(parent, "TOPIC", 1, 2)
+ , secretmode(parent, "secret")
+ , topiclockmode(parent, "topiclock")
+ {
+ syntax = "<channel> [<topic>]";
+ Penalty = 2;
+ }
+
/** Handle command.
* @param parameters The parameters to the comamnd
* @param pcnt The number of parameters passed to teh command
@@ -59,7 +70,7 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User
{
if (c)
{
- if ((c->IsModeSet('s')) && (!c->HasUser(user)))
+ if ((c->IsModeSet(secretmode)) && (!c->HasUser(user)))
{
user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
@@ -98,7 +109,7 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User
user->WriteNumeric(442, "%s %s :You're not on that channel!", user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
}
- if (c->IsModeSet('t') && !ServerInstance->OnCheckExemption(user, c, "topiclock").check(c->GetPrefixValue(user) >= HALFOP_VALUE))
+ if (c->IsModeSet(topiclockmode) && !ServerInstance->OnCheckExemption(user, c, "topiclock").check(c->GetPrefixValue(user) >= HALFOP_VALUE))
{
user->WriteNumeric(482, "%s %s :You do not have access to change the topic on this channel", user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp
index 82d541a2a..a78f03793 100644
--- a/src/commands/cmd_who.cpp
+++ b/src/commands/cmd_who.cpp
@@ -39,13 +39,32 @@ class CommandWho : public Command
bool opt_local;
bool opt_far;
bool opt_time;
+ ChanModeReference secretmode;
+ ChanModeReference privatemode;
+
+ Channel* get_first_visible_channel(User *u)
+ {
+ UCListIter i = u->chans.begin();
+ while (i != u->chans.end())
+ {
+ Channel* c = *i++;
+ if (!c->IsModeSet(secretmode))
+ return c;
+ }
+ return NULL;
+ }
public:
/** Constructor for who.
*/
- CommandWho ( Module* parent) : Command(parent,"WHO", 1) {
+ CommandWho(Module* parent)
+ : Command(parent, "WHO", 1)
+ , secretmode(parent, "secret")
+ , privatemode(parent, "private")
+ {
syntax = "<server>|<nickname>|<channel>|<realname>|<host>|0 [ohurmMiaplf]";
}
+
void SendWhoLine(User* user, const std::vector<std::string>& parms, const std::string &initial, Channel* ch, User* u, std::vector<std::string> &whoresults);
/** Handle command.
* @param parameters The parameters to the comamnd
@@ -57,19 +76,6 @@ class CommandWho : public Command
bool whomatch(User* cuser, User* user, const char* matchtext);
};
-
-static Channel* get_first_visible_channel(User *u)
-{
- UCListIter i = u->chans.begin();
- while (i != u->chans.end())
- {
- Channel* c = *i++;
- if (!c->IsModeSet('s'))
- return c;
- }
- return NULL;
-}
-
bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext)
{
bool match = false;
@@ -180,7 +186,7 @@ bool CommandWho::CanView(Channel* chan, User* user)
if (user->HasPrivPermission("users/auspex"))
return true;
/* Cant see inside a +s or a +p channel unless we are a member (see above) */
- else if (!chan->IsModeSet('s') && !chan->IsModeSet('p'))
+ else if (!chan->IsModeSet(secretmode) && !chan->IsModeSet(privatemode))
return true;
return false;
diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp
index 9048184f6..4893c1251 100644
--- a/src/commands/cmd_whois.cpp
+++ b/src/commands/cmd_whois.cpp
@@ -28,6 +28,9 @@
*/
class CommandWhois : public SplitCommand
{
+ ChanModeReference secretmode;
+ ChanModeReference privatemode;
+
void SplitChanList(User* source, User* dest, const std::string& cl);
void DoWhois(User* user, User* dest, unsigned long signon, unsigned long idle);
std::string ChannelList(User* source, User* dest, bool spy);
@@ -35,7 +38,15 @@ class CommandWhois : public SplitCommand
public:
/** Constructor for whois.
*/
- CommandWhois ( Module* parent) : SplitCommand(parent,"WHOIS", 1) { Penalty = 2; syntax = "<nick>{,<nick>}"; }
+ CommandWhois(Module* parent)
+ : SplitCommand(parent, "WHOIS", 1)
+ , secretmode(parent, "secret")
+ , privatemode(parent, "private")
+ {
+ Penalty = 2;
+ syntax = "<nick>{,<nick>}";
+ }
+
/** Handle command.
* @param parameters The parameters to the comamnd
* @param pcnt The number of parameters passed to teh command
@@ -56,7 +67,7 @@ std::string CommandWhois::ChannelList(User* source, User* dest, bool spy)
/* If the target is the sender, neither +p nor +s is set, or
* the channel contains the user, it is not a spy channel
*/
- if (spy != (source == dest || !(c->IsModeSet('p') || c->IsModeSet('s')) || c->HasUser(source)))
+ if (spy != (source == dest || !(c->IsModeSet(privatemode) || c->IsModeSet(secretmode)) || c->HasUser(source)))
list.append(c->GetPrefixChar(dest)).append(c->name).append(" ");
}