diff options
| author | Adam <Adam@drink-coca-cola.info> | 2010-05-09 19:02:50 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2010-06-18 21:01:09 -0400 |
| commit | 4e1286ca109d079f32d32f07c344a1ab93899032 (patch) | |
| tree | ef55488a4cc068f8954a8862ab2e67f2d1872281 /src/core/ns_sendpass.c | |
| parent | 4149afd45d2c0b9f464d1b4434f7bdaa61873d44 (diff) | |
Rewrote the mail system to use threading
Diffstat (limited to 'src/core/ns_sendpass.c')
| -rw-r--r-- | src/core/ns_sendpass.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/core/ns_sendpass.c b/src/core/ns_sendpass.c index 0ce8f6c5c..ffa4b6ece 100644 --- a/src/core/ns_sendpass.c +++ b/src/core/ns_sendpass.c @@ -14,6 +14,8 @@ #include "module.h" +static bool SendPassMail(User *u, NickAlias *na, const std::string &pass); + class CommandNSSendPass : public Command { public: @@ -34,34 +36,14 @@ class CommandNSSendPass : public Command notice_lang(Config.s_NickServ, u, NICK_X_FORBIDDEN, na->nick); else { - char buf[BUFSIZE]; std::string tmp_pass; if (enc_decrypt(na->nc->pass,tmp_pass) == 1) { - MailInfo *mail; - - snprintf(buf, sizeof(buf), getstring(na, NICK_SENDPASS_SUBJECT), na->nick); - mail = MailBegin(u, na->nc, buf, Config.s_NickServ); - if (!mail) - return MOD_CONT; - - fprintf(mail->pipe, "%s", getstring(na, NICK_SENDPASS_HEAD)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_1), na->nick); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_2), tmp_pass.c_str()); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, "%s", getstring(na, NICK_SENDPASS_LINE_3)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, "%s", getstring(na, NICK_SENDPASS_LINE_4)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_5), Config.NetworkName); - fprintf(mail->pipe, "\n.\n"); - - MailEnd(mail); - - Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SENDPASS on " << nick; - notice_lang(Config.s_NickServ, u, NICK_SENDPASS_OK, nick); + if (SendPassMail(u, na, tmp_pass)) + { + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SENDPASS on " << nick; + notice_lang(Config.s_NickServ, u, NICK_SENDPASS_OK, nick); + } } else notice_lang(Config.s_NickServ, u, NICK_SENDPASS_UNAVAILABLE); @@ -102,10 +84,21 @@ class NSSendPass : public Module ModuleManager::Attach(I_OnNickServHelp, this); } + void OnNickServHelp(User *u) { notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SENDPASS); } }; +static bool SendPassMail(User *u, NickAlias *na, const std::string &pass) +{ + char subject[BUFSIZE], message[BUFSIZE]; + + snprintf(subject, sizeof(subject), getstring(na, NICK_SENDPASS_SUBJECT), na->nick); + snprintf(message, sizeof(message), getstring(na, NICK_SENDPASS), na->nick, pass.c_str(), Config.NetworkName); + + return Mail(u, na->nc, Config.s_NickServ, subject, message); +} + MODULE_INIT(NSSendPass) |
