Skip to content

Fix for znc-clientbuffer#13 #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 2 additions & 37 deletions clientbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ class CClientBufferMod : public CModule
#if ZNC17
virtual EModRet OnUserRawMessage(CMessage& Message) override;
virtual EModRet OnUserTextMessage(CTextMessage& Message) override;
virtual EModRet OnSendToClientMessage(CMessage& Message) override;
#else
virtual EModRet OnUserRaw(CString& line) override;
virtual EModRet OnSendToClient(CString& line, CClient& client) override;
#endif

virtual EModRet OnChanBufferStarting(CChan& chan, CClient& client) override;
Expand Down Expand Up @@ -256,8 +254,7 @@ CModule::EModRet CClientBufferMod::OnUserRawMessage(CMessage& Message)
if (!client)
return CONTINUE;

if (WantMessageType(Message.GetType()))
UpdateTimestamp(client->GetIdentifier(), GetTarget(Message), Message.GetTime());
UpdateTimestamp(client->GetIdentifier(), GetTarget(Message), Message.GetTime());

return CONTINUE;
}
Expand All @@ -267,7 +264,7 @@ CModule::EModRet CClientBufferMod::OnUserRaw(CString& line)
CClient* client = GetClient();
if (client) {
CNick nick; CString cmd, target;
if (ParseMessage(line, nick, cmd, target) && WantMessageCmd(cmd))
if (ParseMessage(line, nick, cmd, target))
UpdateTimestamp(client, target);
}
return CONTINUE;
Expand All @@ -287,38 +284,6 @@ CModule::EModRet CClientBufferMod::OnUserTextMessage(CTextMessage& Message)
}
#endif

/// ZNC callback (called when ZNC sends a raw traffic line to a client).
/// Updates the client "last seen" timestamp.
#if ZNC17
CModule::EModRet CClientBufferMod::OnSendToClientMessage(CMessage& Message)
{
// make sure not to update the timestamp for a channel when joining it
if (!WantMessageType(Message.GetType()))
return CONTINUE;

// make sure not to update the timestamp for a channel when attaching it
CChan* chan = Message.GetChan();
if (!chan || !chan->IsDetached())
UpdateTimestamp(Message.GetClient()->GetIdentifier(), GetTarget(Message), Message.GetTime());
return CONTINUE;
}
#else
CModule::EModRet CClientBufferMod::OnSendToClient(CString& line, CClient& client)
{
CIRCNetwork* network = GetNetwork();
if (network) {
CNick nick; CString cmd, target;
// make sure not to update the timestamp for a channel when attaching it
if (ParseMessage(line, nick, cmd, target)) {
CChan* chan = network->FindChan(target);
if (!chan || !chan->IsDetached())
UpdateTimestamp(&client, target);
}
}
return CONTINUE;
}
#endif

/// ZNC callback (called before a channel buffer is played back to a client).
/// Filters out the "Buffer Playback..." message as necessary.
CModule::EModRet CClientBufferMod::OnChanBufferStarting(CChan& chan, CClient& client)
Expand Down