mirror of
https://github.com/anope/anope.git
synced 2026-07-03 01:03:11 +02:00
Remove the old 1.8-style seen system.
This commit is contained in:
@@ -1179,9 +1179,6 @@ module
|
||||
{
|
||||
name = "cs_seen"
|
||||
|
||||
/* If set, uses the older 1.8 style seen, which is less resource intensive */
|
||||
simple = no
|
||||
|
||||
/* Sets the time to keep seen entries in the seen database. */
|
||||
purgetime = 90d
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ enum TypeInfo
|
||||
NEW, NICK_TO, NICK_FROM, JOIN, PART, QUIT, KICK
|
||||
};
|
||||
|
||||
static bool simple;
|
||||
struct SeenInfo;
|
||||
static SeenInfo *FindInfo(const Anope::string &nick);
|
||||
typedef Anope::unordered_map<SeenInfo *> database_map;
|
||||
@@ -241,76 +240,6 @@ public:
|
||||
class CommandSeen final
|
||||
: public Command
|
||||
{
|
||||
static void SimpleSeen(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!source.c || !source.c->ci)
|
||||
{
|
||||
if (source.IsOper())
|
||||
source.Reply("Seen in simple mode is designed as a fantasy command only!");
|
||||
return;
|
||||
}
|
||||
|
||||
BotInfo *bi = BotInfo::Find(params[0], true);
|
||||
if (bi)
|
||||
{
|
||||
if (bi == source.c->ci->bi)
|
||||
source.Reply(_("You found me, %s!"), source.GetNick().c_str());
|
||||
else
|
||||
source.Reply(_("%s is a network service."), bi->nick.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
NickAlias *na = NickAlias::Find(params[0]);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(_("I don't know who %s is."), params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.GetAccount() == na->nc)
|
||||
{
|
||||
source.Reply(_("Looking for yourself, eh %s?"), source.GetNick().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
User *target = User::Find(params[0], true);
|
||||
|
||||
if (target && source.c->FindUser(target))
|
||||
{
|
||||
source.Reply(_("%s is on the channel right now!"), target->nick.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &[_, uc] : source.c->users)
|
||||
{
|
||||
User *u = uc->user;
|
||||
|
||||
if (u->Account() == na->nc)
|
||||
{
|
||||
source.Reply(_("%s is on the channel right now (as %s)!"), params[0].c_str(), u->nick.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AccessGroup ag = source.c->ci->AccessFor(na->nc);
|
||||
time_t last = 0;
|
||||
for (const auto &p : ag.paths)
|
||||
{
|
||||
if (p.empty())
|
||||
continue;
|
||||
|
||||
ChanAccess *a = p[p.size() - 1];
|
||||
|
||||
if (a->GetAccount() == na->nc && a->last_seen > last)
|
||||
last = a->last_seen;
|
||||
}
|
||||
|
||||
if (last > Anope::CurTime || !last)
|
||||
source.Reply(_("I've never seen %s on this channel."), na->nick.c_str());
|
||||
else
|
||||
source.Reply(_("%s was last seen here %s ago."), na->nick.c_str(), Anope::Duration(Anope::CurTime - last, source.GetAccount()).c_str());
|
||||
}
|
||||
|
||||
public:
|
||||
CommandSeen(Module *creator) : Command(creator, "chanserv/seen", 1, 2)
|
||||
{
|
||||
@@ -323,9 +252,6 @@ public:
|
||||
{
|
||||
const Anope::string &target = params[0];
|
||||
|
||||
if (simple)
|
||||
return this->SimpleSeen(source, params);
|
||||
|
||||
if (target.length() > IRCD->MaxNick)
|
||||
{
|
||||
source.Reply(_("Nick too long, max length is %zu characters."), IRCD->MaxNick);
|
||||
@@ -443,11 +369,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void OnReload(Configuration::Conf &conf) override
|
||||
{
|
||||
simple = conf.GetModule(this).Get<bool>("simple");
|
||||
}
|
||||
|
||||
void OnExpireTick() override
|
||||
{
|
||||
size_t previous_size = database.size();
|
||||
@@ -503,7 +424,7 @@ public:
|
||||
private:
|
||||
static void UpdateUser(const User *u, const TypeInfo Type, const Anope::string &nick, const Anope::string &nick2, const Anope::string &channel, const Anope::string &message)
|
||||
{
|
||||
if (simple || !u->server->IsSynced())
|
||||
if (!u->server->IsSynced())
|
||||
return;
|
||||
|
||||
SeenInfo *&info = database[nick];
|
||||
|
||||
Reference in New Issue
Block a user