pastebin - collaborative debugging tool
kpaste.net RSS


ZNC updated nickserv module
Posted by Anonymous on Thu 21st Oct 2010 18:18
raw | new post

  1. /*
  2.  * Copyright (C) 2004-2008  See the AUTHORS file for details.
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify it
  5.  * under the terms of the GNU General Public License version 2 as published
  6.  * by the Free Software Foundation.
  7.  */
  8.  
  9. #include "User.h"
  10.  
  11. class CNickServ : public CModule
  12. {
  13. public:
  14.         MODCONSTRUCTOR (CNickServ) {}
  15.  
  16.         virtual ~CNickServ () {}
  17.  
  18.         virtual bool OnLoad (const CString& sArgs, CString& sMessage) {
  19.                 m_sPass = sArgs.empty() ? GetNV("Password") : sArgs;
  20.                 return true;
  21.         }
  22.  
  23.         virtual void OnModCommand (const CString& sCommand) {
  24.                 CString sCmdName = sCommand.Token(0).AsLower();
  25.                 if (sCmdName == "set") {
  26.                         CString sPass = sCommand.Token(1, true);
  27.                         m_sPass = sPass;
  28.                         PutModule("Password set");
  29.                 } else if (sCmdName == "show") {
  30.                         if (m_sPass.empty())
  31.                                 PutModule("No password set");
  32.                         else
  33.                                 PutModule("Current password: " + m_sPass);
  34.                 } else if (sCmdName == "save") {
  35.                         SetNV("Password", m_sPass);
  36.                         PutModule("Saved!");
  37.                 } else {
  38.                         PutModule("Commands: set <password>, show, save");
  39.                 }
  40.         }
  41.  
  42.         void HandleMessage (CNick& Nick, const CString& sMessage) {
  43.                 if (!m_sPass.empty()
  44.                                 && Nick.GetNick().CaseCmp("NickServ") == 0
  45.                                 && sMessage.find("msg") != CString::npos
  46.                                 && sMessage.find("IDENTIFY") != CString::npos
  47.                                 && sMessage.find("help") == CString::npos) {
  48.                         PutIRC("NickServ :IDENTIFY " + m_sPass);
  49.                 }
  50.                 if (Nick.GetNick().CaseCmp("NickServ") == 0 && (sMessage.find("has been killed") != CString::npos || sMessage.find("isn't currently in use") != CString::npos)) {
  51.                         PutIRC("NICK " + m_pUser->GetNick());
  52.                 }
  53.         }
  54.  
  55.         virtual void OnIRCConnected () {
  56.                 if (m_pUser->GetCurNick().CaseCmp(m_pUser->GetNick()) != 0)
  57.                                 PutIRC("NickServ :GHOST " + m_pUser->GetNick() + " " + m_sPass);
  58.         }
  59.  
  60.         virtual EModRet OnPrivMsg (CNick& Nick, CString& sMessage) {
  61.                 HandleMessage(Nick, sMessage);
  62.                 return CONTINUE;
  63.         }
  64.  
  65.         virtual EModRet OnPrivNotice (CNick& Nick, CString& sMessage) {
  66.                 HandleMessage(Nick, sMessage);
  67.                 return CONTINUE;
  68.         }
  69.  
  70. private:
  71.         CString m_sPass;
  72. };
  73.  
  74. MODULEDEFS(CNickServ, "Auths you with NickServ")

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at