Example #1
0
    bool OnLoad(const CString& sArgs, CString& sMessage) override {
        CString sReasonArg;

        // Load AwayWait
        CString sFirstArg = sArgs.Token(0);
        if (sFirstArg.Equals("-notimer")) {
            SetAwayWait(0);
            sReasonArg = sArgs.Token(1, true);
        } else if (sFirstArg.Equals("-timer")) {
            SetAwayWait(sArgs.Token(1).ToUInt());
            sReasonArg = sArgs.Token(2, true);
        } else {
            CString sAwayWait = GetNV("awaywait");
            if (!sAwayWait.empty()) SetAwayWait(sAwayWait.ToUInt(), false);
            sReasonArg = sArgs;
        }

        // Load Reason
        if (!sReasonArg.empty()) {
            SetReason(sReasonArg);
        } else {
            CString sSavedReason = GetNV("reason");
            if (!sSavedReason.empty()) SetReason(sSavedReason, false);
        }

        // MinClients
        CString sMinClients = GetNV("minclients");
        if (!sMinClients.empty()) SetMinClients(sMinClients.ToUInt(), false);

        // Set away on load, required if loaded via webadmin
        if (GetNetwork()->IsIRCConnected() && MinClientsConnected())
            SetAway(false);

        return true;
    }
Example #2
0
	virtual void OnModCommand(const CString& sCommand) {
		if (!GetUser()->IsAdmin()) {
			PutModule("Access denied");
			return;
		}

		CString sCmd = sCommand.Token(0);

		if (sCmd.Equals("target")) {
			CString sArg = sCommand.Token(1, true);
			CString sTarget;
			CString sMessage;
			LogMode mode;

			if (sArg.Equals("file")) {
				sTarget = "file";
				sMessage = "Now only logging to file";
				mode = LOG_TO_FILE;
			} else if (sArg.Equals("syslog")) {
				sTarget = "syslog";
				sMessage = "Now only logging to syslog";
				mode = LOG_TO_SYSLOG;
			} else if (sArg.Equals("both")) {
				sTarget = "both";
				sMessage = "Now logging to file and syslog";
				mode = LOG_TO_BOTH;
			} else {
				PutModule("Unknown target");
				return;
			}

			Log(sMessage);
			SetNV("target", sTarget);
			m_eLogMode = mode;
			PutModule(sMessage);
		} else if (sCmd.Equals("show")) {
			CString sTarget;

			switch (m_eLogMode)
			{
			case LOG_TO_FILE:
				sTarget = "file";
				break;
			case LOG_TO_SYSLOG:
				sTarget = "syslog";
				break;
			case LOG_TO_BOTH:
				sTarget = "both, file and syslog";
				break;
			}

			PutModule("Logging is enabled for " + sTarget);
			if (m_eLogMode != LOG_TO_SYSLOG)
				PutModule("Log file will be written to [" + m_sLogFile + "]");
		} else
			PutModule("Commands: show, target <file|syslog|both>");
	}
Example #3
0
void CClient::StatusCTCP(const CString& sLine) {
    CString sCommand = sLine.Token(0);

    if (sCommand.Equals("PING")) {
        PutStatusNotice("\001PING " + sLine.Token(1, true) + "\001");
    } else if (sCommand.Equals("VERSION")) {
        PutStatusNotice("\001VERSION " + CZNC::GetTag() + "\001");
    }
}
Example #4
0
    bool IsOnlineModNick(const CString& sNick) {
        const CString& sPrefix = m_pUser->GetStatusPrefix();
        if (!sNick.Equals(sPrefix, false, sPrefix.length()))
            return false;

        CString sModNick = sNick.substr(sPrefix.length());
        if (!sModNick.Equals("status") &&
                !m_pUser->GetModules().FindModule(sModNick) &&
                !CZNC::Get().GetModules().FindModule(sModNick))
            return false;
        return true;
    }
Example #5
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);
				}

				PutModule(Table);
			}
		} else if (sCmd.Equals("HELP")) {
			PutModule("Try: SetKey, DelKey, ListKeys");
		} else {
			PutModule("Unknown command, try 'Help'");
		}
	}
Example #6
0
File: schat.cpp Project: clem16/znc
	virtual EModRet OnUserRaw(CString & sLine) override
	{
		if (sLine.Equals("schat ", false, 6)) {
			OnModCommand("chat " + sLine.substr(6));
			return(HALT);

		} else if (sLine.Equals("schat")) {
			PutModule("SChat User Area ...");
			OnModCommand("help");
			return(HALT);
		}

		return(CONTINUE);
	}
