Create a gist now

Instantly share code, notes, and snippets.

@Techman- /ns_emailonexpire.cpp Secret
Last active Nov 11, 2016

Embed
What would you like to do?
A module to send an email when the user's nick when it expires
/* ns_emailonexpire: Send an email to a user's nick when it expires
*
* Copyright 2016 Michael Hazell <michaelhazell@hotmail.com>
*
* You may use this module as long as you follow docs/LICENSE, found in
* the Anope source directory.
*
*/
#include "module.h"
class NSNotifyOnExpire : public Module
{
private:
bool DoEmail (NickAlias *na)
{
Anope::string subject;
Anope::string message;
subject = "Expiry notice for nickname $nickname (account $account)";
subject = subject.replace_all_cs("$nickname", na->nick);
subject = subject.replace_all_cs("$account", na->nc->display);
message = "Hello $account, this is a message from $networkname administration letting you know that the nickname $nickname in your account has expired. If this nickname is the same as your account name, your account has also expired. You are free to re-register your nick and/or account at any time, if it's still available.";
message = message.replace_all_cs("$networkname", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname"));
message = message.replace_all_cs("$account", na->nc->display);
message = message.replace_all_cs("$nickname", na->nick);
/* XXX: Language translation doesn't work for whatever stupid reason
subject = Language::Translate(na->nc, subject);
message = Language::Translate(na->nc, message); */
return Mail::Send(na->nc, subject, message);
}
public:
NSNotifyOnExpire(const Anope::string &modname, const Anope::string &creator):
Module(modname, creator, THIRD)
{
this->SetAuthor("Techman");
this->SetVersion("1.0.0");
Module *m_nickserv = ModuleManager::FindModule("nickserv");
if (!m_nickserv)
throw ModuleException("NickServ is not loaded!");
}
void OnNickExpire(NickAlias *na) anope_override
{
DoEmail(na);
}
};
MODULE_INIT(NSNotifyOnExpire)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment