#include "users.h"
#include "channels.h"
#include "modules.h"
-#include "helperfuncs.h"
+
#include "hashcomp.h"
#include "inspircd.h"
class cmd_watch : public command_t
{
public:
- cmd_watch (InspIRCd* Instance) : command_t(Instance,"WATCH",0,0)
+ cmd_watch (InspIRCd* Instance) : command_t(Instance,"WATCH",0,0)
{
this->source = "m_watch.so";
syntax = "[C|L|S]|[+|-<nick>]";
}
- void Handle (const char** parameters, int pcnt, userrec *user)
+ CmdResult Handle (const char** parameters, int pcnt, userrec *user)
{
if (!pcnt)
{
{
// removing an item from the list
nick++;
+ if (!ServerInstance->IsNick(nick))
+ {
+ user->WriteServ("942 %s %s :Invalid nickname",user->nick,nick);
+ return CMD_FAILURE;
+ }
irc::string n1 = nick;
for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
{
}
else
{
- user->WriteServ("602 %s %s * * 0 :stopped watching",user->nick,b->target.c_str());
+ user->WriteServ("602 %s %s * * 0 :stopped watching",user->nick,b->target.c_str());
}
if (n1 == n2)
{
else if (nick[0] == '+')
{
nick++;
+ if (!ServerInstance->IsNick(nick))
+ {
+ user->WriteServ("942 %s %s :Invalid nickname",user->nick,nick);
+ return CMD_FAILURE;
+ }
irc::string n1 = nick;
bool exists = false;
for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
}
}
}
- return;
+ /* So that spanningtree doesnt pass the WATCH commands to the network! */
+ return CMD_FAILURE;
}
};
void Implements(char* List)
{
- List[I_OnUserQuit] = List[I_OnGlobalConnect] = List[I_OnUserPostNick] = List[I_On005Numeric] = 1;
+ List[I_OnUserQuit] = List[I_OnPostConnect] = List[I_OnUserPostNick] = List[I_On005Numeric] = 1;
}
virtual void OnUserQuit(userrec* user, const std::string &reason)
}
}
- virtual void OnGlobalConnect(userrec* user)
+ virtual void OnPostConnect(userrec* user)
{
irc::string n2 = user->nick;
ServerInstance->Log(DEBUG,"*** WATCH: On global connect: user %s",user->nick);