class AccountExtItemImpl : public AccountExtItem
{
+ Events::ModuleEventProvider eventprov;
+
public:
AccountExtItemImpl(Module* mod)
- : AccountExtItem("accountname", mod)
+ : AccountExtItem("accountname", ExtensionItem::EXT_USER, mod)
+ , eventprov(mod, "event/account")
{
}
void unserialize(SerializeFormat format, Extensible* container, const std::string& value)
{
- User* user = dynamic_cast<User*>(container);
- if (!user)
- return;
+ User* user = static_cast<User*>(container);
StringExtItem::unserialize(format, container, value);
if (!value.empty())
{
// Logged in
if (IS_LOCAL(user))
+ {
user->WriteNumeric(900, "%s %s :You are now logged in as %s",
user->GetFullHost().c_str(), value.c_str(), value.c_str());
-
- AccountEvent(creator, user, value).Send();
- }
- else
- {
- // Logged out
- AccountEvent(creator, user, "").Send();
+ }
}
+ // If value is empty then logged out
+
+ FOREACH_MOD_CUSTOM(eventprov, AccountEventListener, OnAccountChange, (user, value));
}
};
Channel_r m4;
User_r m5;
AccountExtItemImpl accountname;
+ bool checking_ban;
public:
ModuleServicesAccount() : m1(this), m2(this), m3(this), m4(this), m5(this),
accountname(this)
+ , checking_ban(false)
{
}
{
/* On nickchange, if they have +r, remove it */
if (user->IsModeSet(m5) && assign(user->nick) != oldnick)
- {
- std::vector<std::string> modechange;
- modechange.push_back(user->nick);
- modechange.push_back("-r");
- ServerInstance->Modes->Process(modechange, ServerInstance->FakeClient, ModeParser::MODE_LOCALONLY);
- }
+ m5.RemoveMode(user);
}
ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask) CXX11_OVERRIDE
{
- static bool checking = false;
- if (checking)
+ if (checking_ban)
return MOD_RES_PASSTHRU;
if ((mask.length() > 2) && (mask[1] == ':'))
/* If we made it this far we know the user isn't registered
so just deny if it matches */
- checking = true;
+ checking_ban = true;
bool result = chan->CheckBan(user, mask.substr(2));
- checking = false;
+ checking_ban = false;
if (result)
return MOD_RES_DENY;
};
MODULE_INIT(ModuleServicesAccount)
-