Example #7
0
File: schat.cpp Project: clem16/znc
	virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage) override
	{
		if (sTarget.Left(3) == "(s)") {
			CString sSockName = GetModName().AsUpper() + "::" + sTarget;
			CSChatSock *p = (CSChatSock *)FindSocket(sSockName);
			if (!p) {
				map< CString,pair< u_long,u_short > >::iterator it;
				it = m_siiWaitingChats.find(sTarget);

				if (it != m_siiWaitingChats.end()) {
					if (!sMessage.Equals("yes"))
						SendToUser(sTarget + "!" + sTarget + "@" +
								CUtils::GetIP(it->second.first),
								"Refusing to accept DCC SCHAT!");
					else
						AcceptSDCC(sTarget, it->second.first, it->second.second);

					m_siiWaitingChats.erase(it);
					return(HALT);
				}
				PutModule("No such SCHAT to [" + sTarget + "]");
			} else
				p->Write(sMessage + "\n");

			return(HALT);
		}
		return(CONTINUE);
	}
Example #8
0
File: schat.cpp Project: clem16/znc
	virtual EModRet OnPrivCTCP(CNick& Nick, CString& sMessage) override
	{
		if (sMessage.Equals("DCC SCHAT ", false, 10)) {
			// chat ip port
			unsigned long iIP = sMessage.Token(3).ToULong();
			unsigned short iPort = sMessage.Token(4).ToUShort();

			if (iIP > 0 && iPort > 0) {
				pair<u_long, u_short> pTmp;
				CString sMask;

				pTmp.first = iIP;
				pTmp.second = iPort;
				sMask = "(s)" + Nick.GetNick() + "!" + "(s)" +
					Nick.GetNick() + "@" + CUtils::GetIP(iIP);

				m_siiWaitingChats["(s)" + Nick.GetNick()] = pTmp;
				SendToUser(sMask, "*** Incoming DCC SCHAT, Accept ? (yes/no)");
				CRemMarkerJob *p = new CRemMarkerJob(this, 60, 1,
						"Remove (s)" + Nick.GetNick(),
						"Removes this nicks entry for waiting DCC.");
				p->SetNick("(s)" + Nick.GetNick());
				AddTimer(p);
				return(HALT);
			}
		}

		return(CONTINUE);
	}
Example #9
0
	void OnModCommand(const CString& sCmdLine) override
	{
		CString sCommand = sCmdLine.Token(0);
		CString sArgs    = sCmdLine.Token(1, true);

		if (sCommand.Equals("dumpbuff")) {
			// for testing purposes - hidden from help
			CString sFile;
			CString sName;
			if (DecryptBuffer(GetPath(sArgs), sFile, sName))
			{
				VCString vsLines;
				VCString::iterator it;

				sFile.Split("\n", vsLines);

				for (it = vsLines.begin(); it != vsLines.end(); ++it) {
					CString sLine(*it);
					sLine.Trim();
					PutModule("[" + sLine + "]");
				}
			}
			PutModule("//!-- EOF " + sArgs);
		} else {
			HandleCommand(sCmdLine);
		}
	}
Example #10
0
	virtual bool OnLoad(const CString & sArgs, CString & sMessage) {
		CString sTarget = GetNV("target");
		if (sTarget.Equals("syslog"))
			m_eLogMode = LOG_TO_SYSLOG;
		else if (sTarget.Equals("both"))
			m_eLogMode = LOG_TO_BOTH;
		else if (sTarget.Equals("file"))
			m_eLogMode = LOG_TO_FILE;
		else
			m_eLogMode = LOG_TO_FILE;

		m_sLogFile = GetSavePath() + "/znc.log";

		Log("Logging started. ZNC PID[" + CString(getpid()) + "] UID/GID[" + CString(getuid()) + ":" + CString(getgid()) + "]");
		return true;
	}
