Skip to content
Browse files

route_replies: Use CModCommand

  • Loading branch information...
1 parent db7c47f commit 7969e73f5cab553dc520b43c02b3e35c389714d8 @kylef kylef committed Mar 21, 2012
Showing with 13 additions and 21 deletions.
  1. +13 −21 modules/route_replies.cpp
View
34 modules/route_replies.cpp
@@ -159,6 +159,10 @@ class CRouteRepliesMod : public CModule
{
m_pDoing = NULL;
m_pReplies = NULL;
+
+ AddHelpCommand();
+ AddCommand("Silent", static_cast<CModCommand::ModCmdFunc>(&CRouteRepliesMod::SilentCommand),
+ "[yes|no]");
}
virtual ~CRouteRepliesMod() {
@@ -308,7 +312,7 @@ class CRouteRepliesMod : public CModule
{
// The timer will be deleted after this by the event loop
- if (GetNV("silent_timeouts") != "yes") {
+ if (!GetNV("silent_timeouts").ToBool()) {
PutModule("This module hit a timeout which is possibly a bug.");
PutModule("To disable this message, do \"/msg " + GetModNick()
+ " silent yes\"");
@@ -389,27 +393,15 @@ class CRouteRepliesMod : public CModule
it->second.erase(it->second.begin());
}
- virtual void OnModCommand(const CString& sCommand) {
- const CString sCmd = sCommand.Token(0);
- const CString sArgs = sCommand.Token(1, true);
-
- if (sCmd.Equals("silent")) {
- if (sArgs.Equals("yes")) {
- SetNV("silent_timeouts", "yes");
- PutModule("Disabled timeout messages");
- } else if (sArgs.Equals("no")) {
- DelNV("silent_timeouts");
- PutModule("Enabled timeout messages");
- } else if (sArgs.empty()) {
- if (GetNV("silent_timeouts") == "yes")
- PutModule("Timeout messages are disabled");
- else
- PutModule("Timeout message are enabled");
- } else
- PutModule("Invalid argument");
- } else {
- PutModule("Available commands: silent [yes/no], silent");
+ void SilentCommand(const CString& sLine) {
+ const CString sValue = sLine.Token(1);
+
+ if (!sValue.empty()) {
+ SetNV("silent_timeouts", sValue);
}
+
+ CString sPrefix = GetNV("silent_timeouts").ToBool() ? "dis" : "en";
+ PutModule("Timeout messages are " + sPrefix + "abled.");
}
CClient *m_pDoing;

0 comments on commit 7969e73

Please sign in to comment.
Something went wrong with that request. Please try again.