Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 142fdeed33ccc52c633c9080e2c57099f217f65d 2 parents cecaf2c + 44a230c
authored November 28, 2011
2  modules/cert.cpp
@@ -29,7 +29,7 @@ class CCertMod : public CModule {
29 29
 		} else {
30 30
 			PutModule("You do not have a certificate. Please use the web interface to add a certificate");
31 31
 			if (m_pUser->IsAdmin()) {
32  
-				PutModule("Alternatively you can either place one at " + PemFile() + " or use the GENERATE command to generate a new certificate");
  32
+				PutModule("Alternatively you can either place one at " + PemFile());
33 33
 			}
34 34
 		}
35 35
 	}
123  modules/nickserv.cpp
@@ -9,90 +9,97 @@
9 9
 #include <znc/Modules.h>
10 10
 #include <znc/User.h>
11 11
 
12  
-class CNickServ : public CModule
13  
-{
  12
+class CNickServ : public CModule {
14 13
 public:
15  
-	MODCONSTRUCTOR(CNickServ)
16  
-	{
  14
+	void SetCommand(const CString& sLine) {
  15
+		SetNV("Password", sLine.Token(1, true));
  16
+		PutModule("Password set");
17 17
 	}
18 18
 
19  
-	virtual ~CNickServ()
20  
-	{
  19
+	void ClearCommand(const CString& sLine) {
  20
+		DelNV("Password");
21 21
 	}
22 22
 
23  
-	virtual bool OnLoad(const CString& sArgs, CString& sMessage)
24  
-	{
25  
-		if (sArgs.empty())
26  
-			m_sPass = GetNV("Password");
27  
-		else {
28  
-			m_sPass = sArgs;
29  
-			SetNV("Password", m_sPass);
30  
-			SetArgs("");
  23
+	void GhostCommand(const CString& sLine) {
  24
+		if (sLine.Token(1).empty()) {
  25
+			PutModule("Syntax: ghost <nickname>");
  26
+		} else {
  27
+			PutIRC("PRIVMSG NickServ :GHOST " + sLine.Token(1) + " " + GetNV("Password"));
31 28
 		}
  29
+	}
32 30
 
33  
-		return true;
  31
+	void RecoverCommand(const CString& sLine) {
  32
+		if (sLine.Token(1).empty()) {
  33
+			PutModule("Syntax: recover <nickname>");
  34
+		} else {
  35
+			PutIRC("PRIVMSG NickServ :RECOVER " + sLine.Token(1) + " " + GetNV("Password"));
  36
+		}
  37
+	}
  38
+
  39
+	void ReleaseCommand(const CString& sLine) {
  40
+		if (sLine.Token(1).empty()) {
  41
+			PutModule("Syntax: release <nickname>");
  42
+		} else {
  43
+			PutIRC("PRIVMSG NickServ :RELEASE " + sLine.Token(1) + " " + GetNV("Password"));
  44
+		}
34 45
 	}
35 46
 
36  
-	virtual void OnModCommand(const CString& sCommand)
37  
-	{
38  
-		CString sCmdName = sCommand.Token(0).AsLower();
39  
-		if (sCmdName == "set") {
40  
-			CString sPass = sCommand.Token(1, true);
41  
-			m_sPass = sPass;
42  
-			SetNV("Password", m_sPass);
43  
-			PutModule("Password set");
44  
-		} else if (sCmdName == "clear") {
45  
-			m_sPass = "";
46  
-			DelNV("Password");
47  
-		} else if (sCmdName == "ghost") {
48  
-			if(sCommand.Token(1).empty()) {
49  
-				PutModule("Syntax: ghost <nickname>");
50  
-			} else {
51  
-				PutIRC("PRIVMSG NickServ :GHOST " + sCommand.Token(1) + " " + m_sPass);
52  
-			}
53  
-		} else if (sCmdName == "group") {
54  
-			CString sConfNick = m_pUser->GetNick();
55  
-			PutIRC("PRIVMSG NickServ :GROUP " + sConfNick + " " + m_sPass);
56  
-		} else if (sCmdName == "recover") {
57  
-			if(sCommand.Token(1).empty())
58  
-				PutModule("Syntax: recover <nickname>");
59  
-			else
60  
-				PutIRC("PRIVMSG NickServ :RECOVER " + sCommand.Token(1) + " " + m_sPass);
61  
-		} else if (sCmdName == "release") {
62  
-			if(sCommand.Token(1).empty())
63  
-				PutModule("Syntax: release <nickname>");
64  
-			else
65  
-				PutIRC("PRIVMSG NickServ :RELEASE " + sCommand.Token(1) + " " + m_sPass);
66  
-		} else
67  
-			PutModule("Commands: set <password>, clear, ghost <nickname>, group, release <nickname>, recover <nickname>");
  47
+	void GroupCommand(const CString& sLine) {
  48
+		if (sLine.Token(1).empty()) {
  49
+			PutModule("Syntax: group <nickname>");
  50
+		} else {
  51
+			PutIRC("PRIVMSG NickServ :GROUP " + sLine.Token(1) + " " + GetNV("Password"));
  52
+		}
68 53
 	}
69 54
 
70  
-	void HandleMessage(CNick& Nick, const CString& sMessage)
71  
-	{
72  
-		if (!m_sPass.empty()
  55
+	MODCONSTRUCTOR(CNickServ) {
  56
+		AddHelpCommand();
  57
+		AddCommand("Set", static_cast<CModCommand::ModCmdFunc>(&CNickServ::SetCommand),
  58
+			"password");
  59
+		AddCommand("Clear", static_cast<CModCommand::ModCmdFunc>(&CNickServ::ClearCommand),
  60
+			"", "Clear your nickserv password");
  61
+		AddCommand("Ghost", static_cast<CModCommand::ModCmdFunc>(&CNickServ::GhostCommand),
  62
+			"nickname", "GHOST disconnects an old user session, or somebody attempting to use your nickname without authorization.");
  63
+		AddCommand("Recover", static_cast<CModCommand::ModCmdFunc>(&CNickServ::RecoverCommand),
  64
+			"nickname");
  65
+		AddCommand("Release", static_cast<CModCommand::ModCmdFunc>(&CNickServ::ReleaseCommand),
  66
+			"nickname");
  67
+		AddCommand("Group", static_cast<CModCommand::ModCmdFunc>(&CNickServ::GroupCommand),
  68
+			"nickname");
  69
+
  70
+	}
  71
+
  72
+	virtual ~CNickServ() {}
  73
+
  74
+	virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
  75
+		if (!sArgs.empty()) {
  76
+			SetNV("Password", sArgs);
  77
+			SetArgs("");
  78
+		}
  79
+
  80
+		return true;
  81
+	}
  82
+
  83
+	void HandleMessage(CNick& Nick, const CString& sMessage) {
  84
+		if (!GetNV("Password").empty()
73 85
 				&& Nick.GetNick().Equals("NickServ")
74 86
 				&& (sMessage.find("msg") != CString::npos
75 87
 				 || sMessage.find("authenticate") != CString::npos)
76 88
 				&& sMessage.AsUpper().find("IDENTIFY") != CString::npos
77 89
 				&& sMessage.find("help") == CString::npos) {
78  
-			PutIRC("PRIVMSG NickServ :IDENTIFY " + m_sPass);
  90
+			PutIRC("PRIVMSG NickServ :IDENTIFY " + GetNV("Password"));
79 91
 		}
80 92
 	}
81 93
 
82  
-	virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage)
83  
-	{
  94
+	virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage) {
84 95
 		HandleMessage(Nick, sMessage);
85 96
 		return CONTINUE;
86 97
 	}
87 98
 
88  
-	virtual EModRet OnPrivNotice(CNick& Nick, CString& sMessage)
89  
-	{
  99
+	virtual EModRet OnPrivNotice(CNick& Nick, CString& sMessage) {
90 100
 		HandleMessage(Nick, sMessage);
91 101
 		return CONTINUE;
92 102
 	}
93  
-
94  
-private:
95  
-	CString m_sPass;
96 103
 };
97 104
 
98 105
 template<> void TModInfo<CNickServ>(CModInfo& Info) {

0 notes on commit 142fdee

Please sign in to comment.
Something went wrong with that request. Please try again.