Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:znc/znc

  • Loading branch information...
commit 142fdeed33ccc52c633c9080e2c57099f217f65d 2 parents cecaf2c + 44a230c
Alexey Sokolov authored
Showing with 66 additions and 59 deletions.
  1. +1 −1  modules/cert.cpp
  2. +65 −58 modules/nickserv.cpp
View
2  modules/cert.cpp
@@ -29,7 +29,7 @@ class CCertMod : public CModule {
} else {
PutModule("You do not have a certificate. Please use the web interface to add a certificate");
if (m_pUser->IsAdmin()) {
- PutModule("Alternatively you can either place one at " + PemFile() + " or use the GENERATE command to generate a new certificate");
+ PutModule("Alternatively you can either place one at " + PemFile());
}
}
}
View
123 modules/nickserv.cpp
@@ -9,90 +9,97 @@
#include <znc/Modules.h>
#include <znc/User.h>
-class CNickServ : public CModule
-{
+class CNickServ : public CModule {
public:
- MODCONSTRUCTOR(CNickServ)
- {
+ void SetCommand(const CString& sLine) {
+ SetNV("Password", sLine.Token(1, true));
+ PutModule("Password set");
}
- virtual ~CNickServ()
- {
+ void ClearCommand(const CString& sLine) {
+ DelNV("Password");
}
- virtual bool OnLoad(const CString& sArgs, CString& sMessage)
- {
- if (sArgs.empty())
- m_sPass = GetNV("Password");
- else {
- m_sPass = sArgs;
- SetNV("Password", m_sPass);
- SetArgs("");
+ void GhostCommand(const CString& sLine) {
+ if (sLine.Token(1).empty()) {
+ PutModule("Syntax: ghost <nickname>");
+ } else {
+ PutIRC("PRIVMSG NickServ :GHOST " + sLine.Token(1) + " " + GetNV("Password"));
}
+ }
- return true;
+ void RecoverCommand(const CString& sLine) {
+ if (sLine.Token(1).empty()) {
+ PutModule("Syntax: recover <nickname>");
+ } else {
+ PutIRC("PRIVMSG NickServ :RECOVER " + sLine.Token(1) + " " + GetNV("Password"));
+ }
+ }
+
+ void ReleaseCommand(const CString& sLine) {
+ if (sLine.Token(1).empty()) {
+ PutModule("Syntax: release <nickname>");
+ } else {
+ PutIRC("PRIVMSG NickServ :RELEASE " + sLine.Token(1) + " " + GetNV("Password"));
+ }
}
- virtual void OnModCommand(const CString& sCommand)
- {
- CString sCmdName = sCommand.Token(0).AsLower();
- if (sCmdName == "set") {
- CString sPass = sCommand.Token(1, true);
- m_sPass = sPass;
- SetNV("Password", m_sPass);
- PutModule("Password set");
- } else if (sCmdName == "clear") {
- m_sPass = "";
- DelNV("Password");
- } else if (sCmdName == "ghost") {
- if(sCommand.Token(1).empty()) {
- PutModule("Syntax: ghost <nickname>");
- } else {
- PutIRC("PRIVMSG NickServ :GHOST " + sCommand.Token(1) + " " + m_sPass);
- }
- } else if (sCmdName == "group") {
- CString sConfNick = m_pUser->GetNick();
- PutIRC("PRIVMSG NickServ :GROUP " + sConfNick + " " + m_sPass);
- } else if (sCmdName == "recover") {
- if(sCommand.Token(1).empty())
- PutModule("Syntax: recover <nickname>");
- else
- PutIRC("PRIVMSG NickServ :RECOVER " + sCommand.Token(1) + " " + m_sPass);
- } else if (sCmdName == "release") {
- if(sCommand.Token(1).empty())
- PutModule("Syntax: release <nickname>");
- else
- PutIRC("PRIVMSG NickServ :RELEASE " + sCommand.Token(1) + " " + m_sPass);
- } else
- PutModule("Commands: set <password>, clear, ghost <nickname>, group, release <nickname>, recover <nickname>");
+ void GroupCommand(const CString& sLine) {
+ if (sLine.Token(1).empty()) {
+ PutModule("Syntax: group <nickname>");
+ } else {
+ PutIRC("PRIVMSG NickServ :GROUP " + sLine.Token(1) + " " + GetNV("Password"));
+ }
}
- void HandleMessage(CNick& Nick, const CString& sMessage)
- {
- if (!m_sPass.empty()
+ MODCONSTRUCTOR(CNickServ) {
+ AddHelpCommand();
+ AddCommand("Set", static_cast<CModCommand::ModCmdFunc>(&CNickServ::SetCommand),
+ "password");
+ AddCommand("Clear", static_cast<CModCommand::ModCmdFunc>(&CNickServ::ClearCommand),
+ "", "Clear your nickserv password");
+ AddCommand("Ghost", static_cast<CModCommand::ModCmdFunc>(&CNickServ::GhostCommand),
+ "nickname", "GHOST disconnects an old user session, or somebody attempting to use your nickname without authorization.");
+ AddCommand("Recover", static_cast<CModCommand::ModCmdFunc>(&CNickServ::RecoverCommand),
+ "nickname");
+ AddCommand("Release", static_cast<CModCommand::ModCmdFunc>(&CNickServ::ReleaseCommand),
+ "nickname");
+ AddCommand("Group", static_cast<CModCommand::ModCmdFunc>(&CNickServ::GroupCommand),
+ "nickname");
+
+ }
+
+ virtual ~CNickServ() {}
+
+ virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
+ if (!sArgs.empty()) {
+ SetNV("Password", sArgs);
+ SetArgs("");
+ }
+
+ return true;
+ }
+
+ void HandleMessage(CNick& Nick, const CString& sMessage) {
+ if (!GetNV("Password").empty()
&& Nick.GetNick().Equals("NickServ")
&& (sMessage.find("msg") != CString::npos
|| sMessage.find("authenticate") != CString::npos)
&& sMessage.AsUpper().find("IDENTIFY") != CString::npos
&& sMessage.find("help") == CString::npos) {
- PutIRC("PRIVMSG NickServ :IDENTIFY " + m_sPass);
+ PutIRC("PRIVMSG NickServ :IDENTIFY " + GetNV("Password"));
}
}
- virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage)
- {
+ virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage) {
HandleMessage(Nick, sMessage);
return CONTINUE;
}
- virtual EModRet OnPrivNotice(CNick& Nick, CString& sMessage)
- {
+ virtual EModRet OnPrivNotice(CNick& Nick, CString& sMessage) {
HandleMessage(Nick, sMessage);
return CONTINUE;
}
-
-private:
- CString m_sPass;
};
template<> void TModInfo<CNickServ>(CModInfo& Info) {
Please sign in to comment.
Something went wrong with that request. Please try again.