AddCommand() in python [$5] #124

Closed
opened 2026-10-05 04:00:09 +02:00 by adam · 10 comments
Owner
No description provided.
<!-- github-sync-id:5777066 -->
adam closed this issue 2026-10-05 04:00:09 +02:00
Author
Owner

I encountered the same issue....

I encountered the same issue.... <!-- github-comment-id:78944844 -->
Author
Owner

Why don't you circumvent the issue by implementing an independent command system in python?

Why don't you circumvent the issue by implementing an independent command system in python? <!-- github-comment-id:78982777 -->
Author
Owner

That would be a possible solution, yes.
As for why, because noone implenented it?

That would be a possible solution, yes. As for why, because noone implenented it? <!-- github-comment-id:80142979 -->
Author
Owner

Does this mean it isn't currently possible to do something like this:

/msg *module command

because it isn't possible to call AddCommand in a Python module?

Does this mean it isn't currently possible to do something like this: `/msg *module command` because it isn't possible to call AddCommand in a Python module? <!-- github-comment-id:474331096 -->
Author
Owner

OnModCommand() is still available, but you need to parse the line yourself.

вт, 19 мар. 2019 г. в 11:53, Philip Colmer notifications@github.com:

Does this mean it isn't currently possible to do something like this:

/msg *module command

because it isn't possible to call AddCommand in a Python module?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/znc/znc/issues/198#issuecomment-474331096, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAT15MtrkWYJoaQkAq8_0DBW9RNdjFmOks5vYM-0gaJpZM4AFEbH
.

OnModCommand() is still available, but you need to parse the line yourself. вт, 19 мар. 2019 г. в 11:53, Philip Colmer <notifications@github.com>: > Does this mean it isn't currently possible to do something like this: > > /msg *module command > > because it isn't possible to call AddCommand in a Python module? > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/znc/znc/issues/198#issuecomment-474331096>, or mute > the thread > <https://github.com/notifications/unsubscribe-auth/AAT15MtrkWYJoaQkAq8_0DBW9RNdjFmOks5vYM-0gaJpZM4AFEbH> > . > <!-- github-comment-id:474361712 -->
Author
Owner

@DarthGandalf thanks. If I add OnModCommand and send a private message to my module, I get:

This module doesn't implement any commands.

which seems to suggest that I still need to call AddCommand somehow, but I'm struggling with the parameters to give it. The call is insisting that I pass it a CModCOmmand::ModCmdFunc.

What am I misunderstanding here?

@DarthGandalf thanks. If I add OnModCommand and send a private message to my module, I get: `This module doesn't implement any commands.` which seems to suggest that I still need to call AddCommand somehow, but I'm struggling with the parameters to give it. The call is insisting that I pass it a CModCOmmand::ModCmdFunc. What am I misunderstanding here? <!-- github-comment-id:474379678 -->
Author
Owner

You don't just add it. You need to implement it. The default implementation
uses commands which were added via AddCommand().

CModCommand::ModCmdFunc is exactly why AddCommand doesn't work currently,
this is what this issue is about - to make AddCommand work.

вт, 19 мар. 2019 г. в 13:52, Philip Colmer notifications@github.com:

@DarthGandalf https://github.com/DarthGandalf thanks. If I add
OnModCommand and send a private message to my module, I get:

This module doesn't implement any commands.

which seems to suggest that I still need to call AddCommand somehow, but
I'm struggling with the parameters to give it. The call is insisting that I
pass it a CModCOmmand::ModCmdFunc.

What am I misunderstanding here?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/znc/znc/issues/198#issuecomment-474379678, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAT15BUsPQEWZ1fuLlXArM5wKRW6USfDks5vYOuqgaJpZM4AFEbH
.

You don't just add it. You need to implement it. The default implementation uses commands which were added via AddCommand(). CModCommand::ModCmdFunc is exactly why AddCommand doesn't work currently, this is what this issue is about - to make AddCommand work. вт, 19 мар. 2019 г. в 13:52, Philip Colmer <notifications@github.com>: > @DarthGandalf <https://github.com/DarthGandalf> thanks. If I add > OnModCommand and send a private message to my module, I get: > > This module doesn't implement any commands. > > which seems to suggest that I still need to call AddCommand somehow, but > I'm struggling with the parameters to give it. The call is insisting that I > pass it a CModCOmmand::ModCmdFunc. > > What am I misunderstanding here? > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/znc/znc/issues/198#issuecomment-474379678>, or mute > the thread > <https://github.com/notifications/unsubscribe-auth/AAT15BUsPQEWZ1fuLlXArM5wKRW6USfDks5vYOuqgaJpZM4AFEbH> > . > <!-- github-comment-id:474391503 -->
Author
Owner

I'm sorry - I don't understand.

If AddCommand doesn't work then how do I implement OnModCommand? The code for the pyeval module just adds the function and has code to do processing when the function is called. I've added a definition for OnModCommand but it doesn't get called - I just get that error message displayed.

    def OnModCommand(self, message):
        print("OnModCommand")
I'm sorry - I don't understand. If AddCommand doesn't work then how do I implement OnModCommand? The code for the `pyeval` module just adds the function and has code to do processing when the function is called. I've added a definition for OnModCommand but it doesn't get called - I just get that error message displayed. ``` def OnModCommand(self, message): print("OnModCommand") ``` <!-- github-comment-id:474399856 -->
Author
Owner

Hmm … I've just realised that my OnModCommand is getting called as the print statement is being executed.

So what do I need to do to tell ZNC that the call has been handled? It is a void function and this is partly why I'm confused about this.

Hmm … I've just realised that my `OnModCommand` **is** getting called as the `print` statement is being executed. So what do I need to do to tell ZNC that the call has been handled? It is a `void` function and this is partly why I'm confused about this. <!-- github-comment-id:474409926 -->
Author
Owner

OK … if I call something like PutModule, I stop getting the error message about there not being any commands implementation. I think I'm OK with this now.

OK … if I call something like PutModule, I stop getting the error message about there not being any commands implementation. I think I'm OK with this now. <!-- github-comment-id:474411935 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#124