Added DoNotTrack command which makes it so you can have a connection on your phone and tell LogSQL to not track when that session disconnects so once you get on your computer, you can re-read everything.

This commit is contained in:
GRMrGecko 2012-02-18 09:13:05 -06:00
parent b6079d0fc7
commit 8b8e4be17f
2 changed files with 52 additions and 4 deletions

View File

@ -41,9 +41,12 @@ public:
AddCommand("ReplayAll", static_cast<CModCommand::ModCmdFunc>(&CLogMySQL::ReplayAllCommand), "[1|0]", "Replay all messages stored.");
AddCommand("LogLimit", static_cast<CModCommand::ModCmdFunc>(&CLogMySQL::LogLimitCommand), "[0-9]+", "Limit the amount of items to store into the log.");
AddCommand("LogLevel", static_cast<CModCommand::ModCmdFunc>(&CLogMySQL::LogLevelCommand), "[0-4]", "Log level.");
AddCommand("AddIgnore", static_cast<CModCommand::ModCmdFunc>(&CLogMySQL::AddIgnoreCommand), "Type[nick|chan] Target", "Add to ignore list.");
AddCommand("RemoveIgnore", static_cast<CModCommand::ModCmdFunc>(&CLogMySQL::RemoveIgnoreCommand), "Type[nick|chan] Target", "Remove from ignore list.");
AddCommand("IgnoreList", static_cast<CModCommand::ModCmdFunc>(&CLogMySQL::IgnoreListCommand), "", "View what is currently ignored.");
AddCommand("DoNotTrack", static_cast<CModCommand::ModCmdFunc>(&CLogMySQL::DoNotTrack), "", "Adds the current session to the do not track disconnect list.");
}
void HostCommand(const CString &sLine) {
@ -282,6 +285,18 @@ public:
}
}
void DoNotTrack(const CString &sLine) {
bool tracking = true;
for (vector<CClient *>::iterator it=doNotTrackClient.begin(); it<doNotTrackClient.end(); it++) {
if (*it==m_pClient) {
tracking = false;
break;
}
}
if (tracking)
doNotTrackClient.push_back(m_pClient);
}
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
connected = true;
databaseConnected = false;
@ -1067,10 +1082,17 @@ public:
}
virtual void OnClientDisconnect() {
if (!m_pNetwork->IsUserAttached()) {
SetSetting("clientDisconnected",GetUNIXTime());
bool track = true;
for (vector<CClient *>::iterator it=doNotTrackClient.begin(); it<doNotTrackClient.end(); it++) {
if (*it==m_pClient) {
doNotTrackClient.erase(it);
track = false;
break;
}
}
if (track)
SetSetting("clientDisconnected",GetUNIXTime());
}
void Replay() {
if (!databaseConnected)
@ -1243,6 +1265,8 @@ private:
vector<CString> nickIgnoreList;
vector<CString> chanIgnoreList;
vector<CClient *> doNotTrackClient;
};
template<> void TModInfo<CLogMySQL>(CModInfo& Info) {

View File

@ -34,9 +34,12 @@ public:
AddCommand("ReplayAll", static_cast<CModCommand::ModCmdFunc>(&CLogSQLite::ReplayAllCommand), "[1|0]", "Replay all messages stored.");
AddCommand("LogLimit", static_cast<CModCommand::ModCmdFunc>(&CLogSQLite::LogLimitCommand), "[0-9]+", "Limit the amount of items to store into the log.");
AddCommand("LogLevel", static_cast<CModCommand::ModCmdFunc>(&CLogSQLite::LogLevelCommand), "[0-4]", "Log level.");
AddCommand("AddIgnore", static_cast<CModCommand::ModCmdFunc>(&CLogSQLite::AddIgnoreCommand), "Type[nick|chan] Target", "Add to ignore list.");
AddCommand("RemoveIgnore", static_cast<CModCommand::ModCmdFunc>(&CLogSQLite::RemoveIgnoreCommand), "Type[nick|chan] Target", "Remove from ignore list.");
AddCommand("IgnoreList", static_cast<CModCommand::ModCmdFunc>(&CLogSQLite::IgnoreListCommand), "", "View what is currently ignored.");
AddCommand("DoNotTrack", static_cast<CModCommand::ModCmdFunc>(&CLogSQLite::DoNotTrack), "", "Adds the current session to the do not track disconnect list.");
}
void ReplayCommand(const CString &sLine) {
@ -195,6 +198,18 @@ public:
}
}
void DoNotTrack(const CString &sLine) {
bool tracking = true;
for (vector<CClient *>::iterator it=doNotTrackClient.begin(); it<doNotTrackClient.end(); it++) {
if (*it==m_pClient) {
tracking = false;
break;
}
}
if (tracking)
doNotTrackClient.push_back(m_pClient);
}
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
connected = true;
@ -785,10 +800,17 @@ public:
}
virtual void OnClientDisconnect() {
if (!m_pNetwork->IsUserAttached()) {
SetSetting("clientDisconnected",GetUNIXTime());
bool track = true;
for (vector<CClient *>::iterator it=doNotTrackClient.begin(); it<doNotTrackClient.end(); it++) {
if (*it==m_pClient) {
doNotTrackClient.erase(it);
track = false;
break;
}
}
if (track)
SetSetting("clientDisconnected",GetUNIXTime());
}
void Replay() {
PutUser(":*LogSQLite!LogSQLite@znc.in NOTICE "+m_pNetwork->GetIRCNick().GetNickMask()+" :Buffer Playback...");
@ -909,6 +931,8 @@ private:
vector<CString> nickIgnoreList;
vector<CString> chanIgnoreList;
vector<CClient *> doNotTrackClient;
};
template<> void TModInfo<CLogSQLite>(CModInfo& Info) {