Example #11
0
bool CClient::OnOtherMessage(CMessage& Message) {
    const CString& sCommand = Message.GetCommand();

    if (sCommand.Equals("ZNC")) {
        CString sTarget = Message.GetParam(0);
        CString sModCommand;

        if (sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) {
            sModCommand = Message.GetParams(1);
        } else {
            sTarget = "status";
            sModCommand = Message.GetParams(0);
        }

        if (sTarget.Equals("status")) {
            if (sModCommand.empty())
                PutStatus("Hello. How may I help you?");
            else
                UserCommand(sModCommand);
        } else {
            if (sModCommand.empty())
                CALLMOD(sTarget, this, m_pUser, m_pNetwork,
                        PutModule("Hello. How may I help you?"))
            else
                CALLMOD(sTarget, this, m_pUser, m_pNetwork,
                        OnModCommand(sModCommand))
        }
        return true;
    } else if (sCommand.Equals("ATTACH")) {
Example #12
0
    virtual EModRet OnStatusCommand(CString& sCommand) {
        if (sCommand.Equals("SAMPLE")) {
            PutModule("Hi, I'm your friendly sample module.");
            return HALT;
        }

        return CONTINUE;
    }
Example #13
0
bool CFile::IsDir(const CString& sLongName, bool bUseLstat) {
	if (sLongName.Equals("/"))
		return CFile::FType(sLongName, FT_DIRECTORY, bUseLstat);

	// Some OS don't like trailing slashes for directories
	return CFile::FType(sLongName.TrimRight_n("/"),
			FT_DIRECTORY, bUseLstat);
}
Example #14
0
    virtual EModRet OnInvite(const CNick& Nick, const CString& sChan) {
        if (sChan.Equals("#test")) {
            PutModule(Nick.GetNick() + " invited us to " + sChan + ", ignoring invites to " + sChan);
            return HALT;
        }

        PutModule(Nick.GetNick() + " invited us to " + sChan);
        return CONTINUE;
    }
Example #15
0
    bool SupportsMechanism(const CString& sMechanism) const {
        for (const auto& it : SupportedMechanisms) {
            if (sMechanism.Equals(it.szName)) {
                return true;
            }
        }

        return false;
    }
Example #16
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]");
        }
    }
Example #17
0
	virtual EModRet OnUserRaw(CString& sLine)
	{
		CString sCmd = sLine.Token(0).AsUpper();

		if (!m_pNetwork->GetIRCSock())
			return CONTINUE;

		if (sCmd.Equals("MODE")) {
			// Check if this is a mode request that needs to be handled

			// If there are arguments to a mode change,
			// we must not route it.
			if (!sLine.Token(3, true).empty())
				return CONTINUE;

			// Grab the mode change parameter
			CString sMode = sLine.Token(2);

			// If this is a channel mode request, znc core replies to it
			if (sMode.empty())
				return CONTINUE;

			// Check if this is a mode change or a specific
			// mode request (the later needs to be routed).
			sMode.TrimPrefix("+");
			if (sMode.length() != 1)
				return CONTINUE;

			// Now just check if it's one of the supported modes
			switch (sMode[0]) {
			case 'I':
			case 'b':
			case 'e':
				break;
			default:
				return CONTINUE;
			}

			// Ok, this looks like we should route it.
			// Fall through to the next loop
		}

		for (size_t i = 0; vRouteReplies[i].szRequest != NULL; i++) {
			if (vRouteReplies[i].szRequest == sCmd) {
				struct queued_req req = {
					sLine, vRouteReplies[i].vReplies
				};
				m_vsPending[m_pClient].push_back(req);
				SendRequest();

				return HALTCORE;
			}
		}

		return CONTINUE;
	}
Example #18
0
TEST(StringTest, Cmp) {
    CString s = "Bbb";

    EXPECT_EQ(s, CString("Bbb"));
    EXPECT_LT(CString("Aaa"), s);
    EXPECT_GT(CString("Ccc"), s);
    EXPECT_EQ(s.StrCmp("Bbb"), 0);
    EXPECT_GT(0, s.StrCmp("bbb"));
    EXPECT_LT(0, s.StrCmp("Aaa"));
    EXPECT_GT(0, s.StrCmp("Ccc"));
    EXPECT_EQ(s.CaseCmp("Bbb"), 0);
    EXPECT_EQ(s.CaseCmp("bbb"), 0);
    EXPECT_LT(0, s.CaseCmp("Aaa"));
    EXPECT_GT(0, s.CaseCmp("Ccc"));

    EXPECT_TRUE(s.Equals("bbb"));
    EXPECT_FALSE(s.Equals("bbb", true));
    EXPECT_FALSE(s.Equals("bb"));
}
	EModRet OnUserNotice(CString& sTarget, CString& sMessage)
	{
		if(m_pClient && sTarget.Equals(m_pUser->GetIRCNick().GetNick()) &&
			sMessage.Token(0).Equals("LAGCHK"))
		{
			m_waiting.AddItem(sMessage, m_pClient);
		}

		return CONTINUE;
	}
