summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Eskola <fruitiex@gmail.com>2013-08-10 17:50:27 +0300
committerRasmus Eskola <fruitiex@gmail.com>2013-08-10 17:50:27 +0300
commit93052d022af8ddb189b56f24f2674905aa65a914 (patch)
tree995567346ebea1197887721472780bb8d97387ff
parent064ecd2d9e229f091714687ed65588f77e68183f (diff)
check if we have joined a window, if so then print log there, otherwise
print to *backlog
-rw-r--r--backlog.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/backlog.cpp b/backlog.cpp
index 590d15d..05bcb6f 100644
--- a/backlog.cpp
+++ b/backlog.cpp
@@ -33,6 +33,7 @@ public:
virtual bool OnLoad(const CString& sArgs, CString& sMessage);
virtual ~CBacklogMod();
virtual void OnModCommand(const CString& sCommand);
+ bool inChan(const CString& Chan);
private:
CString LogPath;
@@ -152,14 +153,16 @@ void CBacklogMod::OnModCommand(const CString& sCommand) {
}
}
+ bool isInChan = CBacklogMod::inChan(Channel);
+
// now actually print
for (std::vector<CString>::reverse_iterator it = LinesToPrint.rbegin(); it != LinesToPrint.rend(); ++it) {
- // if(channel has been joined) {
+ if(isInChan) {
CString Nick = "foo";
m_pNetwork->PutUser(":" + Nick + "!znc@znc.in PRIVMSG " + Channel + " :" + *it, GetClient());
- // } else {
- // PutModule(*it);
- // }
+ } else {
+ PutModule(*it);
+ }
}
if(printedLines == 0) {
@@ -167,6 +170,21 @@ void CBacklogMod::OnModCommand(const CString& sCommand) {
}
}
+bool CBacklogMod::inChan(const CString& Chan) {
+ const std::vector <CChan*>& vChans (m_pNetwork->GetChans());
+
+ for (std::vector<CChan*>::const_iterator it = vChans.begin(); it != vChans.end(); ++it) {
+ CChan *curChan = *it;
+ if(Chan.StrCmp(curChan->GetName()) == 0) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
template<> void TModInfo<CBacklogMod>(CModInfo& Info) {
Info.AddType(CModInfo::NetworkModule);
Info.AddType(CModInfo::GlobalModule);