From 4a2b9ebcf38d6c0a2860b966421b3af125438488 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 25 May 2010 00:57:25 -0500 Subject: Renamed all of source files from .c to .cpp --- src/core/bs_say.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/core/bs_say.cpp (limited to 'src/core/bs_say.cpp') diff --git a/src/core/bs_say.cpp b/src/core/bs_say.cpp new file mode 100644 index 000000000..8dfc55115 --- /dev/null +++ b/src/core/bs_say.cpp @@ -0,0 +1,94 @@ +/* BotServ core functions + * + * (C) 2003-2010 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * + */ +/*************************************************************************/ + +#include "module.h" + +class CommandBSSay : public Command +{ + public: + CommandBSSay() : Command("SAY", 2, 2) + { + } + + CommandReturn Execute(User *u, const std::vector ¶ms) + { + ChannelInfo *ci; + + const char *chan = params[0].c_str(); + const char *text = params[1].c_str(); + + ci = cs_findchan(chan); + + if (!check_access(u, ci, CA_SAY)) + { + notice_lang(Config.s_BotServ, u, ACCESS_DENIED); + return MOD_CONT; + } + + if (!ci->bi) + { + notice_help(Config.s_BotServ, u, BOT_NOT_ASSIGNED); + return MOD_CONT; + } + + if (!ci->c || ci->c->users.size() < Config.BSMinUsers) + { + notice_lang(Config.s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name.c_str()); + return MOD_CONT; + } + + if (text[0] == '\001') + { + this->OnSyntaxError(u, ""); + return MOD_CONT; + } + + ircdproto->SendPrivmsg(ci->bi, ci->name.c_str(), "%s", text); + ci->bi->lastmsg = time(NULL); + if (Config.LogBot && Config.LogChannel && LogChan && !debug && findchan(Config.LogChannel)) + ircdproto->SendPrivmsg(ci->bi, Config.LogChannel, "SAY %s %s %s", u->nick.c_str(), ci->name.c_str(), text); + return MOD_CONT; + } + + bool OnHelp(User *u, const ci::string &subcommand) + { + notice_help(Config.s_BotServ, u, BOT_HELP_SAY); + return true; + } + + void OnSyntaxError(User *u, const ci::string &subcommand) + { + syntax_error(Config.s_BotServ, u, "SAY", BOT_SAY_SYNTAX); + } +}; + +class BSSay : public Module +{ + public: + BSSay(const std::string &modname, const std::string &creator) : Module(modname, creator) + { + this->SetAuthor("Anope"); + this->SetVersion(VERSION_STRING); + this->SetType(CORE); + this->AddCommand(BotServ, new CommandBSSay()); + + ModuleManager::Attach(I_OnBotServHelp, this); + } + void OnBotServHelp(User *u) + { + notice_lang(Config.s_BotServ, u, BOT_HELP_CMD_SAY); + } +}; + +MODULE_INIT(BSSay) -- cgit From 6cd88494662c5c4af2da891926dcc82367596cb9 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 30 May 2010 17:21:44 -0400 Subject: Moved the *Serv help functions to Command, will come in use later with subcommands --- src/core/bs_say.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/core/bs_say.cpp') diff --git a/src/core/bs_say.cpp b/src/core/bs_say.cpp index 8dfc55115..a388a1ec9 100644 --- a/src/core/bs_say.cpp +++ b/src/core/bs_say.cpp @@ -71,6 +71,11 @@ class CommandBSSay : public Command { syntax_error(Config.s_BotServ, u, "SAY", BOT_SAY_SYNTAX); } + + void OnServHelp(User *u) + { + notice_lang(Config.s_BotServ, u, BOT_HELP_CMD_SAY); + } }; class BSSay : public Module @@ -82,12 +87,6 @@ class BSSay : public Module this->SetVersion(VERSION_STRING); this->SetType(CORE); this->AddCommand(BotServ, new CommandBSSay()); - - ModuleManager::Attach(I_OnBotServHelp, this); - } - void OnBotServHelp(User *u) - { - notice_lang(Config.s_BotServ, u, BOT_HELP_CMD_SAY); } }; -- cgit