// Trout // // Douglas Thrift // // $Id$ #include #include #include #include #include #include "foreach.hpp" class Trout : public CModule { public: MODCONSTRUCTOR(Trout) {} virtual ~Trout() {} virtual bool OnLoad(const CString &args, CString &message) { ::srandomdev(); return true; } virtual EModRet OnUserMsg(CString &target, CString &message) { if (message.Token(0).Equals("!trout")) { CString who(message.Token(1)); if (who.empty()) if (GetUser()->IsChan(target)) { typedef std::map NickMap; VCString nicks; _foreach (const NickMap, nick, GetUser()->FindChan(target)->GetNicks()) nicks.push_back(nick->first); who = nicks[::random() % nicks.size()]; } else who = target; message = "\001ACTION slaps " + who + " around a bit with a large trout\001"; if (GetUser()->IsChan(target)) PutUser(":" + GetClient()->GetNickMask() + " PRIVMSG " + target + " :" + message); else PutUser(":" + target + " NOTICE " + GetClient()->GetNick() + " :\001ACTION \002" + GetClient()->GetNick() + "\017 slaps " + who + " around a bit with a large trout\001"); } return CONTINUE; } }; MODULEDEFS(Trout, "Slap people around a bit with a large trout");