HALT/HALTCORE not blocking message when returned from OnRaw in modpython module #639

Closed
opened 2026-10-05 04:35:33 +02:00 by adam · 6 comments
Owner

Ubuntu 14.04
ZNC 1.6.2 - IPv6: yes, SSL: yes, DNS: threads, charset: no

I've been trying to fix a glitch in an IRC server I use, so I'd like to stop a raw message and replace it with another. Nothing I've attempted has worked. The messages are being properly detected (I have a more complex version w/logging and the logs properly fire on the message), but returning znc.HALT and znc.HALTCORE seem to do nothing.

By all accounts, I would expect this to work (a similar strategy is being used in the block_motd module), but nothing works and the message continues on as if the handler wasn't here (except now the additional message is present)

import znc


class SlackPong(znc.Module):
    description = "Stop Slack's annoying PONG messages"
    module_types = [znc.CModInfo.NetworkModule]

    def OnRaw(self, line):
        if str(line).find("PONG :TIMEOUTCHECK") > -1:
            self.PutUser(":irc.tinyspeck.com PONG irc.tinyspeck.com :TIMEOUTCHECK")
            return znc.HALT
        return znc.CONTINUE

Ubuntu 14.04 ZNC 1.6.2 - IPv6: yes, SSL: yes, DNS: threads, charset: no I've been trying to fix a glitch in an IRC server I use, so I'd like to stop a raw message and replace it with another. Nothing I've attempted has worked. The messages are being properly detected (I have a more complex version w/logging and the logs properly fire on the message), but returning znc.HALT and znc.HALTCORE seem to do nothing. By all accounts, I would expect this to work (a similar strategy is being used in the block_motd module), but nothing works and the message continues on as if the handler wasn't here (except now the additional message is present) ``` import znc class SlackPong(znc.Module): description = "Stop Slack's annoying PONG messages" module_types = [znc.CModInfo.NetworkModule] def OnRaw(self, line): if str(line).find("PONG :TIMEOUTCHECK") > -1: self.PutUser(":irc.tinyspeck.com PONG irc.tinyspeck.com :TIMEOUTCHECK") return znc.HALT return znc.CONTINUE ``` ## <!-- github-sync-id:117667502 -->
adam closed this issue 2026-10-05 04:35:34 +02:00
Author
Owner

This simple module works for me:

import znc
class pytest(znc.Module):
    def OnRaw(self, line):
        return znc.HALT

ZNC hangs on IRC -> ZNC [:wilhelm.freenode.net CAP * LS :account-notify extended-join identify-msg multi-prefix sasl] and doesn't reply anything because of HALT.

This simple module works for me: ``` py import znc class pytest(znc.Module): def OnRaw(self, line): return znc.HALT ``` ZNC hangs on `IRC -> ZNC [:wilhelm.freenode.net CAP * LS :account-notify extended-join identify-msg multi-prefix sasl]` and doesn't reply anything because of HALT. <!-- github-comment-id:158636122 -->
Author
Owner

That's really strange; if I shrink the module down to that, it works, but if I add the find again, it fails to stop the message.

If I replace the if and add self.PutModule("Found timeout!"), I get that message, but the incorrect PONG still goes through...

That's really strange; if I shrink the module down to that, it works, but if I add the find again, it fails to stop the message. If I replace the if and add `self.PutModule("Found timeout!")`, I get that message, but the incorrect PONG still goes through... <!-- github-comment-id:159107579 -->
Author
Owner

May you show znc -D with that PONG?

May you show `znc -D` with that PONG? <!-- github-comment-id:160338963 -->
Author
Owner

Sorry about the delay, the holidays have been a bit busy...

This is without the module:

[2016-01-12 07:23:52.520310] (<username>/Slack) CLI -> ZNC [PING :TIMEOUTCHECK]
[2016-01-12 07:23:52.520458] (<username>/Slack) ZNC -> IRC [PING :TIMEOUTCHECK]
[2016-01-12 07:23:52.554026] (<username>/Slack) IRC -> ZNC [:irc.tinyspeck.com PONG :TIMEOUTCHECK]
[2016-01-12 07:23:52.554188] (<username>/Slack) ZNC -> CLI [:irc.tinyspeck.com PONG :TIMEOUTCHECK]

