summaryrefslogtreecommitdiff
path: root/backlog.cpp
diff options
context:
space:
mode:
authorRasmus Eskola <fruitiex@gmail.com>2013-08-09 13:32:20 +0300
committerRasmus Eskola <fruitiex@gmail.com>2013-08-09 13:32:20 +0300
commit2fe8b601d8dbf1bfe01a2101699b3f1ab63188f1 (patch)
tree56659045953bf0f4e04e41f68a0fe3c327edb283 /backlog.cpp
parentaf90efae817fb90b4d6078a9c758a089c3f5bbc6 (diff)
cleanup
Diffstat (limited to 'backlog.cpp')
-rw-r--r--backlog.cpp67
1 files changed, 28 insertions, 39 deletions
diff --git a/backlog.cpp b/backlog.cpp
index 77765e1..795c206 100644
--- a/backlog.cpp
+++ b/backlog.cpp
@@ -19,59 +19,48 @@
#include <znc/Chan.h>
#include <znc/Modules.h>
-using std::vector;
-
-
class CBacklogMod : public CModule {
public:
MODCONSTRUCTOR(CBacklogMod) {}
- virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
- PutModule("I'm being loaded with the arguments: [" + sArgs + "]");
- //AddTimer(new CSampleTimer(this, 300, 0, "Sample", "Sample timer for sample things."));
- //AddTimer(new CSampleTimer(this, 5, 20, "Another", "Another sample timer."));
- //AddTimer(new CSampleTimer(this, 25000, 5, "Third", "A third sample timer."));
- return true;
- }
-
- virtual ~CBacklogMod() {
- PutModule("I'm being unloaded!");
- }
+ virtual bool OnLoad(const CString& sArgs, CString& sMessage);
+ virtual ~CBacklogMod();
+ virtual void OnModCommand(const CString& sCommand);
- virtual bool OnBoot() {
- // This is called when the app starts up (only modules that are loaded in the config will get this event)
- return true;
- }
+private:
+ CString LogPath;
+};
+bool CBacklogMod::OnLoad(const CString& sArgs, CString& sMessage) {
+ PutModule("I'm being loaded with the arguments: [" + sArgs + "]");
+ return true;
+}
- virtual void OnModCommand(const CString& sCommand) {
- /*
- if (sCommand.Equals("TIMERS")) {
- ListTimers();
- }
- */
- // TODO: sanity check on file path, see log.cpp
+CBacklogMod::~CBacklogMod() {
+ PutModule("I'm being unloaded!");
+}
- CFile LogFile(sCommand);
- CString Line;
+void CBacklogMod::OnModCommand(const CString& sCommand) {
+ CFile LogFile(sCommand);
+ CString Line;
- if (LogFile.Open()) {
- while (LogFile.ReadLine(Line)) {
- PutModule(Line);
- }
- } else {
- PutModule("Could not open log file [" + sCommand + "]: " + strerror(errno));
+ if (LogFile.Open()) {
+ while (LogFile.ReadLine(Line)) {
+ PutModule(Line);
}
-
- LogFile.Close();
+ } else {
+ PutModule("Could not open log file [" + sCommand + "]: " + strerror(errno));
}
-};
+
+ LogFile.Close();
+}
template<> void TModInfo<CBacklogMod>(CModInfo& Info) {
- Info.SetWikiPage("sample");
+ Info.AddType(CModInfo::NetworkModule);
+ Info.AddType(CModInfo::GlobalModule);
+ Info.SetWikiPage("backlog");
+ Info.SetArgsHelpText("Takes path to logs as argument, use keywords: $USER, $NETWORK and $WINDOW");
Info.SetHasArgs(true);
- Info.SetArgsHelpText("Takes %Channelname% and %number of lines% as arguments");
}
NETWORKMODULEDEFS(CBacklogMod, "Module for getting the last X lines of a channels log.")
-