CIgnore(const CString& sHostMask, const CString& sType) { CNick Nick; Nick.Parse(sHostMask); m_sHostMask = ((Nick.GetNick().empty()) ? "*" : Nick.GetNick()); m_sHostMask += "!"; m_sHostMask += (Nick.GetIdent().empty()) ? "*" : Nick.GetIdent(); m_sHostMask += "@"; m_sHostMask += (Nick.GetHost().empty()) ? "*" : Nick.GetHost(); m_sType = sType; }
EModRet OnInvite(const CNick& Nick, const CString& sChan) override { if (!Nick.NickEquals("Q") || !Nick.GetHost().Equals("CServe.quakenet.org")) return CONTINUE; if (m_bJoinOnInvite) GetNetwork()->AddChan(sChan, false); return CONTINUE; }
void CNick::Clone(const CNick& SourceNick) { SetNick(SourceNick.GetNick()); SetIdent(SourceNick.GetIdent()); SetHost(SourceNick.GetHost()); m_sChanPerms = SourceNick.m_sChanPerms; m_pNetwork = SourceNick.m_pNetwork; }
void CLogMod::OnQuit(const CNick& Nick, const CString& sMessage, const vector<CChan*>& vChans) { if (!HasNV("quits") || GetNV("quits").ToBool()) { for (CChan* pChan : vChans) PutLog("*** Quits: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ") (" + sMessage + ")", *pChan); } }
// #124: OnChanMsg(): nick doesn't have perms static void FixupChanNick(CNick& Nick, CChan* pChan) { // A channel nick has up-to-date channel perms, but might be // lacking (usernames-in-host) the associated ident & host. // An incoming message, on the other hand, has normally a full // nick!ident@host prefix. Sync the two so that channel nicks // get the potentially missing piece of info and module hooks // get the perms. CNick* pChanNick = pChan->FindNick(Nick.GetNick()); if (pChanNick) { if (!Nick.GetIdent().empty()) { pChanNick->SetIdent(Nick.GetIdent()); } if (!Nick.GetHost().empty()) { pChanNick->SetHost(Nick.GetHost()); } Nick.Clone(*pChanNick); } }
void HandleMessage(CNick& Nick, const CString& sMessage) { if (!m_sAuth.empty() && Nick.GetNick().CaseCmp("Q") == 0 && Nick.GetHost().CaseCmp("CServe.quakenet.org") == 0 && sMessage.find("AUTH") != CString::npos && sMessage.find("authenticate") != CString::npos) { PutIRC("PRIVMSG [email protected] :auth " + m_sAuth); } }
virtual void OnKick(const CNick& OpNick, const CString& sKickedNick, CChan& Channel, const CString& sMessage) { CString sOpNick = TclEscape(CString(OpNick.GetNick())); CString sNick = TclEscape(sKickedNick); CString sOpHost = TclEscape(CString(OpNick.GetIdent() + "@" + OpNick.GetHost())); CString sCommand = "Binds::ProcessKick {" + sOpNick + "} {" + sOpHost + "} - {" + Channel.GetName() + "} {" + sNick + "} {" + sMessage + "}"; i = Tcl_Eval(interp, sCommand.c_str()); if (i != TCL_OK) { PutModule(Tcl_GetStringResult(interp)); } }
virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage) { CString sMes = TclEscape(sMessage); CString sNick = TclEscape(CString(Nick.GetNick())); CString sHost = TclEscape(CString(Nick.GetIdent() + "@" + Nick.GetHost())); CString sCommand = "Binds::ProcessMsgm {" + sNick + "} {" + sHost + "} - {" + sMes + "}"; i = Tcl_Eval(interp, sCommand.c_str()); if (i != TCL_OK) { PutModule(Tcl_GetStringResult(interp)); } return CONTINUE; }
EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage) override { CString sMes = TclEscape(sMessage); CString sNick = TclEscape(CString(Nick.GetNick())); CString sHost = TclEscape(CString(Nick.GetIdent() + "@" + Nick.GetHost())); CString sChannel = TclEscape(CString(Channel.GetName())); CString sCommand = "Binds::ProcessPubm {" + sNick + "} {" + sHost + "} - {" + sChannel + "} {" + sMes + "}"; i = Tcl_Eval(interp, sCommand.c_str()); if (i != TCL_OK) { PutModule(Tcl_GetStringResult(interp)); } return CONTINUE; }
virtual void OnNick(const CNick& OldNick, const CString& sNewNick, const vector<CChan*>& vChans) { CString sOldNick = TclEscape(CString(OldNick.GetNick())); CString sNewNickTmp = TclEscape(sNewNick); CString sHost = TclEscape(CString(OldNick.GetIdent() + "@" + OldNick.GetHost())); CString sCommand; // Nick change is triggered for each common chan so that binds can be chan specific unsigned int nLength = vChans.size(); for (unsigned int n = 0; n < nLength; n++) { sCommand = "Binds::ProcessNick {" + sOldNick + "} {" + sHost + "} - {" + vChans[n]->GetName() + "} {" + sNewNickTmp + "}"; i = Tcl_Eval(interp, sCommand.c_str()); if (i != TCL_OK) { PutModule(Tcl_GetStringResult(interp)); } } }
void CLogMod::OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage) { PutLog("*** Parts: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ") (" + sMessage + ")", Channel); }
void CLogMod::OnJoin(const CNick& Nick, CChan& Channel) { PutLog("*** Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ")", Channel); }
void CLogMod::OnQuit(const CNick& Nick, const CString& sMessage, const vector<CChan*>& vChans) { for (std::vector<CChan*>::const_iterator pChan = vChans.begin(); pChan != vChans.end(); ++pChan) PutLog("*** Quits: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ") (" + sMessage + ")", **pChan); }
EModRet HandleMessage(const CNick& Nick, CString sMessage) { if (!Nick.NickEquals("Q") || !Nick.GetHost().Equals("CServe.quakenet.org")) return CONTINUE; sMessage.Trim(); #if Q_DEBUG_COMMUNICATION PutModule("[ZNC <-- Q] " + sMessage); #endif // WHOAMI if (sMessage.find("WHOAMI is only available to authed users") != CString::npos) { m_bAuthed = false; Auth(); m_bCatchResponse = m_bRequestedWhoami; } else if (sMessage.find("Information for user") != CString::npos) { m_bAuthed = true; m_msChanModes.clear(); m_bCatchResponse = m_bRequestedWhoami; m_bRequestedWhoami = true; } else if (m_bRequestedWhoami && sMessage.WildCmp("#*")) { CString sChannel = sMessage.Token(0); CString sFlags = sMessage.Token(1, true).Trim_n().TrimLeft_n("+"); m_msChanModes[sChannel] = sFlags; } else if (m_bRequestedWhoami && m_bCatchResponse && (sMessage.Equals("End of list.") || sMessage.Equals( "account, or HELLO to create an account."))) { m_bRequestedWhoami = m_bCatchResponse = false; return HALT; } // AUTH else if (sMessage.Equals("Username or password incorrect.")) { m_bAuthed = false; PutModule("Auth failed: " + sMessage); return HALT; } else if (sMessage.WildCmp("You are now logged in as *.")) { m_bAuthed = true; PutModule("Auth successful: " + sMessage); WhoAmI(); return HALT; } else if (m_bRequestedChallenge && sMessage.Token(0).Equals("CHALLENGE")) { m_bRequestedChallenge = false; if (sMessage.find("not available once you have authed") != CString::npos) { m_bAuthed = true; } else { if (sMessage.find("HMAC-SHA-256") != CString::npos) { ChallengeAuth(sMessage.Token(1)); } else { PutModule( "Auth failed: Q does not support HMAC-SHA-256 for " "CHALLENGEAUTH, falling back to standard AUTH."); SetUseChallenge(false); Auth(); } } return HALT; } // prevent buffering of Q's responses return !m_bCatchResponse && GetUser()->IsUserAttached() ? CONTINUE : HALT; }
virtual void OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage) { PutModule("* Parts: " + Nick.GetNick() + " (" + Nick.GetIdent() + "!" + Nick.GetHost() + ")"); }
virtual void OnJoin(const CNick& Nick, CChan& Channel) { PutModule("* Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "!" + Nick.GetHost() + ")"); }
virtual void OnQuit(const CNick& Nick, const CString& sMessage, const vector<CChan*>& vChans) { PutModule("* Quits: " + Nick.GetNick() + " (" + Nick.GetIdent() + "!" + Nick.GetHost() + ") (" + sMessage + ")"); }
void CLogMod::OnJoin(const CNick& Nick, CChan& Channel) { if (!HasNV("joins") || GetNV("joins").ToBool()) PutLog("*** Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ")", Channel); }