summaryrefslogtreecommitdiff
path: root/modules/extra/stats/irc2sql/irc2sql.h
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-01-03 19:54:14 -0500
committerAdam <Adam@anope.org>2014-01-03 19:54:14 -0500
commite1ce6174cee90b71dc461be39d2bf20965ff69e0 (patch)
tree6f8788ab40a533f3ae791f30cfe4a1f94fadf193 /modules/extra/stats/irc2sql/irc2sql.h
parent2781b6946daa82b88b08cdd6ab3c6478f7c70aa1 (diff)
Move modules/stats under extras because it depends on m_mysql, update its config a bit to look similar to all of the other config files
Diffstat (limited to 'modules/extra/stats/irc2sql/irc2sql.h')
-rw-r--r--modules/extra/stats/irc2sql/irc2sql.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/modules/extra/stats/irc2sql/irc2sql.h b/modules/extra/stats/irc2sql/irc2sql.h
new file mode 100644
index 000000000..b5fc8c37f
--- /dev/null
+++ b/modules/extra/stats/irc2sql/irc2sql.h
@@ -0,0 +1,77 @@
+#include "module.h"
+#include "modules/sql.h"
+
+class MySQLInterface : public SQL::Interface
+{
+ public:
+ MySQLInterface(Module *o) : SQL::Interface(o) { }
+
+ void OnResult(const SQL::Result &r) anope_override
+ {
+ }
+
+ void OnError(const SQL::Result &r) anope_override
+ {
+ if (!r.GetQuery().query.empty())
+ Log(LOG_DEBUG) << "m_irc2sql: Error executing query " << r.finished_query << ": " << r.GetError();
+ else
+ Log(LOG_DEBUG) << "m_irc2sql: Error executing query: " << r.GetError();
+ }
+};
+
+class IRC2SQL : public Module
+{
+ ServiceReference<SQL::Provider> sql;
+ MySQLInterface sqlinterface;
+ SQL::Query query;
+ std::vector<Anope::string> TableList, ProcedureList, EventList;
+ Anope::string prefix, GeoIPDB;
+ bool quitting, introduced_myself, UseGeoIP, ctcpuser, ctcpeob, firstrun;
+ BotInfo *StatServ;
+ PrimitiveExtensibleItem<bool> versionreply;
+
+ void RunQuery(const SQL::Query &q);
+ void GetTables();
+
+ bool HasTable(const Anope::string &table);
+ bool HasProcedure(const Anope::string &table);
+ bool HasEvent(const Anope::string &table);
+
+ void CheckTables();
+
+ public:
+ IRC2SQL(const Anope::string &modname, const Anope::string &creator) :
+ Module(modname, creator, EXTRA | VENDOR), sql("", ""), sqlinterface(this), versionreply(this, "CTCPVERSION")
+ {
+ firstrun = true;
+ quitting = false;
+ introduced_myself = false;
+ }
+
+ void OnShutdown() anope_override;
+ void OnReload(Configuration::Conf *config) anope_override;
+ void OnNewServer(Server *server) anope_override;
+ void OnServerQuit(Server *server) anope_override;
+ void OnUserConnect(User *u, bool &exempt) anope_override;
+ void OnUserQuit(User *u, const Anope::string &msg) anope_override;
+ void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override;
+ void OnFingerprint(User *u) anope_override;
+ void OnUserModeSet(User *u, const Anope::string &mname) anope_override;
+ void OnUserModeUnset(User *u, const Anope::string &mname) anope_override;
+ void OnUserLogin(User *u) anope_override;
+ void OnNickLogout(User *u) anope_override;
+ void OnSetDisplayedHost(User *u) anope_override;
+
+ void OnChannelCreate(Channel *c) anope_override;
+ void OnChannelDelete(Channel *c) anope_override;
+ void OnLeaveChannel(User *u, Channel *c) anope_override;
+ void OnJoinChannel(User *u, Channel *c) anope_override;
+ EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) anope_override;
+ EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) anope_override;
+
+ void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) anope_override;
+
+ void OnBotNotice(User *u, BotInfo *bi, Anope::string &message) anope_override;
+};
+
+