summaryrefslogtreecommitdiff
path: root/src/modules/m_watch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/m_watch.cpp')
-rw-r--r--src/modules/m_watch.cpp46
1 files changed, 17 insertions, 29 deletions
diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp
index ec38edc31..94f53c164 100644
--- a/src/modules/m_watch.cpp
+++ b/src/modules/m_watch.cpp
@@ -22,8 +22,6 @@
#include "inspircd.h"
-/* $ModDesc: Provides support for the /WATCH command */
-
/*
* Okay, it's nice that this was documented and all, but I at least understood very little
@@ -92,12 +90,7 @@
* of users using WATCH.
*/
-/*
- * Before you start screaming, this definition is only used here, so moving it to a header is pointless.
- * Yes, it's horrid. Blame cl for being different. -- w00t
- */
-
-typedef nspace::hash_map<irc::string, std::deque<User*>, irc::hash> watchentries;
+typedef TR1NS::unordered_map<irc::string, std::deque<User*>, irc::hash> watchentries;
typedef std::map<irc::string, std::string> watchlist;
/* Who's watching each nickname.
@@ -112,7 +105,7 @@ class CommandSVSWatch : public Command
CommandSVSWatch(Module* Creator) : Command(Creator,"SVSWATCH", 2)
{
syntax = "<target> [C|L|S]|[+|-<nick>]";
- TRANSLATE3(TR_NICK, TR_TEXT, TR_END); /* we watch for a nick. not a UID. */
+ TRANSLATE2(TR_NICK, TR_TEXT); /* we watch for a nick. not a UID. */
}
CmdResult Handle (const std::vector<std::string> &parameters, User *user)
@@ -151,7 +144,7 @@ class CommandWatch : public Command
CmdResult remove_watch(User* user, const char* nick)
{
// removing an item from the list
- if (!ServerInstance->IsNick(nick, ServerInstance->Config->Limits.NickMax))
+ if (!ServerInstance->IsNick(nick))
{
user->WriteNumeric(942, "%s %s :Invalid nickname", user->nick.c_str(), nick);
return CMD_FAILURE;
@@ -201,7 +194,7 @@ class CommandWatch : public Command
CmdResult add_watch(User* user, const char* nick)
{
- if (!ServerInstance->IsNick(nick, ServerInstance->Config->Limits.NickMax))
+ if (!ServerInstance->IsNick(nick))
{
user->WriteNumeric(942, "%s %s :Invalid nickname",user->nick.c_str(),nick);
return CMD_FAILURE;
@@ -242,7 +235,7 @@ class CommandWatch : public Command
{
(*wl)[nick] = std::string(target->ident).append(" ").append(target->dhost).append(" ").append(ConvToStr(target->age));
user->WriteNumeric(604, "%s %s %s :is online",user->nick.c_str(), nick, (*wl)[nick].c_str());
- if (IS_AWAY(target))
+ if (target->IsAway())
{
user->WriteNumeric(609, "%s %s %s %s %lu :is away", user->nick.c_str(), target->nick.c_str(), target->ident.c_str(), target->dhost.c_str(), (unsigned long) target->awaytime);
}
@@ -260,7 +253,6 @@ class CommandWatch : public Command
CommandWatch(Module* parent, unsigned int &maxwatch) : Command(parent,"WATCH", 0), MAX_WATCH(maxwatch), ext("watchlist", parent)
{
syntax = "[C|L|S]|[+|-<nick>]";
- TRANSLATE2(TR_TEXT, TR_END); /* we watch for a nick. not a UID. */
}
CmdResult Handle (const std::vector<std::string> &parameters, User *user)
@@ -320,7 +312,7 @@ class CommandWatch : public Command
{
user->WriteNumeric(604, "%s %s %s :is online", user->nick.c_str(), q->first.c_str(), q->second.c_str());
User *targ = ServerInstance->FindNick(q->first.c_str());
- if (IS_AWAY(targ))
+ if (targ->IsAway())
{
user->WriteNumeric(609, "%s %s %s %s %lu :is away", user->nick.c_str(), targ->nick.c_str(), targ->ident.c_str(), targ->dhost.c_str(), (unsigned long) targ->awaytime);
}
@@ -382,24 +374,22 @@ class Modulewatch : public Module
whos_watching_me = new watchentries();
}
- void init()
+ void init() CXX11_OVERRIDE
{
OnRehash(NULL);
ServerInstance->Modules->AddService(cmdw);
ServerInstance->Modules->AddService(sw);
ServerInstance->Modules->AddService(cmdw.ext);
- Implementation eventlist[] = { I_OnRehash, I_OnGarbageCollect, I_OnUserQuit, I_OnPostConnect, I_OnUserPostNick, I_On005Numeric, I_OnSetAway };
- ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- virtual void OnRehash(User* user)
+ void OnRehash(User* user) CXX11_OVERRIDE
{
maxwatch = ServerInstance->Config->ConfValue("watch")->getInt("maxentries", 32);
if (!maxwatch)
maxwatch = 32;
}
- virtual ModResult OnSetAway(User *user, const std::string &awaymsg)
+ ModResult OnSetAway(User *user, const std::string &awaymsg) CXX11_OVERRIDE
{
std::string numeric;
int inum;
@@ -427,7 +417,7 @@ class Modulewatch : public Module
return MOD_RES_PASSTHRU;
}
- virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
+ void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) CXX11_OVERRIDE
{
watchentries::iterator x = whos_watching_me->find(user->nick.c_str());
if (x != whos_watching_me->end())
@@ -467,7 +457,7 @@ class Modulewatch : public Module
}
}
- virtual void OnGarbageCollect()
+ void OnGarbageCollect()
{
watchentries* old_watch = whos_watching_me;
whos_watching_me = new watchentries();
@@ -478,7 +468,7 @@ class Modulewatch : public Module
delete old_watch;
}
- virtual void OnPostConnect(User* user)
+ void OnPostConnect(User* user) CXX11_OVERRIDE
{
watchentries::iterator x = whos_watching_me->find(user->nick.c_str());
if (x != whos_watching_me->end())
@@ -495,7 +485,7 @@ class Modulewatch : public Module
}
}
- virtual void OnUserPostNick(User* user, const std::string &oldnick)
+ void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE
{
watchentries::iterator new_offline = whos_watching_me->find(oldnick.c_str());
watchentries::iterator new_online = whos_watching_me->find(user->nick.c_str());
@@ -527,22 +517,20 @@ class Modulewatch : public Module
}
}
- virtual void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
{
- // we don't really have a limit...
- output = output + " WATCH=" + ConvToStr(maxwatch);
+ tokens["WATCH"] = ConvToStr(maxwatch);
}
- virtual ~Modulewatch()
+ ~Modulewatch()
{
delete whos_watching_me;
}
- virtual Version GetVersion()
+ Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides support for the /WATCH command", VF_OPTCOMMON | VF_VENDOR);
}
};
MODULE_INIT(Modulewatch)
-