Example #20
0
	void SetCommandCommand(const CString& sLine) {
		CString sCmd = sLine.Token(1);
		CString sNewCmd = sLine.Token(2, true);
		if (sCmd.Equals("IDENTIFY")) {
			SetNV("IdentifyCmd", sNewCmd);
		} else if (sCmd.Equals("GHOST")) {
			SetNV("GhostCmd", sNewCmd);
		} else if (sCmd.Equals("RECOVER")) {
			SetNV("RecoverCmd", sNewCmd);
		} else if (sCmd.Equals("RELEASE")) {
			SetNV("ReleaseCmd", sNewCmd);
		} else if (sCmd.Equals("GROUP")) {
			SetNV("GroupCmd", sNewCmd);
		} else {
			PutModule("No such editable command. See ViewCommands for list.");
			return;
		}
		PutModule("Ok");
	}
Example #21
0
 void Authenticate(const CString& sLine) {
     if (m_Mechanisms.GetCurrent().Equals("PLAIN") && sLine.Equals("+")) {
         CString sAuthLine = GetNV("username") + '\0' + GetNV("username") +
                             '\0' + GetNV("password");
         sAuthLine.Base64Encode();
         PutIRC("AUTHENTICATE " + sAuthLine);
     } else {
         /* Send blank authenticate for other mechanisms (like EXTERNAL). */
         PutIRC("AUTHENTICATE +");
     }
 }
Example #22
0
File: Chan.cpp Project: BtbN/znc
CChan::CChan(const CString& sName, CIRCNetwork* pNetwork, bool bInConfig,
             CConfig* pConfig)
    : m_bDetached(false),
      m_bIsOn(false),
      m_bAutoClearChanBuffer(pNetwork->GetUser()->AutoClearChanBuffer()),
      m_bInConfig(bInConfig),
      m_bDisabled(false),
      m_bHasBufferCountSet(false),
      m_bHasAutoClearChanBufferSet(false),
      m_sName(sName.Token(0)),
      m_sKey(sName.Token(1)),
      m_sTopic(""),
      m_sTopicOwner(""),
      m_ulTopicDate(0),
      m_ulCreationDate(0),
      m_pNetwork(pNetwork),
      m_Nick(),
      m_uJoinTries(0),
      m_sDefaultModes(""),
      m_msNicks(),
      m_Buffer(),
      m_bModeKnown(false),
      m_mcsModes() {
    if (!m_pNetwork->IsChan(m_sName)) {
        m_sName = "#" + m_sName;
    }

    m_Nick.SetNetwork(m_pNetwork);
    m_Buffer.SetLineCount(m_pNetwork->GetUser()->GetChanBufferSize(), true);

    if (pConfig) {
        CString sValue;
        if (pConfig->FindStringEntry("buffer", sValue))
            SetBufferCount(sValue.ToUInt(), true);
        if (pConfig->FindStringEntry("autoclearchanbuffer", sValue))
            SetAutoClearChanBuffer(sValue.ToBool());
        if (pConfig->FindStringEntry("keepbuffer", sValue))
            // XXX Compatibility crap, added in 0.207
            SetAutoClearChanBuffer(!sValue.ToBool());
        if (pConfig->FindStringEntry("detached", sValue))
            SetDetached(sValue.ToBool());
        if (pConfig->FindStringEntry("disabled", sValue))
            if (sValue.ToBool()) Disable();
        if (pConfig->FindStringEntry("autocycle", sValue))
            if (sValue.Equals("true"))
                CUtils::PrintError(
                    "WARNING: AutoCycle has been removed, instead try -> "
                    "LoadModule = autocycle " +
                    sName);
        if (pConfig->FindStringEntry("key", sValue)) SetKey(sValue);
        if (pConfig->FindStringEntry("modes", sValue)) SetDefaultModes(sValue);
    }
}
Example #23
0
bool CIRCNetwork::DelChan(const CString& sName) {
    for (vector<CChan*>::iterator a = m_vChans.begin(); a != m_vChans.end();
         ++a) {
        if (sName.Equals((*a)->GetName())) {
            delete *a;
            m_vChans.erase(a);
            return true;
        }
    }

    return false;
}
Example #24
0
	virtual EModRet OnRaw(CString& sLine) {
		if (sLine.Equals("ERROR ", false, 6)) {
			//ERROR :Closing Link: nick[24.24.24.24] (Excess Flood)
			//ERROR :Closing Link: nick[24.24.24.24] Killer (Local kill by Killer (reason))
			CString sError(sLine.substr(6));
			if (sError.Left(1) == ":")
				sError.LeftChomp();
			Log("[" + m_pUser->GetUserName() + "/" + m_pNetwork->GetName() + "] disconnected from IRC: " +
			    m_pNetwork->GetCurrentServer()->GetName() + " [" + sError + "]", LOG_NOTICE);
		}
		return CONTINUE;
        }
