Exemplo n.º 1
0
	virtual void OnModCommand(const CString& sCommand)
	{
		CString sCmdName = sCommand.Token(0);
		CString sChannel = sCommand.Token(1);
		sChannel.MakeLower();
		if ((sCmdName == "stick") && (!sChannel.empty()))
		{
			SetNV(sChannel, sCommand.Token(2));
			PutModule("Stuck " + sChannel);
		}
		else if ((sCmdName == "unstick") && (!sChannel.empty()))
		{
			MCString::iterator it = FindNV(sChannel);
			if (it != EndNV())
				DelNV(it);

			PutModule("UnStuck " + sChannel);
		}
		else if ((sCmdName == "list") && (sChannel.empty()))
		{
			int i = 1;
			for (MCString::iterator it = BeginNV(); it != EndNV(); ++it, i++)
			{
				if (it->second.empty())
					PutModule(CString(i) + ": " + it->first);
				else
					PutModule(CString(i) + ": " + it->first + " (" + it->second + ")");
			}
			PutModule(" -- End of List");
		}
		else
		{
			PutModule("USAGE: [un]stick #channel [key], list");
		}
	}
Exemplo n.º 2
0
	bool OnEmbeddedWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
		if (sPageName == "webadmin/user" && WebSock.GetSession()->IsAdmin()) {
			CString sAction = Tmpl["WebadminAction"];
			if (sAction == "display") {
				Tmpl["Blocked"] = CString(IsBlocked(Tmpl["Username"]));
				Tmpl["Self"] = CString(Tmpl["Username"].Equals(WebSock.GetSession()->GetUser()->GetUserName()));
				return true;
			}
			if (sAction == "change" && WebSock.GetParam("embed_blockuser_presented").ToBool()) {
				if (Tmpl["Username"].Equals(WebSock.GetSession()->GetUser()->GetUserName()) &&
						WebSock.GetParam("embed_blockuser_block").ToBool()) {
					WebSock.GetSession()->AddError("You can't block yourself");
				} else if (WebSock.GetParam("embed_blockuser_block").ToBool()) {
					if (!WebSock.GetParam("embed_blockuser_old").ToBool()) {
						if (Block(Tmpl["Username"])) {
							WebSock.GetSession()->AddSuccess("Blocked [" + Tmpl["Username"] + "]");
						} else {
							WebSock.GetSession()->AddError("Couldn't block [" + Tmpl["Username"] + "]");
						}
					}
				} else  if (WebSock.GetParam("embed_blockuser_old").ToBool()){
					if (DelNV(Tmpl["Username"])) {
						WebSock.GetSession()->AddSuccess("Unblocked [" + Tmpl["Username"] + "]");
					} else {
						WebSock.GetSession()->AddError("User [" + Tmpl["Username"] + "is not blocked");
					}
				}
				return true;
			}
		}
		return false;
	}
Exemplo n.º 3
0
	virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
		if (sPageName.empty() || sPageName == "index") {
			bool bSubmitted = (WebSock.GetParam("submitted").ToInt() != 0);

			const vector<CChan*>& Channels = m_pUser->GetChans();
			for (unsigned int c = 0; c < Channels.size(); c++) {
				const CString sChan = Channels[c]->GetName();
				bool bStick = FindNV(sChan) != EndNV();

				if(bSubmitted) {
					bool bNewStick = WebSock.GetParam("stick_" + sChan).ToBool();
					if(bNewStick && !bStick)
						SetNV(sChan, ""); // no password support for now unless chansaver is active too
					else if(!bNewStick && bStick) {
						MCString::iterator it = FindNV(sChan);
						if(it != EndNV())
							DelNV(it);
					}
					bStick = bNewStick;
				}

				CTemplate& Row = Tmpl.AddRow("ChannelLoop");
				Row["Name"] = sChan;
				Row["Sticky"] = CString(bStick);
			}

			if(bSubmitted) {
				WebSock.GetSession()->AddSuccess("Changes have been saved!");
			}

			return true;
		}

		return false;
	}
