summaryrefslogtreecommitdiff
path: root/modules/commands/cs_seen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/commands/cs_seen.cpp')
-rw-r--r--modules/commands/cs_seen.cpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp
index 10c23dd53..610ad4475 100644
--- a/modules/commands/cs_seen.cpp
+++ b/modules/commands/cs_seen.cpp
@@ -60,10 +60,10 @@ struct SeenInfo : Serializable
s = anope_dynamic_static_cast<SeenInfo *>(obj);
else
{
- /* ignore duplicate entries in the db, created by an old bug */
- s = FindInfo(snick);
- if (!s)
- s = new SeenInfo();
+ SeenInfo* &info = database[snick];
+ if (!info)
+ info = new SeenInfo();
+ s = info;
}
data["nick"] >> s->nick;
@@ -82,9 +82,6 @@ struct SeenInfo : Serializable
}
};
-static time_t purgetime;
-static time_t expiretimeout;
-
static SeenInfo *FindInfo(const Anope::string &nick)
{
database_map::iterator iter = database.find(nick);
@@ -192,9 +189,9 @@ class CommandSeen : public Command
{
const Anope::string &target = params[0];
- if (target.length() > Config->NickLen)
+ if (target.length() > Config->GetBlock("networkinfo")->Get<unsigned>("nicklen"))
{
- source.Reply(_("Nick too long, max length is %u characters."), Config->NickLen);
+ source.Reply(_("Nick too long, max length is %u characters."), Config->GetBlock("networkinfo")->Get<unsigned>("nicklen"));
return;
}
@@ -300,7 +297,9 @@ class DataBasePurger : public Timer
void Tick(time_t) anope_override
{
- size_t previous_size = database.size();
+ size_t previous_size = database.size(), purgetime = Config->GetModule(this->GetOwner())->Get<time_t>("purgetime");
+ if (!purgetime)
+ purgetime = Anope::DoTime("30d");
for (database_map::iterator it = database.begin(), it_end = database.end(); it != it_end;)
{
database_map::iterator cur = it;
@@ -324,9 +323,8 @@ class CSSeen : public Module
CommandOSSeen commandosseen;
DataBasePurger purger;
public:
- CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this), purger(this)
+ CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this), purger(this)
{
- this->SetAuthor("Anope");
Implementation eventlist[] = { I_OnReload,
I_OnUserConnect,
@@ -334,17 +332,15 @@ class CSSeen : public Module
I_OnUserQuit,
I_OnJoinChannel,
I_OnPartChannel,
- I_OnUserKicked };
+ I_OnPreUserKicked };
ModuleManager::Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
-
- OnReload();
}
- void OnReload() anope_override
+ void OnReload(Configuration::Conf *conf) anope_override
{
- ConfigReader config;
- purgetime = Anope::DoTime(config.ReadValue("cs_seen", "purgetime", "30d", 0));
- expiretimeout = Anope::DoTime(config.ReadValue("cs_seen", "expiretimeout", "1d", 0));
+ time_t expiretimeout = conf->GetModule(this)->Get<time_t>("expiretimeout");
+ if (!expiretimeout)
+ expiretimeout = Anope::DoTime("1d");
if (purger.GetSecs() != expiretimeout)
purger.SetSecs(expiretimeout);
@@ -377,9 +373,9 @@ class CSSeen : public Module
UpdateUser(u, PART, u->nick, "", channel, msg);
}
- void OnUserKicked(Channel *c, User *target, MessageSource &source, const Anope::string &msg) anope_override
+ void OnPreUserKicked(MessageSource &source, ChanUserContainer *cu, const Anope::string &msg) anope_override
{
- UpdateUser(target, KICK, target->nick, source.GetSource(), c->name, msg);
+ UpdateUser(cu->user, KICK, cu->user->nick, source.GetSource(), cu->chan->name, msg);
}
private:
@@ -388,12 +384,9 @@ class CSSeen : public Module
if (!u->server->IsSynced())
return;
- SeenInfo *info = FindInfo(nick);
+ SeenInfo* &info = database[nick];
if (!info)
- {
- info = new SeenInfo;
- database.insert(std::pair<Anope::string, SeenInfo *>(nick, info));
- }
+ info = new SeenInfo();
info->nick = nick;
info->vhost = u->GetVIdent() + "@" + u->GetDisplayedHost();
info->type = Type;