summaryrefslogtreecommitdiff
path: root/modules/extra/m_chanstats.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-05-05 01:55:04 -0400
committerAdam <Adam@anope.org>2013-05-05 01:55:04 -0400
commit1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b (patch)
tree4486f0784bdf050fd7eb225c0cb9df352ce1f45a /modules/extra/m_chanstats.cpp
parent781defb7076ddfddf723ca08cd0a518b6657b64f (diff)
Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in.
Diffstat (limited to 'modules/extra/m_chanstats.cpp')
-rw-r--r--modules/extra/m_chanstats.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/modules/extra/m_chanstats.cpp b/modules/extra/m_chanstats.cpp
index caa20aacb..f5e20646b 100644
--- a/modules/extra/m_chanstats.cpp
+++ b/modules/extra/m_chanstats.cpp
@@ -1,5 +1,5 @@
#include "module.h"
-#include "../extra/sql.h"
+#include "sql.h"
class MySQLInterface : public SQL::Interface
{
@@ -338,7 +338,7 @@ class MChanstats : public Module
{
Implementation i[] = { I_OnPrivmsg,
- I_OnUserKicked,
+ I_OnPreUserKicked,
I_OnChannelModeSet,
I_OnChannelModeUnset,
I_OnTopicUpdated,
@@ -349,14 +349,15 @@ class MChanstats : public Module
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
}
- void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
+ void OnReload(Configuration::Conf *conf) anope_override
{
- prefix = reader.ReadValue("chanstats", "prefix", "anope_", 0);
- SmileysHappy = reader.ReadValue("chanstats", "SmileysHappy", ":) :-) ;) :D :-D", 0);
- SmileysSad = reader.ReadValue("chanstats", "SmileysSad", ":( :-( ;( ;-(", 0);
- SmileysOther = reader.ReadValue("chanstats", "SmileysOther", ":/", 0);
+ Configuration::Block *block = conf->GetModule(this);
+ prefix = block->Get<const Anope::string &>("prefix", "anope_");
+ SmileysHappy = block->Get<const Anope::string &>("SmileysHappy");
+ SmileysSad = block->Get<const Anope::string &>("SmileysSad");
+ SmileysOther = block->Get<const Anope::string &>("SmileysOther");
- Anope::string engine = reader.ReadValue("chanstats", "engine", "", 0);
+ Anope::string engine = block->Get<const Anope::string &>("engine");
this->sql = ServiceReference<SQL::Provider>("SQL::Provider", engine);
if (sql)
this->CheckTables();
@@ -399,24 +400,24 @@ class MChanstats : public Module
this->RunQuery(query);
}
public:
- void OnUserKicked(Channel *c, User *target, MessageSource &source, const Anope::string &kickmsg) anope_override
+ void OnPreUserKicked(MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) anope_override
{
- if (!c->ci || !c->ci->HasExt("STATS"))
+ if (!cu->chan->ci || !cu->chan->ci->HasExt("STATS"))
return;
query = "CALL " + prefix + "chanstats_proc_update(@channel@, @nick@, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0);";
- query.SetValue("channel", c->name);
- query.SetValue("nick", GetDisplay(target));
+ query.SetValue("channel", cu->chan->name);
+ query.SetValue("nick", GetDisplay(cu->user));
this->RunQuery(query);
query = "CALL " + prefix + "chanstats_proc_update(@channel@, @nick@, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0);";
- query.SetValue("channel", c->name);
+ query.SetValue("channel", cu->chan->name);
query.SetValue("nick", GetDisplay(source.GetUser()));
this->RunQuery(query);
}
void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override
{
- if (!c->ci || !c->ci->HasExt("STATS") || (msg[0] == Config->BSFantasyCharacter[0]))
+ if (!c->ci || !c->ci->HasExt("STATS"))
return;
size_t letters = msg.length();