Exemplo n.º 4
0
	virtual void OnModCommand(const CString& sCommand) {
		CString sCmd = sCommand.Token(0);

		if (sCmd.Equals("DELKEY")) {
			CString sTarget = sCommand.Token(1);

			if (!sTarget.empty()) {
				if (DelNV(sTarget.AsLower())) {
					PutModule("Target [" + sTarget + "] deleted");
				} else {
					PutModule("Target [" + sTarget + "] not found");
				}
			} else {
				PutModule("Usage DelKey <#chan|Nick>");
			}
		} else if (sCmd.Equals("SETKEY")) {
			CString sTarget = sCommand.Token(1);
			CString sKey = sCommand.Token(2, true);

			// Strip "cbc:" from beginning of string incase someone pastes directly from mircryption
			sKey.TrimPrefix("cbc:");

			if (!sKey.empty()) {
				SetNV(sTarget.AsLower(), sKey);
				PutModule("Set encryption key for [" + sTarget + "] to [" + sKey + "]");
			} else {
				PutModule("Usage: SetKey <#chan|Nick> <Key>");
			}
		} else if (sCmd.Equals("LISTKEYS")) {
			if (BeginNV() == EndNV()) {
				PutModule("You have no encryption keys set.");
			} else {
				CTable Table;
				Table.AddColumn("Target");
				Table.AddColumn("Key");

				for (MCString::iterator it = BeginNV(); it != EndNV(); ++it) {
					Table.AddRow();
					Table.SetCell("Target", it->first);
					Table.SetCell("Key", it->second);
				}

				MCString::iterator it = FindNV(NICK_PREFIX_KEY);
				if (it == EndNV()) {
					Table.AddRow();
					Table.SetCell("Target", NICK_PREFIX_KEY);
					Table.SetCell("Key", NickPrefix());
				}

				PutModule(Table);
			}
		} else if (sCmd.Equals("HELP")) {
			PutModule("Try: SetKey, DelKey, ListKeys");
		} else {
			PutModule("Unknown command, try 'Help'");
		}
	}
Exemplo n.º 5
0
	bool Del(bool bNegated, const CString& sChan, const CString& sHost) {
		VAttachIter it = FindEntry(sChan, sHost);
		if (it == m_vMatches.end() || it->IsNegated() != bNegated)
			return false;

		DelNV(it->ToString());
		m_vMatches.erase(it);

		return true;
	}
Exemplo n.º 6
0
 void ShowAllCtcp(const CString& sCtcp) {
     // Toggle between showing all incoming ctcps and just the ones on our notify list.
     if (GetNV("ctcp_showall").empty()) {
         SetNV("ctcp_showall", "y");
         PutModule("Will now show all incoming CTCP replies.");
     } else {
         DelNV("ctcp_showall");
         PutModule("Will no longer show all incoming CTCP replies.");
     }
 }
Exemplo n.º 7
0
    void DelCtcp(const CString& sCtcp) {
        // Remove a ctcp request to the ctcp queries we're listening to.
        CString sCtcpNotifier = sCtcp.Token(1).AsUpper();

        if (!GetNV("ctcp_" + sCtcpNotifier).empty()) {
            DelNV("ctcp_" + sCtcpNotifier);
            PutModule("Deleted CTCP notifier: " + sCtcpNotifier);
        } else {
            PutModule("Could not find CTCP notifier: " + sCtcpNotifier);
        }
    }
Exemplo n.º 8
0
	virtual void OnModCommand(const CString& sCommand) {
		CString sCmd = sCommand.Token(0);
		
		if (sCmd.Equals("settoken")) {
			CString sToken = sCommand.Token(1,true);
			if (!sToken.empty()) {
				if (SetNV("token",sToken)) {
					PutModule("Token [" + sToken + "] setted");
				} else {
					PutModule("Token set error (?)");
				}
				
			} else {
				//PutModule("Usage SetToken <token>");
				if (DelNV("token")) PutModule("Token deleted.");
			}
		} else if (sCmd.Equals("setpassword")) {
			CString sPassw = sCommand.Token(1,true);
			if (!sPassw.empty()) {
				if (SetNV("password",sPassw)) {
					PutModule("Password setted");
				} else {
					PutModule("Password set error (?)");
				}

			} else {
				//PutModule("Usage SetPassword <password>");
				if (DelNV("password")) PutModule("Passwored deleted.");
			}
		} else if (sCmd.Equals("show")) {

			PutModule("Token: [" + GetNV("token") + "]");
			PutModule("Password: [" + GetNV("password") + "]");

		} else if (sCmd.Equals("HELP")) {
			PutModule("Try: Show, SetToken, SetPassword");

		} else {
			PutModule("Unknown command, try 'Help'");
		}
	}
