[go: up one dir, main page]

Menu

[c90421]: / mod.stats / stats.h  Maximize  Restore  History

Download this file

208 lines (171 with data), 5.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/**
* stats.h
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: stats.h,v 1.18 2004/06/04 20:17:24 jeekay Exp $
*/
#ifndef __STATS_H
#define __STATS_H "$Id: stats.h,v 1.18 2004/06/04 20:17:24 jeekay Exp $"
#include <fstream>
#include <string>
#include <list>
#include "client.h"
#include "iClient.h"
#include "server.h"
#include "events.h"
namespace gnuworld
{
class stats : public xClient
{
public:
/**
* Create a new stats object, given its configuration filename.
*/
stats( const std::string& ) ;
/**
* Destroy a stats object.
*/
virtual ~stats() ;
/**
* This method required to load into the gnuworld core.
* It basically just calls the base class OnAttach(),
* and registers for events.
*/
virtual void OnAttach() ;
/**
* This method is invoked when someone sends a private
* message to the stats bot.
*/
virtual void OnPrivateMessage( iClient*, const std::string&,
bool = false ) ;
/**
* This method is invoked when someone sends a private
* message CTCP to the stats bot.
*/
virtual void OnCTCP( iClient*, const std::string&,
const std::string&, bool = false ) ;
/**
* This method is invoked when someone sends a channel
* message to the stats bot.
*/
virtual void OnChannelMessage( iClient*, Channel*,
const std::string& ) ;
/**
* This method is invoked when someone sends a channel
* CTCP to the stats bot.
*/
virtual void OnChannelCTCP( iClient*, Channel*,
const std::string&, const std::string& ) ;
/**
* This method is invoked when someone sends a private
* notice to the stats bot.
*/
virtual void OnPrivateNotice( iClient*, const std::string&, bool ) ;
/**
* This method is invoked when someone sends a channel
* notice to the stats bot.
*/
virtual void OnChannelNotice( iClient*, Channel*,
const std::string& ) ;
/**
* This method is called when a general network event
* occurs.
*/
virtual void OnEvent( const eventType&,
void* = 0, void* = 0, void* = 0, void* = 0 ) ;
/**
* This method is invoked when a channel event (except for
* kick) occurs.
*/
virtual void OnChannelEvent( const channelEventType&,
Channel*,
void* Data1 = NULL, void* Data2 = NULL,
void* Data3 = NULL, void* Data4 = NULL ) ;
/**
* This method is invoked when a channel kick occurs.
*/
virtual void OnNetworkKick( Channel*, iClient*,
iClient*, const std::string&, bool ) ;
/**
* This method is called when a registered timer
* expires.
*/
virtual void OnTimer( const xServer::timerID&, void* ) ;
/**
* Return the part message stats will use when it parts
* a channel.
*/
inline const std::string& getPartMessage() const
{ return partMessage ; }
/**
* Set the part message stats will use when it parts
* a channel.
*/
inline void setPartMessage( const std::string& newVal )
{ partMessage = newVal ; }
/**
* Send the current running stats to the given iClient.
*/
virtual void dumpStats( iClient* ) ;
protected:
/**
* WriteLog() will flush all data to the log files.
*/
virtual void writeLog() ;
/**
* Opens all of the log files.
*/
virtual void openLogFiles() ;
/**
* Return true if the given account name is permitted
* access to this module.
*/
virtual bool hasAccess( const std::string& ) const ;
/// True if the stats should log during net burst (of gnuworld)
bool logDuringBurst ;
/// True if opers can use this service, false otherwise
bool allowOpers ;
/// list of account names who can use this service
std::list< std::string > allowAccess ;
/// The path to the directory in which to store the logs files.
/// If the path does not exist, it will NOT be created.
std::string data_path ;
/// The message to use when parting a channel.
std::string partMessage ;
/// The absolute time at which stats collection began.
time_t startTime ;
/// This variable holds the totals for each event,
/// and is reset each minute when the log files are
/// written.
unsigned long int eventMinuteTotal[ EVT_CREATE + 1 ] ;
/// This variable holds the totals for each event
/// since time of connect (optionally excluding net
/// bursts).
unsigned long int eventTotal[ EVT_CREATE + 1 ] ;
/// This variable holds pointers to the individual
/// log files.
std::ofstream fileTable[ EVT_CREATE + 1 ] ;
/// The name of the file to which channel information will
/// be written.
std::string channelInfoFileName ;
/// The name of the file to which user information will be
// written.
std::string userInfoFileName ;
} ;
} // namespace gnuworld
#endif // __STATS_h