- if ((modechar == 'g') && (type == MT_CHANNEL))
- {
- chanrec* chan = (chanrec*)target;
-
- for (unsigned int j = 0; j < params[0].length(); j++)
- params[0][j] = tolower(params[0][j]);
-
- std::string param = params[0];
-
- if (mode_on)
- {
- SpamList* spamlist = (SpamList*)chan->GetExt("spam_list");
- if (!spamlist)
- {
- spamlist = new SpamList;
- chan->Extend("spam_list",(char*)spamlist);
- }
- if (spamlist->size() < (unsigned)MaxEntries)
- {
- for (SpamList::iterator i = spamlist->begin(); i != spamlist->end(); i++)
- {
- if (*i == params[0])
- {
- WriteServ(user->fd,"937 %s %s :The word %s is already on the spamfilter list",user->nick, chan->name,params[0].c_str());
- return -1;
- }
- }
- spamlist->push_back(params[0]);
- return 1;
- }
- WriteServ(user->fd,"939 %s %s :Channel spamfilter list is full",user->nick, chan->name);
- return -1;
- }
- else
- {
- SpamList* spamlist = (SpamList*)chan->GetExt("spam_list");
- if (spamlist)
- {
- for (SpamList::iterator i = spamlist->begin(); i != spamlist->end(); i++)
- {
- if (*i == params[0])
- {
- spamlist->erase(i);
- return 1;
- }
- }
- }
- WriteServ(user->fd,"938 %s %s :No such spamfilter word is set",user->nick, chan->name);
- return -1;
- }
- return -1;
- }
- return 0;
- }
-
- virtual void OnSendList(userrec* user, chanrec* channel, char mode)
- {
- if (mode == 'g')
- {
- SpamList* spamlist = (SpamList*)channel->GetExt("spam_list");
- if (spamlist)
- {
- for (SpamList::iterator i = spamlist->begin(); i != spamlist->end(); i++)
- {
- WriteServ(user->fd,"941 %s %s %s",user->nick, channel->name,i->c_str());
- }
- }
- WriteServ(user->fd,"940 %s %s :End of channel spamfilter list",user->nick, channel->name);
- }