Exemplo n.º 9
0
 bool Delete(const CString& sPattern) {
     vector<CPattern>::iterator it = m_vPatterns.begin();
     for (; it != m_vPatterns.end(); ++it) {
         if (it->GetPattern() == sPattern) {
             m_vPatterns.erase(it);
             DelNV(it->GetPattern());
             return true;
         }
     }
     
     return false;
 }
Exemplo n.º 10
0
	void OnDelKeyCommand(const CString& sCommand) {
		CString sTarget = sCommand.Token(1);

		if (!sTarget.empty()) {
			if (DelNV(sTarget.AsLower())) {
				PutModule("Target [" + sTarget + "] deleted");
			} else {
				PutModule("Target [" + sTarget + "] not found");
			}
		} else {
			PutModule("Usage DelKey <#chan|Nick>");
		}
	}
Exemplo n.º 11
0
	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 {
			PutModule("Commands: set <password>, clear");
		}
	}
Exemplo n.º 12
0
	void OnModCommand(const CString& sCommand) {
		CString sCmd = sCommand.Token(0);

		if (!m_pUser->IsAdmin()) {
			PutModule("Access denied");
			return;
		}

		if (sCmd.Equals("list")) {
			CTable Table;
			MCString::iterator it;

			Table.AddColumn("Blocked user");

			for (it = BeginNV(); it != EndNV(); ++it) {
				Table.AddRow();
				Table.SetCell("Blocked user", it->first);
			}

			if (PutModule(Table) == 0)
				PutModule("No users blocked");
		} else if (sCmd.Equals("block")) {
			CString sUser = sCommand.Token(1, true);

			if (m_pUser->GetUserName().Equals(sUser)) {
				PutModule("You can't block yourself");
				return;
			}

			if (Block(sUser))
				PutModule("Blocked [" + sUser + "]");
			else
				PutModule("Could not block [" + sUser + "] (misspelled?)");
		} else if (sCmd.Equals("unblock")) {
			CString sUser = sCommand.Token(1, true);

			if (DelNV(sUser))
				PutModule("Unblocked [" + sUser + "]");
			else
				PutModule("This user is not blocked");
		} else {
			PutModule("Commands: list, block [user], unblock [user]");
		}
	}
Exemplo n.º 13
0
	virtual bool OnEmbeddedWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
		if (sPageName == "webadmin/channel") {
			CString sChan = Tmpl["ChanName"];
			bool bStick = FindNV(sChan) != EndNV();
			if (Tmpl["WebadminAction"].Equals("display")) {
				Tmpl["Sticky"] = CString(bStick);
			} else if (WebSock.GetParam("embed_stickychan_presented").ToBool()) {
				bool bNewStick = WebSock.GetParam("embed_stickychan_sticky").ToBool();
				if(bNewStick && !bStick) {
					SetNV(sChan, ""); // no password support for now unless chansaver is active too
					WebSock.GetSession()->AddSuccess("Channel become sticky!");
				} else if(!bNewStick && bStick) {
					DelNV(sChan);
					WebSock.GetSession()->AddSuccess("Channel stopped being sticky!");
				}
			}
			return true;
		}
		return false;
	}
Exemplo n.º 14
0
	virtual void OnModCommand(const CString& sCommand) {
		const CString sCmd = sCommand.Token(0);
		const CString sArgs = sCommand.Token(1, true);

		if (sCmd.Equals("silent")) {
			if (sArgs.Equals("yes")) {
				SetNV("silent_timeouts", "yes");
				PutModule("Disabled timeout messages");
			} else if (sArgs.Equals("no")) {
				DelNV("silent_timeouts");
				PutModule("Enabled timeout messages");
			} else if (sArgs.empty()) {
				if (GetNV("silent_timeouts") == "yes")
					PutModule("Timeout messages are disabled");
				else
					PutModule("Timeout message are enabled");
			} else
				PutModule("Invalid argument");
		} else {
			PutModule("Available commands: silent [yes/no], silent");
		}
	}