This is with the module:

[2016-01-12 07:47:53.223294] (<username>/Slack) CLI -> ZNC [PING :TIMEOUTCHECK]
[2016-01-12 07:47:53.223510] (<username>/Slack) ZNC -> IRC [PING :TIMEOUTCHECK]
[2016-01-12 07:47:53.257863] (<username>/Slack) IRC -> ZNC [:irc.tinyspeck.com PONG :TIMEOUTCHECK]
[2016-01-12 07:47:53.258124] (<username>/Slack) ZNC -> CLI [:irc.tinyspeck.com PONG :TIMEOUTCHECK]
[2016-01-12 07:47:53.258354] (<username>/Slack) ZNC -> CLI [:irc.tinyspeck.com PONG irc.tinyspeck.com :TIMEOUTCHECK]

The module is basically the same as before, forgot I included it earlier.

Sorry about the delay, the holidays have been a bit busy... This is without the module: ``` [2016-01-12 07:23:52.520310] (<username>/Slack) CLI -> ZNC [PING :TIMEOUTCHECK] [2016-01-12 07:23:52.520458] (<username>/Slack) ZNC -> IRC [PING :TIMEOUTCHECK] [2016-01-12 07:23:52.554026] (<username>/Slack) IRC -> ZNC [:irc.tinyspeck.com PONG :TIMEOUTCHECK] [2016-01-12 07:23:52.554188] (<username>/Slack) ZNC -> CLI [:irc.tinyspeck.com PONG :TIMEOUTCHECK] ``` This is with the module: ``` [2016-01-12 07:47:53.223294] (<username>/Slack) CLI -> ZNC [PING :TIMEOUTCHECK] [2016-01-12 07:47:53.223510] (<username>/Slack) ZNC -> IRC [PING :TIMEOUTCHECK] [2016-01-12 07:47:53.257863] (<username>/Slack) IRC -> ZNC [:irc.tinyspeck.com PONG :TIMEOUTCHECK] [2016-01-12 07:47:53.258124] (<username>/Slack) ZNC -> CLI [:irc.tinyspeck.com PONG :TIMEOUTCHECK] [2016-01-12 07:47:53.258354] (<username>/Slack) ZNC -> CLI [:irc.tinyspeck.com PONG irc.tinyspeck.com :TIMEOUTCHECK] ``` The module is basically the same as before, forgot I included it earlier. <!-- github-comment-id:170829587 -->
Author
Owner
[2016-01-22 20:33:22.076320] (qwe/default) IRC -> ZNC [:irc.tinyspeck.com PONG :TIMEOUTCHECK]
[2016-01-22 20:33:22.076450] (qwe/default) ZNC -> CLI [:irc.tinyspeck.com PONG irc.tinyspeck.com :TIMEOUTCHECK]

Works for me...

irc.tinyspeck.com doesn't resolve, so I did this:

echo ":irc.tinyspeck.com 001 nick :hello\n:irc.tinyspeck.com PONG :TIMEOUTCHECK" | socat tcp6-listen:54321,reuseaddr stdio
``` [2016-01-22 20:33:22.076320] (qwe/default) IRC -> ZNC [:irc.tinyspeck.com PONG :TIMEOUTCHECK] [2016-01-22 20:33:22.076450] (qwe/default) ZNC -> CLI [:irc.tinyspeck.com PONG irc.tinyspeck.com :TIMEOUTCHECK] ``` Works for me... irc.tinyspeck.com doesn't resolve, so I did this: ``` shell echo ":irc.tinyspeck.com 001 nick :hello\n:irc.tinyspeck.com PONG :TIMEOUTCHECK" | socat tcp6-listen:54321,reuseaddr stdio ``` <!-- github-comment-id:174038692 -->
Author
Owner

If you have any more info, reopen

If you have any more info, reopen <!-- github-comment-id:260990618 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#639