* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
* See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
/* $ModDesc: Implementation of callerid (umode +g & /accept, ala hybrid etc) */
-class callerid_data : public classbase
+class callerid_data
{
public:
time_t lastnotify;
{
}
- std::string serialize(SerializeFormat format, const Extensible* container, void* item)
+ std::string serialize(SerializeFormat format, const Extensible* container, void* item) const
{
callerid_data* dat = static_cast<callerid_data*>(item);
return dat->ToString(format);
callerid_data* get(User* user, bool create)
{
callerid_data* dat = static_cast<callerid_data*>(get_raw(user));
- if (!dat)
+ if (create && !dat)
{
dat = new callerid_data;
set_raw(user, dat);
class User_g : public SimpleUserModeHandler
{
public:
- User_g(Module* Creator) : SimpleUserModeHandler(Creator, 'g') { }
+ User_g(Module* Creator) : SimpleUserModeHandler(Creator, "callerid", 'g') { }
};
class CommandAccept : public Command
public:
ModuleCallerID() : cmd(this), myumode(this)
{
- OnRehash(NULL);
+ }
- if (!ServerInstance->Modes->AddMode(&myumode))
- throw ModuleException("Could not add usermode +g");
+ void init()
+ {
+ OnRehash(NULL);
- ServerInstance->AddCommand(&cmd);
- Extensible::Register(&cmd.extInfo);
+ ServerInstance->Modules->AddService(myumode);
+ ServerInstance->Modules->AddService(cmd);
+ ServerInstance->Modules->AddService(cmd.extInfo);
Implementation eventlist[] = { I_OnRehash, I_OnUserPreNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage };
ServerInstance->Modules->Attach(eventlist, this, 6);
virtual ~ModuleCallerID()
{
- ServerInstance->Modes->DelMode(&myumode);
}
virtual Version GetVersion()
{
- return Version("Implementation of callerid (umode +g & /accept, ala hybrid etc)", VF_COMMON | VF_VENDOR, API_VERSION);
+ return Version("Implementation of callerid (umode +g & /accept, ala hybrid etc)", VF_COMMON | VF_VENDOR);
}
virtual void On005Numeric(std::string& output)
if (now > (dat->lastnotify + (time_t)notify_cooldown))
{
user->WriteNumeric(717, "%s %s :has been informed that you messaged them.", user->nick.c_str(), dest->nick.c_str());
- ServerInstance->DumpText(dest, ":%s 718 %s %s %s@%s :is messaging you, and you have umode +g. Use /ACCEPT +%s to allow.",
+ dest->SendText(":%s 718 %s %s %s@%s :is messaging you, and you have umode +g. Use /ACCEPT +%s to allow.",
ServerInstance->Config->ServerName.c_str(), dest->nick.c_str(), user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), user->nick.c_str());
dat->lastnotify = now;
}