// 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 (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"; PutUser(":" + GetClient()->GetNickMask() + " PRIVMSG " + target + " :" + message); } return CONTINUE; } }; MODULEDEFS(Trout, "Trout");