[log] self-messages in queries not logged #702

Open
opened 2026-10-05 04:39:34 +02:00 by adam · 6 comments
Owner

This is likely an edge case, but here's how I discovered it.

One of the networks I've added to my ZNC is a local BitlBee server, so I can use other chat protocols via IRC and centralize almost everything into one instance of The Lounge web IRC for when I'm mobile or at a public computer. The latest BitlBee update (3.4.2) added support for IRCv3 self-message or echo-message whatever the spec calls it now (I've lost track). If I interact with one of the external chat networks (Steam, Facebook, etc.) via one of the official clients, not through IRC, BitlBee now forwards what I said to connected IRC clients (ZNC).

As far as I can tell, ZNC supports the forwarding just fine. My desktop client, Textual, happily inserts received self-messages into both channel and query buffers. Logging, however, is incomplete. Only self-messages in channels are logged. If I am interacting with a one-on-one chat that goes to a query buffer instead, ZNC's log module appears to ignore the message, and it does not appear in the log files.

Messages sent from another client connected to ZNC log just fine. It appears to be only private messages that come from the server that aren't logged.

I built and installed a test ZNC from the latest git code to confirm that the bug was still present:

[02:33:35] <dgw> version
[02:33:35] <*status> ZNC 1.7.x-git-1274-4435baf - http://znc.in
[02:33:35] <*status> IPv6: yes, SSL: yes, DNS: threads, charset: yes, build: autoconf, i18n: no

Since self-messages to queries were still not logged, I decided to go ahead and create this issue. Looking through log.cpp myself, I didn't see anything obvious that would cause this. It might even be buried somewhere in core.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

This is likely an edge case, but here's how I discovered it. One of the networks I've added to my ZNC is a local BitlBee server, so I can use other chat protocols via IRC and centralize almost everything into one instance of The Lounge web IRC for when I'm mobile or at a public computer. The latest BitlBee update (3.4.2) [added support](https://wiki.bitlbee.org/SelfMessages) for IRCv3 `self-message` or `echo-message` whatever the spec calls it now (I've lost track). If I interact with one of the external chat networks (Steam, Facebook, etc.) via one of the official clients, not through IRC, BitlBee now forwards what I said to connected IRC clients (ZNC). As far as I can tell, ZNC supports the forwarding just fine. My desktop client, Textual, happily inserts received self-messages into both channel and query buffers. Logging, however, is incomplete. Only self-messages in channels are logged. If I am interacting with a one-on-one chat that goes to a query buffer instead, ZNC's `log` module appears to ignore the message, and it does not appear in the log files. Messages sent from another client connected to ZNC log just fine. It appears to be only private messages that come from the _server_ that aren't logged. I built and installed a test ZNC from the latest git code to confirm that the bug was still present: ``` [02:33:35] <dgw> version [02:33:35] <*status> ZNC 1.7.x-git-1274-4435baf - http://znc.in [02:33:35] <*status> IPv6: yes, SSL: yes, DNS: threads, charset: yes, build: autoconf, i18n: no ``` Since self-messages to queries were still not logged, I decided to go ahead and create this issue. Looking through `log.cpp` myself, I didn't see anything obvious that would cause this. It might even be buried somewhere in core. ## <bountysource-plugin> Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/33898565-log-self-messages-in-queries-not-logged?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github). </bountysource-plugin> <!-- github-sync-id:152949255 -->
Author
Owner

On further investigation, I believe it has to do with this conditional, which calls the OnPrivMessage() module hooks only if the message target is equal to GetNick(). If not, it is passed along to be handled as a channel message—and self-messages will be dropped here, because they will not be found by m_pNetwork->FindChan() (they aren't targeted to channels).

As I said, it's an edge case. Still tracing the flow of messages through the code in bits and pieces as I get better at understanding the code, but I get the impression that it won't be a simple fix.

On further investigation, I believe it has to do with [this conditional](https://github.com/znc/znc/blob/17e0d1031e54a74ae7a7c515dd7f5a8b41b5b4bd/src/IRCSock.cpp#L1052-L1053), which calls the `OnPrivMessage()` module hooks only if the message target is equal to `GetNick()`. If not, it is passed along to be handled as a channel message—and self-messages will be dropped here, because they will not be found by `m_pNetwork->FindChan()` (they aren't targeted to channels). As I said, it's an edge case. Still tracing the flow of messages through the code in bits and pieces as I get better at understanding the code, but I get the impression that it won't be a simple fix. <!-- github-comment-id:217714346 -->
Author
Owner

I also get this particular problem. I can take a look through the course - once my college coursework clears up though. But I also have the feelling it might be more complex than just patching IRCSock.cpp...

I also get this _particular_ problem. I can take a look through the course - once my college coursework clears up though. But I also have the feelling it might be more complex than just patching `IRCSock.cpp`... <!-- github-comment-id:340434962 -->
Author
Owner

@dgw Did you get any further on this bug? 😄

@dgw Did you get any further on this bug? :smile: <!-- github-comment-id:380955314 -->
Author
Owner

@shymega Honestly, I haven't been back to look at it. I just make sure to send stuff in queries directly with BitlBee, instead of using the service's app/website. (I've also taken over two other OSS projects since filing this, so my motivation to learn more C++ and look into this myself has gone down a lot…)

But I should ask you the same 😂

@shymega Honestly, I haven't been back to look at it. I just make sure to send stuff in queries directly with BitlBee, instead of using the service's app/website. (I've also taken over two other OSS projects since filing this, so my motivation to learn more C++ and look into this myself has gone down a lot…) But I should ask you the same 😂 <!-- github-comment-id:380976657 -->
Author
Owner

@dgw I did not get anywhere either, my solution is exactly the same as yours in that sending queries directly with bitlbee works. Unfortunately, I also have FB Messenger on my phone, so I usually end up forgetting to send via ZNC/Bitlbee and thus lose message history.

Its an odd bug...

@dgw I did not get anywhere either, my solution is exactly the same as yours in that sending queries directly with bitlbee works. Unfortunately, I also have FB Messenger on my phone, so I usually end up forgetting to send via ZNC/Bitlbee and thus lose message history. Its an odd bug... <!-- github-comment-id:381107560 -->
Author
Owner

for anyone who lands here, an ugly workaround until this is properly fixed in ZNC is to set self_message or self_message_prefix on bitlbee to treat ZNC as a client that doesn't understand znc.in/self-message which, while funny, is accurate

for anyone who lands here, an ugly workaround until this is properly fixed in ZNC is to set self_message or self_message_prefix on bitlbee to treat ZNC as a client that doesn't understand znc.in/self-message which, while funny, is accurate <!-- github-comment-id:449608093 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#702