summaryrefslogtreecommitdiff
path: root/backlog.cpp
diff options
context:
space:
mode:
authorRasmus Eskola <fruitiex@gmail.com>2013-08-09 14:45:39 +0300
committerRasmus Eskola <fruitiex@gmail.com>2013-08-09 14:45:39 +0300
commit9a08449082854572dc39fe26a559fbe22e6cda3a (patch)
treeb572c5a69c6e14bcce255e1ecf751fe34bff21b7 /backlog.cpp
parent2fe8b601d8dbf1bfe01a2101699b3f1ab63188f1 (diff)
handle "help" and "logpath" commands, set logpath if module started with
arguments
Diffstat (limited to 'backlog.cpp')
-rw-r--r--backlog.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/backlog.cpp b/backlog.cpp
index 795c206..e5b3849 100644
--- a/backlog.cpp
+++ b/backlog.cpp
@@ -22,17 +22,36 @@
class CBacklogMod : public CModule {
public:
MODCONSTRUCTOR(CBacklogMod) {}
+ /*
+ AddHelpCommand();
+ AddCommand("LogPath", static_cast<CModCommand::ModCmdFunc>(&CBacklogMod::SetLogPath),
+ "<path>");
+ AddCommand("Get", static_cast<CModCommand::ModCmdFunc>(&CBacklogMod::SetLogPath),
+ }
+ */
virtual bool OnLoad(const CString& sArgs, CString& sMessage);
virtual ~CBacklogMod();
virtual void OnModCommand(const CString& sCommand);
+ virtual void SetLogPath(const CString& Path);
private:
CString LogPath;
};
bool CBacklogMod::OnLoad(const CString& sArgs, CString& sMessage) {
+ LogPath = sArgs;
PutModule("I'm being loaded with the arguments: [" + sArgs + "]");
+
+ if(LogPath.empty()) {
+ LogPath = GetNV("LogPath");
+ if(LogPath.empty()) {
+ // TODO: guess logpath
+
+ }
+ } else {
+ SetNV("LogPath", LogPath);
+ }
return true;
}
@@ -41,6 +60,22 @@ CBacklogMod::~CBacklogMod() {
}
void CBacklogMod::OnModCommand(const CString& sCommand) {
+ if (sCommand.Token(0).CaseCmp("help") == 0) {
+ // TODO: help text, look how AddHelpCommand() does it in other ZNC code
+ PutModule("Help");
+ return;
+ }
+ else if (sCommand.Token(0).CaseCmp("logpath") == 0) {
+ CString Args = sCommand.Token(1, true);
+ SetNV("LogPath", Args);
+ PutModule("LogPath set to: " + Args);
+ return;
+ }
+
+ CString User;
+ CString Network;
+ CString Channel;
+
CFile LogFile(sCommand);
CString Line;
@@ -55,11 +90,15 @@ void CBacklogMod::OnModCommand(const CString& sCommand) {
LogFile.Close();
}
+void CBacklogMod::SetLogPath(const CString& Path) {
+ SetNV("LogPath", LogPath);
+}
+
template<> void TModInfo<CBacklogMod>(CModInfo& Info) {
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.SetArgsHelpText("Takes as optional argument (and if given, sets) the log path, use keywords: $USER, $NETWORK and $WINDOW");
Info.SetHasArgs(true);
}