From 43534a1d75afe6b916ac157b7f3a706a45c43d2c Mon Sep 17 00:00:00 2001 From: Rasmus Eskola Date: Thu, 14 Aug 2014 12:54:41 +0300 Subject: try printing privmsgs to the right place --- backlog.cpp | 52 ++++++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) (limited to 'backlog.cpp') diff --git a/backlog.cpp b/backlog.cpp index dd60ccc..b190c07 100644 --- a/backlog.cpp +++ b/backlog.cpp @@ -176,50 +176,38 @@ void CBacklogMod::OnModCommand(const CString& sCommand) { } } - bool isInChan = CBacklogMod::inChan(Channel); - if(printedLines == 0) { PutModule("No log files found for window " + Channel + " in " + DirPath + "/"); return; - } else if (isInChan) { - m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + Channel + " :Backlog playback...", GetClient()); } else { - PutModule("*** Backlog playback..."); + m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + Channel + " :Backlog playback...", GetClient()); } // now actually print for (std::vector::reverse_iterator it = LinesToPrint.rbegin(); it != LinesToPrint.rend(); ++it) { - if(isInChan) { - CString Line = *it; - size_t FirstWS = Line.find_first_of(' '); // position of first whitespace char in line - size_t NickLen = 3; - CString Nick = "***"; - - try { - // a log line looks like: [HH:MM:SS] Message - // < and > are illegal characters in nicknames, so we can - // search for these - if(Line.at(FirstWS + 1) == '<') { // normal message - // nicklen includes surrounding < > - NickLen = Line.find_first_of('>') - Line.find_first_of('<') + 1; - // but we don't want them in Nick so subtract by two - Nick = Line.substr(FirstWS + 2, NickLen - 2); - } - - m_pNetwork->PutUser(":" + Nick + "!znc@znc.in PRIVMSG " + Channel + " :" + Line.substr(0, FirstWS) + Line.substr(FirstWS + NickLen + 1, Line.npos), GetClient()); - } catch (int e) { - PutModule("Malformed log line! " + Line); + CString Line = *it; + size_t FirstWS = Line.find_first_of(' '); // position of first whitespace char in line + size_t NickLen = 3; + CString Nick = "***"; + + try { + // a log line looks like: [HH:MM:SS] Message + // < and > are illegal characters in nicknames, so we can + // search for these + if(Line.at(FirstWS + 1) == '<') { // normal message + // nicklen includes surrounding < > + NickLen = Line.find_first_of('>') - Line.find_first_of('<') + 1; + // but we don't want them in Nick so subtract by two + Nick = Line.substr(FirstWS + 2, NickLen - 2); } - } else { - PutModule(*it); + + m_pNetwork->PutUser(":" + Nick + "!znc@znc.in PRIVMSG " + Channel + " :" + Line.substr(0, FirstWS) + Line.substr(FirstWS + NickLen + 1, Line.npos), GetClient()); + } catch (int e) { + PutModule("Malformed log line! " + Line); } } - if (isInChan) { - m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + Channel + " :" + "Playback Complete.", GetClient()); - } else { - PutModule("*** Playback Complete."); - } + m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + Channel + " :" + "Playback Complete.", GetClient()); } bool CBacklogMod::inChan(const CString& Chan) { -- cgit v1.2.3