Example #25
0
void CIRCSock::SendAltNick(const CString& sBadNick) {
    const CString& sLastNick = m_Nick.GetNick();

    // We don't know the maximum allowed nick length yet, but we know which
    // nick we sent last. If sBadNick is shorter than that, we assume the
    // server truncated our nick.
    if (sBadNick.length() < sLastNick.length())
        m_uMaxNickLen = (unsigned int)sBadNick.length();

    unsigned int uMax = m_uMaxNickLen;

    const CString& sConfNick = m_pNetwork->GetNick();
    const CString& sAltNick  = m_pNetwork->GetAltNick();
    CString sNewNick = sConfNick.Left(uMax - 1);

    if (sLastNick.Equals(sConfNick)) {
        if ((!sAltNick.empty()) && (!sConfNick.Equals(sAltNick))) {
            sNewNick = sAltNick;
        } else {
            sNewNick += "-";
        }
    } else if (sLastNick.Equals(sAltNick) && !sAltNick.Equals(sNewNick + "-")) {
        sNewNick += "-";
    } else if (sLastNick.Equals(sNewNick + "-") && !sAltNick.Equals(sNewNick + "|")) {
        sNewNick += "|";
    } else if (sLastNick.Equals(sNewNick + "|") && !sAltNick.Equals(sNewNick + "^")) {
        sNewNick += "^";
    } else if (sLastNick.Equals(sNewNick + "^") && !sAltNick.Equals(sNewNick + "a")) {
        sNewNick += "a";
    } else {
        char cLetter = 0;
        if (sBadNick.empty()) {
            m_pNetwork->PutUser("No free nick available");
            Quit();
            return;
        }

        cLetter = sBadNick.back();

        if (cLetter == 'z') {
            m_pNetwork->PutUser("No free nick found");
            Quit();
            return;
        }

        sNewNick = sConfNick.Left(uMax -1) + ++cLetter;
        if (sNewNick.Equals(sAltNick))
            sNewNick = sConfNick.Left(uMax -1) + ++cLetter;
    }
    PutIRC("NICK " + sNewNick);
    m_Nick.SetNick(sNewNick);
}
Example #26
0
	virtual void OnModCommand(const CString& sCmdLine)
	{
		CString sCommand = sCmdLine.Token(0);
		CString sArgs    = sCmdLine.Token(1, true);

		if (sCommand.Equals("setpass"))
		{
			PutModule("Password set to [" + sArgs + "]");
			m_sPassword = CBlowfish::MD5(sArgs);

		} else if (sCommand.Equals("dumpbuff"))
		{
			CString sFile;
			if (DecryptChannel(sArgs, sFile))
			{
				VCString vsLines;
				VCString::iterator it;

				sFile.Split("\n", vsLines);

				for (it = vsLines.begin(); it != vsLines.end(); ++it) {
					CString sLine(*it);
					sLine.Trim();
					PutModule("[" + sLine + "]");
				}
			}
			PutModule("//!-- EOF " + sArgs);
		} else if (sCommand.Equals("replay"))
		{
			Replay(sArgs);
			PutModule("Replayed " + sArgs);

		} else if (sCommand.Equals("save"))
		{
			SaveBufferToDisk();
			PutModule("Done.");
		} else
			PutModule("Unknown command [" + sCommand + "]");
	}
Example #27
0
	void Skype_GotMessageProperty(uint64_t a_msgID, const CString& a_property, const CString& a_value)
	{
		EnterCriticalSection(&m_rcvdMsgLock);

		try
		{
			if(m_rcvdMsgs.find(a_msgID) != m_rcvdMsgs.end())
			{
				CReceivedSkypeMsg *l_msg = m_rcvdMsgs[a_msgID];

				if(a_property.Equals("BODY"))
				{
					l_msg->body = (l_msg->edited && a_value.empty() ? "[deleted]" : a_value);
				}
				else if(a_property.Equals("TIMESTAMP"))
					l_msg->timestamp = a_value.ToULong();
				if(a_property.Equals("CHATNAME"))
					l_msg->chatName = a_value;
				else if(a_property.Equals("FROM_DISPNAME"))
					l_msg->fromDispname = a_value;
				else if(a_property.Equals("TYPE"))
					l_msg->type = a_value;

				if(l_msg->isComplete())
				{
					if(l_msg->type == "SAID" || l_msg->type == "EMOTED" || l_msg->edited)
					{
						SendSkypeMsgToIRC(l_msg);
					}
					m_rcvdMsgs.erase(m_rcvdMsgs.find(a_msgID));
					delete l_msg;
				}
			}
		}
		catch(...) {}

		LeaveCriticalSection(&m_rcvdMsgLock);
	}
