diff options
author | walliski <walliski@users.noreply.github.com> | 2015-10-23 19:26:14 +0300 |
---|---|---|
committer | walliski <walliski@users.noreply.github.com> | 2015-10-23 19:26:14 +0300 |
commit | 494f8981e665f39008e39e6a09f981b5d2588948 (patch) | |
tree | fcfcd30e443726974fee5b3a4269f762190b7ab1 | |
parent | e80558c2217c6589870090ecf85fd36946bb3278 (diff) | |
parent | 3040f6d514ae98b13e52250dae9ed86f27fc816d (diff) |
Merge pull request #11 from FruitieX/fixes
Show log file name and print messages to query window
-rw-r--r-- | backlog.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/backlog.cpp b/backlog.cpp index 619de29..39ea131 100644 --- a/backlog.cpp +++ b/backlog.cpp @@ -136,7 +136,13 @@ void CBacklogMod::OnModCommand(const CString& sCommand) { CString Line; std::vector<CString> Lines; + if (LogFile.GetShortName() == "." || LogFile.GetShortName() == "..") { + continue; + } + if (LogFile.Open()) { + Lines.push_back("[00:00:00] <***> File: " + LogFile.GetShortName()); //Parse name to get date prettier? + printedLines--; while (LogFile.ReadLine(Line)) { try { // is line a part/join/rename etc message (nick ***), do we want to print it? @@ -173,11 +179,17 @@ void CBacklogMod::OnModCommand(const CString& sCommand) { } } - if(printedLines == 0) { + if(printedLines <= 0) { m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + Channel + " :No log files found for window " + Channel + " in " + DirPath + "/", GetClient()); return; } else { - m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + Channel + " :Backlog playback...", GetClient()); + //RFC prefixes: # ! & + + if (Channel.StartsWith("#") || Channel.StartsWith("&") || + Channel.StartsWith("!") || Channel.StartsWith("+")) { //Normal channel + m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + Channel + " :Backlog playback...", GetClient()); + } else { + m_pNetwork->PutUser(":" + Channel + "!znc@znc.in PRIVMSG " + Channel + " :<***> Backlog playback...", GetClient()); + } } // now actually print @@ -206,13 +218,26 @@ void CBacklogMod::OnModCommand(const CString& sCommand) { MessageType = "NOTICE "; } - m_pNetwork->PutUser(":" + Nick + "!znc@znc.in " + MessageType + Channel + " :" + Line.substr(0, FirstWS) + Line.substr(FirstWS + NickLen + 1, Line.npos), GetClient()); + //RFC prefixes: # ! & + + if (Channel.StartsWith("#") || Channel.StartsWith("&") || + Channel.StartsWith("!") || Channel.StartsWith("+")) { //Normal channel + m_pNetwork->PutUser(":" + Nick + "!znc@znc.in " + MessageType + Channel + " :" + Line.substr(0, FirstWS) + Line.substr(FirstWS + NickLen + 1, Line.npos), GetClient()); + } else { //Privmsg + m_pNetwork->PutUser(":" + Channel + "!znc@znc.in " + MessageType + Channel + " :" + Line.substr(0, FirstWS) + " <" + Nick + ">" + Line.substr(FirstWS + NickLen + 1, Line.npos), GetClient()); + } + + } catch (int e) { PutModule("Malformed log line! " + Line); } } - m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + Channel + " :" + "Playback Complete.", GetClient()); + if (Channel.StartsWith("#") || Channel.StartsWith("&") || + Channel.StartsWith("!") || Channel.StartsWith("+")) { //Normal channel + m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + Channel + " :" + "Playback Complete.", GetClient()); + } else { + m_pNetwork->PutUser(":" + Channel + "!znc@znc.in PRIVMSG " + Channel + " :<***> " + "Playback Complete.", GetClient()); + } } template<> void TModInfo<CBacklogMod>(CModInfo& Info) { |