~ubuntu-branches/ubuntu/trusty/znc/trusty

« back to all changes in this revision

Viewing changes to modules/nickserv.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-11-08 13:13:58 UTC
  • mfrom: (34.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20131108131358-o90mlo1evvu27z8h
Tags: 1.2-1
* New upstream release.
  Closes: #728786
  - Remove merged patch 01-spelling-error.
  - Remove merged patch 02-CVE-2013-2130.
  - License has been changed to Apache-2.0.
  - Disable new tests, because they require an internet connection.
  - Add new znc-extra module modules_online.
  - Remove AUTHORS file.
* Bump Standards-Version to 3.9.5 (no changes needed).
* Don't explicitly request xz compression - dpkg 1.17 does this by default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2004-2012  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.
 
2
 * Copyright (C) 2004-2013 ZNC, see the NOTICE file for details.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
7
15
 */
8
16
 
9
17
#include <znc/Modules.h>
26
34
                DelNV("Password");
27
35
        }
28
36
 
 
37
        void SetNSNameCommand(const CString& sLine) {
 
38
                SetNV("NickServName", sLine.Token(1, true));
 
39
                PutModule("NickServ name set");
 
40
        }
 
41
 
 
42
        void ClearNSNameCommand(const CString& sLine) {
 
43
                DelNV("NickServName");
 
44
        }
 
45
 
29
46
        void GhostCommand(const CString& sLine) {
30
47
                if (sLine.Token(1).empty()) {
31
48
                        PutModule("Syntax: ghost <nickname>");
92
109
                        "password");
93
110
                AddCommand("Clear", static_cast<CModCommand::ModCmdFunc>(&CNickServ::ClearCommand),
94
111
                        "", "Clear your nickserv password");
 
112
                AddCommand("SetNSName", static_cast<CModCommand::ModCmdFunc>(&CNickServ::SetNSNameCommand),
 
113
                        "nickname", "Set NickServ name (Useful on networks like EpiKnet, where NickServ is named Themis)");
 
114
                AddCommand("ClearNSName", static_cast<CModCommand::ModCmdFunc>(&CNickServ::ClearNSNameCommand),
 
115
                        "", "Reset NickServ name to default (NickServ)");
95
116
                AddCommand("Ghost", static_cast<CModCommand::ModCmdFunc>(&CNickServ::GhostCommand),
96
117
                        "nickname", "GHOST disconnects an old user session, or somebody attempting to use your nickname without authorization.");
97
118
                AddCommand("Recover", static_cast<CModCommand::ModCmdFunc>(&CNickServ::RecoverCommand),
109
130
        virtual ~CNickServ() {}
110
131
 
111
132
        virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
112
 
                if (!sArgs.empty()) {
 
133
                if (!sArgs.empty() && sArgs != "<hidden>") {
113
134
                        SetNV("Password", sArgs);
114
 
                        SetArgs("");
 
135
                        SetArgs("<hidden>");
115
136
                }
116
137
 
117
138
                if (GetNV("IdentifyCmd").empty()) {
134
155
        }
135
156
 
136
157
        void HandleMessage(CNick& Nick, const CString& sMessage) {
 
158
                CString sNickServName = (!GetNV("NickServName").empty()) ? GetNV("NickServName") : "NickServ";
137
159
                if (!GetNV("Password").empty()
138
 
                                && Nick.GetNick().Equals("NickServ")
 
160
                                && Nick.NickEquals(sNickServName)
139
161
                                && (sMessage.find("msg") != CString::npos
140
162
                                 || sMessage.find("authenticate") != CString::npos
141
163
                                 || sMessage.find("choose a different nickname") != CString::npos
 
164
                                 || sMessage.find("If this is your nick, identify yourself with") != CString::npos
142
165
                                 || sMessage.find("If this is your nick, type") != CString::npos
143
 
                                 || sMessage.find("type /NickServ IDENTIFY password") != CString::npos)
 
166
                                 || sMessage.StripControls_n().find("type /NickServ IDENTIFY password") != CString::npos)
144
167
                                && sMessage.AsUpper().find("IDENTIFY") != CString::npos
145
168
                                && sMessage.find("help") == CString::npos) {
146
169
                        MCString msValues;