Example #28
0
	virtual void OnModCommand(const CString& sLine) {
		CString sCommand = sLine.Token(0);
		if (sCommand.Equals("TIMERS")) {
			ListTimers();
		}
		else if (sCommand.Equals("SET")) {
			CString sFormat = sLine.Token(1);

			if (!sFormat.empty()) {
				m_sFormat = sFormat;
				SetNV("nick", m_sFormat);
			}

			if (m_pUser) {
				CString sExpanded = GetAwayNick();
				CString sMsg = "AwayNick is set to [" + m_sFormat + "]";

				if (m_sFormat != sExpanded) {
					sMsg += " (" + sExpanded + ")";
				}

				PutModule(sMsg);
			}
		} else if (sCommand.Equals("SHOW")) {
			if (m_pUser) {
				CString sExpanded = GetAwayNick();
				CString sMsg = "AwayNick is set to [" + m_sFormat + "]";

				if (m_sFormat != sExpanded) {
					sMsg += " (" + sExpanded + ")";
				}

				PutModule(sMsg);
			}
		} else if (sCommand.Equals("HELP")) {
			PutModule("Commands are: show, timers, set [awaynick]");
		}
	}
Example #29
0
void CIRCSock::ParseISupport(const CMessage& Message) {
    const VCString vsParams = Message.GetParams();

    for (size_t i = 1; i < vsParams.size() - 1; ++i) {
        const CString& sParam = vsParams[i];
        CString sName = sParam.Token(0, false, "=");
        CString sValue = sParam.Token(1, true, "=");

        if (0 < sName.length() && ':' == sName[0]) {
            break;
        }

        m_mISupport[sName] = sValue;

        if (sName.Equals("PREFIX")) {
            CString sPrefixes = sValue.Token(1, false, ")");
            CString sPermModes = sValue.Token(0, false, ")");
            sPermModes.TrimLeft("(");

            if (!sPrefixes.empty() && sPermModes.size() == sPrefixes.size()) {
                m_sPerms = sPrefixes;
                m_sPermModes = sPermModes;
            }
        } else if (sName.Equals("CHANTYPES")) {
            m_pNetwork->SetChanPrefixes(sValue);
        } else if (sName.Equals("NICKLEN")) {
            unsigned int uMax = sValue.ToUInt();

            if (uMax) {
                m_uMaxNickLen = uMax;
            }
        } else if (sName.Equals("CHANMODES")) {
            if (!sValue.empty()) {
                m_mueChanModes.clear();

                for (unsigned int a = 0; a < 4; a++) {
                    CString sModes = sValue.Token(a, false, ",");

                    for (unsigned int b = 0; b < sModes.size(); b++) {
                        m_mueChanModes[sModes[b]] = (EChanModeArgs) a;
                    }
                }
            }
        } else if (sName.Equals("NAMESX")) {
            if (m_bNamesx)
                continue;
            m_bNamesx = true;
            PutIRC("PROTOCTL NAMESX");
        } else if (sName.Equals("UHNAMES")) {
            if (m_bUHNames)
                continue;
            m_bUHNames = true;
            PutIRC("PROTOCTL UHNAMES");
        }
    }
}
Example #30
0
	virtual EModRet OnRaw(CString& sLine) {
		CString cmd = sLine.Token(1, false);
		if (cmd.Equals("AWAY")) {
			if (m_pNetwork && m_pNetwork->GetIRCSock() && m_pNetwork->GetIRCSock()->IsCapAccepted(m_sCapability)) {
				vector<CClient*> vClients = m_pNetwork->GetClients();
				for (std::vector<CClient*>::size_type i = 0; i != vClients.size(); i++) {
					if (vClients[i] != m_pClient && vClients[i]->IsCapEnabled(m_sCapability)) {
						m_pNetwork->PutUser(sLine, vClients[i], NULL);
					}
				}
			}
			return HALTCORE;
		}
		return CONTINUE;
	}