- else if (pcnt > 0)
- {
- for (int x = 0; x < pcnt; x++)
- {
- const char *nick = parameters[x];
- ServerInstance->Log(DEBUG,"WATCH iterate item '%s'", nick);
- if (!strcasecmp(nick,"C"))
- {
- // watch clear
- watchlist* wl;
- if (user->GetExt("watchlist", wl))
- {
- for (watchlist::iterator i = wl->begin(); i != wl->end(); i++)
- {
- watchentries::iterator x = whos_watching_me.find(i->first);
- if (x != whos_watching_me.end())
- {
- /* People are watching this user, am i one of them? */
- std::deque<userrec*>::iterator n = std::find(x->second.begin(), x->second.end(), user);
- if (n != x->second.end())
- /* I'm no longer watching you... */
- x->second.erase(n);
-
- if (!x->second.size())
- whos_watching_me.erase(user->nick);
- }
- }
-
- delete wl;
- user->Shrink("watchlist");
- }
- }
- else if (!strcasecmp(nick,"L"))
- {
- watchlist* wl;
- if (user->GetExt("watchlist", wl))
- {
- for (watchlist::iterator q = wl->begin(); q != wl->end(); q++)
- {
- if (!q->second.empty())
- user->WriteServ("604 %s %s %s :is online", user->nick, q->first.c_str(), q->second.c_str());
- else
- user->WriteServ("605 %s %s * * 0 :is offline", user->nick, q->first.c_str());
- }
- }
- user->WriteServ("607 %s :End of WATCH list",user->nick);
- }
- else if (!strcasecmp(nick,"S"))
- {
- watchlist* wl;
- int you_have = 0;
- int youre_on = 0;
- std::string list;
-
- if (user->GetExt("watchlist", wl))
- {
- for (watchlist::iterator q = wl->begin(); q != wl->end(); q++)
- list.append(q->first.c_str()).append(" ");
- you_have = wl->size();
- }
-
- watchentries::iterator x = whos_watching_me.find(user->nick);
- if (x != whos_watching_me.end())
- youre_on = x->second.size();
-
- user->WriteServ("603 %s :You have %d and are on %d WATCH entries", user->nick, you_have, youre_on);
- user->WriteServ("606 %s :%s",user->nick, list.c_str());
- user->WriteServ("607 %s :End of WATCH S",user->nick);
- }
- else if (nick[0] == '-')
- {
- nick++;
- remove_watch(user, nick);
- }
- else if (nick[0] == '+')
- {
- nick++;
- add_watch(user, nick);
- }
- }
- }
- /* So that spanningtree doesnt pass the WATCH commands to the network! */
- return CMD_FAILURE;