command for clearing all buffers #473

Closed
opened 2026-10-05 04:23:39 +02:00 by adam · 3 comments
Owner

Currently there are /znc clearallchannelbuffers and /znc clearallquerybuffers. /znc clearallbuffers to clear both channel and query buffers could be useful especially with mobile client.

Currently there are `/znc clearallchannelbuffers` and `/znc clearallquerybuffers`. `/znc clearallbuffers` to clear both channel and query buffers could be useful especially with mobile client. <!-- github-sync-id:56944449 -->
adam closed this issue 2026-10-05 04:23:39 +02:00
Author
Owner

I actually have this as my own addon aliased to /clr for exactly this reason!

I thought it was a bit niche so I haven't PRd it, but:

#include <znc/Chan.h>
#include <znc/IRCNetwork.h>
#include <znc/Modules.h>
#include <znc/Query.h>
#include <znc/User.h>

class CClearAllBuffers : public CModule {
public:
        MODCONSTRUCTOR(CClearAllBuffers) {}

        virtual void OnModCommand(const CString& sCommand) {
            int count = 0;

            for (auto network : m_pUser->GetNetworks()) {
                for (auto chan : network->GetChans()) {
                    chan->ClearBuffer();
                    count++;
                }
                for (auto query : network->GetQueries()) {
                    network->DelQuery(query->GetName());
                    count++;
                }
            }

            PutStatus("Cleared " + CString(count) + " buffers");
        }
};

USERMODULEDEFS(CClearAllBuffers, "Provides command to clear ALL buffers")
I actually have this as my own addon aliased to /clr for exactly this reason! I thought it was a bit niche so I haven't PRd it, but: ``` c++ #include <znc/Chan.h> #include <znc/IRCNetwork.h> #include <znc/Modules.h> #include <znc/Query.h> #include <znc/User.h> class CClearAllBuffers : public CModule { public: MODCONSTRUCTOR(CClearAllBuffers) {} virtual void OnModCommand(const CString& sCommand) { int count = 0; for (auto network : m_pUser->GetNetworks()) { for (auto chan : network->GetChans()) { chan->ClearBuffer(); count++; } for (auto query : network->GetQueries()) { network->DelQuery(query->GetName()); count++; } } PutStatus("Cleared " + CString(count) + " buffers"); } }; USERMODULEDEFS(CClearAllBuffers, "Provides command to clear ALL buffers") ``` <!-- github-comment-id:73403243 -->
Author
Owner

Oh and if you just want the current network, simply use *alias:

<*alias> Actions for alias CL:
<*alias> 0   ZNC ClearAllChannelBuffers
<*alias> 1   ZNC ClearAllQueryBuffers
<*alias> End of actions for alias CL.
Oh and if you just want the current network, simply use *alias: ``` <*alias> Actions for alias CL: <*alias> 0 ZNC ClearAllChannelBuffers <*alias> 1 ZNC ClearAllQueryBuffers <*alias> End of actions for alias CL. ``` <!-- github-comment-id:73403272 -->
Author
Owner

For those using the playback module:
/msg *playback clear *

For those using the [playback](http://wiki.znc.in/Playback) module: `/msg *playback clear *` <!-- github-comment-id:74627105 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#473