Exemplo n.º 15
0
	bool Del(const CString& sChan) {
		vector<CString>::iterator it, end;

		if (sChan.empty() || sChan == "!")
			return false;

		if (sChan.Left(1) == "!") {
			CString sTmp = sChan.substr(1);
			it = m_vsNegChans.begin();
			end = m_vsNegChans.end();

			for (; it != end; ++it)
				if (*it == sTmp)
					break;

			if (it == end)
				return false;

			m_vsNegChans.erase(it);
		} else {
			it = m_vsChans.begin();
			end = m_vsChans.end();

			for (; it != end; ++it)
				if (*it == sChan)
					break;

			if (it == end)
				return false;

			m_vsChans.erase(it);
		}

		DelNV(sChan);

		return true;
	}
Exemplo n.º 16
0
	void DisableCloneUserCommand(const CString &sLine) {
		DelNV("CloneUser");
		PutModule("Clone user disabled");
	}
Exemplo n.º 17
0
Arquivo: nickserv.cpp Projeto: KTE/znc
	void ClearCommand(const CString& sLine) {
		DelNV("Password");
	}
Exemplo n.º 18
0
Arquivo: nickserv.cpp Projeto: KTE/znc
	void ClearNSNameCommand(const CString& sLine) {
		DelNV("NickServName");
	}
Exemplo n.º 19
0
	virtual void OnModCommand(const CString& sLine) {
		CString sCommand = sLine.Token(0).AsUpper();

		if (sCommand.Equals("HELP")) {
			PutModule("Commands are: ListUsers, AddChans, DelChans, AddUser, DelUser");
		} else if (sCommand.Equals("TIMERS")) {
			ListTimers();
		} else if (sCommand.Equals("ADDUSER") || sCommand.Equals("DELUSER")) {
			CString sUser = sLine.Token(1);
			CString sHost = sLine.Token(2);
			CString sKey = sLine.Token(3);

			if (sCommand.Equals("ADDUSER")) {
				if (sHost.empty()) {
					PutModule("Usage: " + sCommand + " <user> <hostmask> <key> [channels]");
				} else {
					CAutoOpUser* pUser = AddUser(sUser, sKey, sHost, sLine.Token(4, true));

					if (pUser) {
						SetNV(sUser, pUser->ToString());
					}
				}
			} else {
				DelUser(sUser);
				DelNV(sUser);
			}
		} else if (sCommand.Equals("LISTUSERS")) {
			if (m_msUsers.empty()) {
				PutModule("There are no users defined");
				return;
			}

			CTable Table;

			Table.AddColumn("User");
			Table.AddColumn("Hostmask");
			Table.AddColumn("Key");
			Table.AddColumn("Channels");

			for (map<CString, CAutoOpUser*>::iterator it = m_msUsers.begin(); it != m_msUsers.end(); it++) {
				Table.AddRow();
				Table.SetCell("User", it->second->GetUsername());
				Table.SetCell("Hostmask", it->second->GetHostmask());
				Table.SetCell("Key", it->second->GetUserKey());
				Table.SetCell("Channels", it->second->GetChannels());
			}

			PutModule(Table);
		} else if (sCommand.Equals("ADDCHANS") || sCommand.Equals("DELCHANS")) {
			CString sUser = sLine.Token(1);
			CString sChans = sLine.Token(2, true);

			if (sChans.empty()) {
				PutModule("Usage: " + sCommand + " <user> <channel> [channel] ...");
				return;
			}

			CAutoOpUser* pUser = FindUser(sUser);

			if (!pUser) {
				PutModule("No such user");
				return;
			}

			if (sCommand.Equals("ADDCHANS")) {
				pUser->AddChans(sChans);
				PutModule("Channel(s) added to user [" + pUser->GetUsername() + "]");
			} else {
				pUser->DelChans(sChans);
				PutModule("Channel(s) Removed from user [" + pUser->GetUsername() + "]");
			}

			SetNV(pUser->GetUsername(), pUser->ToString());
		} else {
			PutModule("Unknown command, try HELP");
		}
	}