Skip to content

Instantly share code, notes, and snippets.

@amyreese
Created September 9, 2011 14:02
Show Gist options
  • Save amyreese/1206300 to your computer and use it in GitHub Desktop.
Save amyreese/1206300 to your computer and use it in GitHub Desktop.
Query Buffering Patch for ZNC
This patch make ZNC query buffering behave the way I like, as I use
multiple clients and still want the query buffer to be filled and replayed
for the newly connecting client.
diff -rup znc-0.074/IRCSock.cpp znc/IRCSock.cpp
--- znc-0.074/IRCSock.cpp 2009-06-29 13:26:19 +0200
+++ znc/IRCSock.cpp 2009-08-26 11:30:56 +0200
@@ -724,21 +724,14 @@ bool CIRCSock::OnGeneralCTCP(CNick& Nick
bool CIRCSock::OnPrivNotice(CNick& Nick, CString& sMessage) {
MODULECALL(OnPrivNotice(Nick, sMessage), m_pUser, NULL, return true);
- if (!m_pUser->IsUserAttached()) {
- // If the user is detached, add to the buffer
- m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " NOTICE ", " :" + m_pUser->AddTimestamp(sMessage));
- }
+ m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " NOTICE ", " :" + m_pUser->AddTimestamp(sMessage));
return false;
}
bool CIRCSock::OnPrivMsg(CNick& Nick, CString& sMessage) {
MODULECALL(OnPrivMsg(Nick, sMessage), m_pUser, NULL, return true);
-
- if (!m_pUser->IsUserAttached()) {
- // If the user is detached, add to the buffer
- m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " PRIVMSG ", " :" + m_pUser->AddTimestamp(sMessage));
- }
+ m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " PRIVMSG ", " :" + m_pUser->AddTimestamp(sMessage));
return false;
}
diff -rup znc-0.074/User.cpp znc/User.cpp
--- znc-0.074/User.cpp 2009-07-22 18:54:52 +0200
+++ znc/User.cpp 2009-08-26 11:30:56 +0200
@@ -290,6 +290,7 @@ void CUser::UserConnected(CClient* pClie
MODULECALL(OnPrivBufferPlayLine(*pClient, sBufLine), this, NULL, continue);
pClient->PutClient(sBufLine);
}
+ m_QueryBuffer.Clear();
// Tell them why they won't connect
if (!GetIRCConnectEnabled())
@ksx4system
Copy link

some errors while trying to patch latest stable (0.202, didn't tried git snapshot):

[ksx4system@ancon ~/temp/znc-0.202]$ patch -p1 < znc-query-buffering.patch
Hmm... Looks like a unified diff to me...

The text leading up to this was:

|This patch make ZNC query buffering behave the way I like, as I use
|multiple clients and still want the query buffer to be filled and replayed
|for the newly connecting client.
|
|diff -rup znc-0.074/IRCSock.cpp znc/IRCSock.cpp
|--- znc-0.074/IRCSock.cpp 2009-06-29 13:26:19 +0200

|+++ znc/IRCSock.cpp 2009-08-26 11:30:56 +0200

Patching file IRCSock.cpp using Plan A...
Hunk #1 failed at 724.
1 out of 1 hunks failed--saving rejects to IRCSock.cpp.rej
Hmm... The next patch looks like a unified diff to me...

The text leading up to this was:

|diff -rup znc-0.074/User.cpp znc/User.cpp
|--- znc-0.074/User.cpp 2009-07-22 18:54:52 +0200

|+++ znc/User.cpp 2009-08-26 11:30:56 +0200

Patching file User.cpp using Plan A...
Hunk #1 failed at 290.
1 out of 1 hunks failed--saving rejects to User.cpp.rej
done

operating system I'm using:

[ksx4system@ancon ~/temp/znc-0.202]$ uname -srp
FreeBSD 8.2-STABLE amd64

@amyreese
Copy link
Author

amyreese commented Dec 8, 2011

Sorry for the delay in replying. I can't replicate this error on my end (Ubuntu 10.04) on a fresh copy of 0.202. Both hunks succeed, even with the offset (see below). Your patch output looks quite different from mine, are you using any sort of params that might be causing different behavior, or does FreeBSD use a different implementation of patch?

root@dyson /srv/source # wget http://znc.in/releases/znc-0.202.tar.gz
--2011-12-08 18:26:57-- http://znc.in/releases/znc-0.202.tar.gz
Resolving znc.in... 109.234.106.52
Connecting to znc.in|109.234.106.52|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 654083 (639K) [application/octet-stream]
Saving to: `znc-0.202.tar.gz'

100%[=====================================================================================>] 654,083 677K/s in 0.9s

2011-12-08 18:26:58 (677 KB/s) - `znc-0.202.tar.gz' saved [654083/654083]

root@dyson /srv/source # tar xf znc-0.202.tar.gz
root@dyson /srv/source # cd znc-0.202
root@dyson /srv/source/znc-0.202 # patch -p1 < ../znc-query-buffering.patch
patching file IRCSock.cpp
Hunk #1 succeeded at 812 (offset 88 lines).
patching file User.cpp
Hunk #1 succeeded at 537 (offset 247 lines).
root@dyson /srv/source/znc-0.202 #

@vanhoof
Copy link

vanhoof commented Jan 20, 2012

Give this a go, applies, builds cleanly, and is functional on znc 0.202 on an Ubuntu 11.10 install:

http://paste.ubuntu.com/810415/

--chris

@jonypoins
Copy link

@amyreese
Copy link
Author

amyreese commented Feb 4, 2013

jonypoin's patch updated to compile against 1.0: https://gist.github.com/4710462

@d4g
Copy link

d4g commented May 13, 2013

Can you recreate the features of the original patch? Always everything in the query buffer? No stars?

With the latest patch, I am additionally having a weird behavior. On reconnect of the last clients, I get many emtpy messages in the query. On my iPad client, when I conenct to the server, the client crashes immediately and I have to restart it. Then I get no querybuffer.

@omgjlk
Copy link

omgjlk commented Apr 4, 2014

I've updated the original patch for 1.2 and improved upon it. See znc/znc#521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment