ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/FreeBSDAdmin/IRC/trout.cpp
Revision: 1295
Committed: 2010-04-09T05:48:07-07:00 (15 years, 2 months ago) by douglas
File size: 1305 byte(s)
Log Message:
Useful descriptions; some basic stats reporting in Smart ISON before recording more complex stats.

File Contents

# User Rev Content
1 douglas 1262 // Trout
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #include <main.h>
8     #include <Modules.h>
9     #include <Chan.h>
10     #include <Client.h>
11     #include <User.h>
12    
13     #include "foreach.hpp"
14    
15     class Trout : public CModule
16     {
17     public:
18     MODCONSTRUCTOR(Trout) {}
19     virtual ~Trout() {}
20    
21     virtual bool OnLoad(const CString &args, CString &message)
22     {
23     ::srandomdev();
24    
25     return true;
26     }
27    
28     virtual EModRet OnUserMsg(CString &target, CString &message)
29     {
30     if (message.Token(0).Equals("!trout"))
31     {
32     CString who(message.Token(1));
33    
34     if (who.empty())
35     if (GetUser()->IsChan(target))
36     {
37     typedef std::map<CString, CNick *> NickMap;
38    
39     VCString nicks;
40    
41 douglas 1266 _foreach (const NickMap, nick, GetUser()->FindChan(target)->GetNicks())
42 douglas 1262 nicks.push_back(nick->first);
43    
44     who = nicks[::random() % nicks.size()];
45     }
46     else
47     who = target;
48    
49     message = "\001ACTION slaps " + who + " around a bit with a large trout\001";
50    
51 douglas 1266 if (GetUser()->IsChan(target))
52     PutUser(":" + GetClient()->GetNickMask() + " PRIVMSG " + target + " :" + message);
53     else
54     PutUser(":" + target + " NOTICE " + GetClient()->GetNick() + " :\001ACTION \002" + GetClient()->GetNick() + "\017 slaps " + who + " around a bit with a large trout\001");
55 douglas 1262 }
56    
57     return CONTINUE;
58     }
59     };
60    
61 douglas 1295 MODULEDEFS(Trout, "Slap people around a bit with a large trout");

Properties

Name Value
svn:keywords Id