mirror of
https://github.com/anope/anope.git
synced 2026-06-30 19:26:38 +02:00
made the chanstats fantasy modules work again.
This commit is contained in:
@@ -38,9 +38,15 @@ command { service = "NickServ"; name = "SASET CHANSTATS"; command = "nickserv/sa
|
||||
module { name = "cs_fantasy_stats" }
|
||||
command { service = "ChanServ"; name = "STATS"; command = "chanserv/stats"; }
|
||||
command { service = "ChanServ"; name = "GSTATS"; command = "chanserv/gstats"; }
|
||||
fantasy { name = "STATS"; command = "chanserv/stats"; }
|
||||
fantasy { name = "GSTATS"; command = "chanserv/gstats"; }
|
||||
|
||||
module { name = "cs_fantasy_top" }
|
||||
command { service = "ChanServ"; name = "TOP"; command = "chanserv/top"; }
|
||||
command { service = "ChanServ"; name = "TOP10"; command = "chanserv/top10"; }
|
||||
command { service = "ChanServ"; name = "GTOP"; command = "chanserv/gtop"; }
|
||||
command { service = "ChanServ"; name = "GTOP10"; command = "chanserv/gtop10"; }
|
||||
fantasy { name = "TOP"; command = "chanserv/top"; }
|
||||
fantasy { name = "TOP10"; command = "chanserv/top10"; }
|
||||
fantasy { name = "GTOP"; command = "chanserv/gtop"; }
|
||||
fantasy { name = "GTOP10"; command = "chanserv/gtop10"; }
|
||||
|
||||
@@ -37,7 +37,7 @@ class CommandCSStats : public Command
|
||||
CommandCSStats(Module *creator) : Command (creator, "chanserv/stats", 0, 2)
|
||||
{
|
||||
this->SetDesc(_("Displays your Channel Stats"));
|
||||
this->SetSyntax(_("\037nick\037"));
|
||||
this->SetSyntax(_("[\037channel\037] [\037nick\037]"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms);
|
||||
@@ -75,10 +75,10 @@ class CSStats : public Module
|
||||
|
||||
void OnReload(Configuration::Conf *conf) anope_override
|
||||
{
|
||||
prefix = conf->GetModule(this)->Get<const Anope::string>("prefix");
|
||||
prefix = conf->GetModule("m_chanstats")->Get<const Anope::string>("prefix");
|
||||
if (prefix.empty())
|
||||
prefix = "anope_";
|
||||
this->sql = ServiceReference<SQL::Provider>("SQL::Provider", conf->GetModule(this)->Get<const Anope::string>("engine"));
|
||||
this->sql = ServiceReference<SQL::Provider>("SQL::Provider", conf->GetModule("m_chanstats")->Get<const Anope::string>("engine"));
|
||||
}
|
||||
|
||||
SQL::Result RunQuery(const SQL::Query &query)
|
||||
@@ -94,30 +94,51 @@ class CSStats : public Module
|
||||
|
||||
void DoStats(CommandSource &source, const bool is_global, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!source.c)
|
||||
return;
|
||||
Anope::string display, channel;
|
||||
|
||||
Anope::string display;
|
||||
if (params.empty())
|
||||
display = source.nc->display;
|
||||
else if (const NickAlias *na = NickAlias::Find(params[0]))
|
||||
display = na->nc->display;
|
||||
else
|
||||
/*
|
||||
* possible parameters are:
|
||||
* stats [channel] [nick]
|
||||
* stats [channel]
|
||||
* stats [nick]
|
||||
* stats
|
||||
*/
|
||||
|
||||
switch (params.size())
|
||||
{
|
||||
source.Reply(_("%s not found."), params[0].c_str());
|
||||
return;
|
||||
case 2:
|
||||
channel = params[0];
|
||||
display = params[1];
|
||||
break;
|
||||
case 1:
|
||||
if (params[0][0] == '#')
|
||||
channel = params[0];
|
||||
else
|
||||
{
|
||||
if (NickAlias *na = NickAlias::Find(params[0]))
|
||||
display = na->nc->display;
|
||||
else
|
||||
{
|
||||
source.Reply(_("%s not found."), params[0].c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (display.empty())
|
||||
display = source.nc->display;
|
||||
|
||||
try
|
||||
{
|
||||
SQL::Query query;
|
||||
query = "SELECT letters, words, line, smileys_happy+smileys_sad+smileys_other as smileys,"
|
||||
"actions FROM `" + prefix + "chanstats` "
|
||||
"WHERE `nick` = @nick@ AND `chan` = @channel@ AND `type` = 'total';";
|
||||
if (is_global)
|
||||
if (is_global || channel.empty())
|
||||
query.SetValue("channel", "");
|
||||
else
|
||||
query.SetValue("channel", source.c->ci->name);
|
||||
query.SetValue("channel", channel);
|
||||
query.SetValue("nick", display);
|
||||
SQL::Result res = this->RunQuery(query);
|
||||
|
||||
@@ -126,7 +147,7 @@ class CSStats : public Module
|
||||
if (is_global)
|
||||
source.Reply(_("Network stats for %s:"), display.c_str());
|
||||
else
|
||||
source.Reply(_("Channel stats for %s on %s:"), display.c_str(), source.c->name.c_str());
|
||||
source.Reply(_("Channel stats for %s on %s:"), display.c_str(), channel.c_str());
|
||||
|
||||
source.Reply(_("letters: %s, words: %s, lines: %s, smileys %s, actions: %s"),
|
||||
res.Get(0, "letters").c_str(), res.Get(0, "words").c_str(),
|
||||
|
||||
@@ -100,10 +100,10 @@ class CSTop : public Module
|
||||
|
||||
void OnReload(Configuration::Conf *conf) anope_override
|
||||
{
|
||||
prefix = conf->GetModule(this)->Get<const Anope::string>("prefix");
|
||||
prefix = conf->GetModule("m_chanstats")->Get<const Anope::string>("prefix");
|
||||
if (prefix.empty())
|
||||
prefix = "anope_";
|
||||
this->sql = ServiceReference<SQL::Provider>("SQL::Provider", conf->GetModule(this)->Get<const Anope::string>("engine"));
|
||||
this->sql = ServiceReference<SQL::Provider>("SQL::Provider", conf->GetModule("m_chanstats")->Get<const Anope::string>("engine"));
|
||||
}
|
||||
|
||||
SQL::Result RunQuery(const SQL::Query &query)
|
||||
@@ -119,19 +119,15 @@ class CSTop : public Module
|
||||
|
||||
void DoTop(CommandSource &source, const std::vector<Anope::string> ¶ms, bool is_global, int limit = 1)
|
||||
{
|
||||
if (!source.c || !source.c->ci)
|
||||
return;
|
||||
|
||||
Anope::string channel;
|
||||
if (is_global || params.empty())
|
||||
channel = source.c->ci->name;
|
||||
else if (!params.empty())
|
||||
if (!params.empty())
|
||||
channel = params[0];
|
||||
else
|
||||
{
|
||||
source.Reply(_("%s not found."), params[0].c_str());
|
||||
return;
|
||||
}
|
||||
else if (source.c && source.c->ci)
|
||||
channel = source.c->ci->name;
|
||||
|
||||
if (!is_global && channel.empty())
|
||||
is_global = true;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
# them into existing mysql tables. The tables are created
|
||||
# by the irc2sql module on the first load.
|
||||
|
||||
# Dont forget to rename this file or your changes
|
||||
# will be overwritte on the next 'make install'
|
||||
|
||||
############################
|
||||
# Config
|
||||
############################
|
||||
@@ -16,7 +19,7 @@ mysql_user="anope"
|
||||
mysql_password="anope"
|
||||
mysql_database="anope"
|
||||
prefix="anope_"
|
||||
die="no"
|
||||
die="yes"
|
||||
|
||||
###########################
|
||||
|
||||
|
||||
Reference in New Issue
Block a user