- const char *nick = parameters[x].c_str();
- 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 i2 = whos_watching_me->find(i->first);
- if (i2 != whos_watching_me->end())
- {
- /* People are watching this user, am i one of them? */
- std::deque<User*>::iterator n = std::find(i2->second.begin(), i2->second.end(), user);
- if (n != i2->second.end())
- /* I'm no longer watching you... */
- i2->second.erase(n);
-
- if (i2->second.empty())
- /* nobody else is, either. */
- whos_watching_me->erase(i2);
- }
- }
-
- 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->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))
- {
- 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);
- }
- }
- else
- user->WriteNumeric(605, "%s %s * * 0 :is offline", user->nick.c_str(), q->first.c_str());
- }
- }
- user->WriteNumeric(607, "%s :End of WATCH list",user->nick.c_str());
- }
- 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 i2 = whos_watching_me->find(user->nick.c_str());
- if (i2 != whos_watching_me->end())
- youre_on = i2->second.size();
-
- user->WriteNumeric(603, "%s :You have %d and are on %d WATCH entries", user->nick.c_str(), you_have, youre_on);
- user->WriteNumeric(606, "%s :%s",user->nick.c_str(), list.c_str());
- user->WriteNumeric(607, "%s :End of WATCH S",user->nick.c_str());
- }
- else if (nick[0] == '-')
- {
- nick++;
- remove_watch(user, nick);
- }
- else if (nick[0] == '+')
- {
- nick++;
- add_watch(user, nick);
- }