22 data[
"ci"] << this->
chan;
23 data[
"word"] << this->
word;
33 typedef std::vector<BadWordImpl *>
list;
47 this->badwords->push_back(bw);
56 if (this->badwords->empty() || index >= this->badwords->size())
66 return this->badwords->size();
71 if (this->badwords->empty() || index >= this->badwords->size())
74 FOREACH_MOD(OnBadWordDel, (ci, (*this->badwords)[index]));
76 delete this->badwords->at(index);
81 while (!this->badwords->empty())
82 delete this->badwords->back();
87 if (this->badwords->empty())
110 BadWordsImpl::list::iterator it = std::find(badwords->
badwords->begin(), badwords->
badwords->end(),
this);
111 if (it != badwords->
badwords->end())
122 data[
"word"] >> sword;
158 this->
override =
true;
165 source.
Reply(
_(
"No matching entries on %s bad words list."), ci->
name.
c_str());
166 else if (deleted == 1)
167 source.
Reply(
_(
"Deleted 1 entry from %s bad words list."), ci->
name.
c_str());
169 source.
Reply(
_(
"Deleted %d entries from %s bad words list."), deleted, ci->
name.
c_str());
193 list.AddColumn(
_(
"Number")).AddColumn(
_(
"Word")).AddColumn(
_(
"Type"));
195 if (!bw || !bw->GetBadWordCount())
202 class BadwordsListCallback :
public NumberList
219 entry[
"Word"] = b->
word;
224 nl_list(list, bw, word);
229 for (
unsigned i = 0, end = bw->GetBadWordCount(); i < end; ++i)
231 const BadWord *b = bw->GetBadWord(i);
238 entry[
"Word"] = b->
word;
240 list.AddEntry(entry);
245 source.
Reply(
_(
"No matching entries on %s bad words list."), ci->
name.
c_str());
248 std::vector<Anope::string> replies;
249 list.Process(replies);
253 for (
unsigned i = 0; i < replies.size(); ++i)
254 source.
Reply(replies[i]);
256 source.
Reply(
_(
"End of bad words list."));
262 size_t pos = word.
rfind(
' ');
279 realword = word.
substr(0, pos);
282 unsigned badwordsmax =
Config->GetModule(this->
module)->Get<
unsigned>(
"badwordsmax");
285 source.
Reply(
_(
"Sorry, you can only have %d bad words entries on a channel."), badwordsmax);
289 bool casesensitive =
Config->GetModule(this->
module)->Get<
bool>(
"casesensitive");
363 source.
Reply(
_(
"Bad words list is now empty."));
369 this->
SetDesc(
_(
"Maintains the bad words list"));
370 this->
SetSyntax(
_(
"\037channel\037 ADD \037word\037 [\037SINGLE\037 | \037START\037 | \037END\037]"));
371 this->
SetSyntax(
_(
"\037channel\037 DEL {\037word\037 | \037entry-num\037 | \037list\037}"));
372 this->
SetSyntax(
_(
"\037channel\037 LIST [\037mask\037 | \037list\037]"));
379 const Anope::string &word = params.size() > 2 ? params[2] :
"";
382 if (!need_args && word.
empty())
395 if (!source.AccessFor(ci).HasPriv(
"BADWORDS") && (!need_args || !source.HasPriv(
"botserv/administration")))
403 source.Reply(
_(
"Sorry, channel bad words list modification is temporarily disabled."));
408 return this->
DoAdd(source, ci, word);
410 return this->
DoDelete(source, ci, word);
412 return this->
DoList(source, ci, word);
414 return this->
DoClear(source, ci);
423 source.Reply(
_(
"Maintains the \002bad words list\002 for a channel. The bad\n"
424 "words list determines which words are to be kicked\n"
425 "when the bad words kicker is enabled. For more information,\n"
426 "type \002%s%s HELP KICK %s\002.\n"
428 "The \002ADD\002 command adds the given word to the\n"
429 "bad words list. If SINGLE is specified, a kick will be\n"
430 "done only if a user says the entire word. If START is\n"
431 "specified, a kick will be done if a user says a word\n"
432 "that starts with \037word\037. If END is specified, a kick\n"
433 "will be done if a user says a word that ends with\n"
434 "\037word\037. If you don't specify anything, a kick will\n"
435 "be issued every time \037word\037 is said by a user.\n"
436 " \n"),
Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), source.command.c_str());
437 source.Reply(
_(
"The \002DEL\002 command removes the given word from the\n"
438 "bad words list. If a list of entry numbers is given, those\n"
439 "entries are deleted. (See the example for LIST below.)\n"
441 "The \002LIST\002 command displays the bad words list. If\n"
442 "a wildcard mask is given, only those entries matching the\n"
443 "mask are displayed. If a list of entry numbers is given,\n"
444 "only those entries are shown; for example:\n"
445 " \002#channel LIST 2-5,7-9\002\n"
446 " Lists bad words entries numbered 2 through 5 and\n"
449 "The \002CLEAR\002 command clears all entries of the\n"
463 commandbsbadwords(this), badwords(this,
"badwords"), badword_type(
"BadWord",
BadWordImpl::Unserialize)
void Check() anope_override
bool equals_cs(const char *_str) const
BSBadwords(const Anope::string &modname, const Anope::string &creator)
Serialize::Reference< ChannelInfo > ci
void EraseBadWord(unsigned index) anope_override
void ClearBadWords() anope_override
void DoList(CommandSource &source, ChannelInfo *ci, const Anope::string &word)
void Serialize(Serialize::Data &data) const anope_override
static Serializable * Unserialize(Serializable *obj, Serialize::Data &)
Serialize::Checker< list > badwords
CommandBSBadwords commandbsbadwords
size_type rfind(const string &_str, size_type pos=npos) const
void SetDesc(const Anope::string &d)
bool equals_ci(const char *_str) const
BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list)
T * Require(const Anope::string &name)
CommandBSBadwords(Module *creator)
bool HasPriv(const Anope::string &priv) const
std::vector< BadWordImpl * > list
#define FOREACH_MOD(ename, args)
static ChannelInfo * Find(const Anope::string &name)
string substr(size_type pos=0, size_type n=npos) const
void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &word)
BadWordsImpl(Extensible *obj)
void Shrink(const Anope::string &name)
void HandleNumber(unsigned Number) anope_override
CoreExport bool Match(const string &str, const string &mask, bool case_sensitive=false, bool use_regex=false)
virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand)
static const size_type npos
void Reply(const char *message,...)
bool HasPriv(const Anope::string &cmd)
BadWord * GetBadWord(unsigned index) const anope_override
unsigned GetBadWordCount() const anope_override
Serialize::Type badword_type
ExtensibleItem< BadWordsImpl > badwords
virtual BadWord * GetBadWord(unsigned index) const =0
void SetSyntax(const Anope::string &s)
BadWord * AddBadWord(const Anope::string &word, BadWordType type) anope_override
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
size_type find_first_not_of(const string &_str, size_type pos=0) const
Anope::string stringify(const T &x)
virtual unsigned GetBadWordCount() const =0
#define CHAN_X_NOT_REGISTERED
AccessGroup AccessFor(ChannelInfo *ci)
virtual void ClearBadWords()=0
virtual void EraseBadWord(unsigned index)=0
T anope_dynamic_static_cast(O ptr)
void Execute(CommandSource &source, const std::vector< Anope::string > ¶ms) anope_override
void SendSyntax(CommandSource &)
virtual BadWord * AddBadWord(const Anope::string &word, BadWordType type)=0
void DoClear(CommandSource &source, ChannelInfo *ci)
const char * c_str() const
T * GetExt(const Anope::string &name) const
void DoDelete(CommandSource &source, ChannelInfo *ci, const Anope::string &word)
Type(const Anope::string &n, unserialize_func f, Module *owner=NULL)