/*-------------------------------------------------------------- * Name: cs_fantasy_lmgtfy * Author: LEthaLity 'Lee' * Date: 22nd February 2014 * Version: 0.1 * -------------------------------------------------------------- * This module adds the command LMGTFY, aka LetMeGoogleThatForYou * Provide it with a search-term and the bot in the channel will * return a http://lmgtfy.com url. * * Usage: !lmgtfy anope services * -------------------------------------------------------------- * Configuration: chanserv.conf module { name = "cs_fantasy_lmgtfy" } command { service = "ChanServ"; name = "LMGTFY"; command = "chanserv/lmgtfy"; } fantasy { name = "LMGTFY"; command = "chanserv/lmgtfy"; prepend_channel = true; } * -------------------------------------------------------------- */ #include "module.h" class CommandCSLmgtfy : public Command { public: CommandCSLmgtfy(Module *creator) : Command(creator, "chanserv/lmgtfy", 1, 2) { this->AllowUnregistered(true); this->SetDesc(_("Display a lmgtfy link for a given string.")); this->SetSyntax(_("\037query\037")); } void Execute(CommandSource &source, const std::vector ¶ms) anope_override { const Anope::string &chan = params[0]; ChannelInfo *ci = ChannelInfo::Find(params[0]); Anope::string query = params[1]; if (ci == NULL) { source.Reply(CHAN_X_NOT_IN_USE, chan.c_str()); return; } else if (!query.empty()) { std::replace(query.begin(), query.end(), ' ', '+'); const Anope::string url = "http://lmgtfy.com/?q="; const char *qstring = (url + query).c_str(); IRCD->SendPrivmsg(*ci->bi, ci->name.c_str(), qstring); ci->bi->lastmsg = Anope::CurTime; } else { this->SendSyntax(source); return; } } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override { this->SendSyntax(source); source.Reply(" "); source.Reply(_("Returns a LetMeGoogleThatForYou link.")); return true; } }; class CSLmgtfy : public Module { CommandCSLmgtfy commandcslmgtfy; public: CSLmgtfy(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, THIRD), commandcslmgtfy(this) { this->SetAuthor("LEthaLity"); this->SetVersion("0.2"); } }; MODULE_INIT(CSLmgtfy)