benediktschmitt/py-ts3

text Commands handler

Closed this issue · 6 comments

Hello!

Have can I handle text commands to bot when I send private message to bot?
I've been looking for months on how to do it, and I haven't found out anything new.

Text commands are events and therefore accessible through servernotifyregister.
Just look up "servernotifyregister" in the serverquery documentation.

Thanks for your reply!
Do your have any examples how to register event "Text message"?

In the serverquery console you can do:
servernotifyregister event=textprivate
In this library its quite well documented, there are many examples in the README file for version 2:
https://github.com/benediktschmitt/py-ts3/tree/v2#examples

Yes of course but this event only allows to send private message to bot, but how to handle this? How to make command handler?
example:
When I send message "!kick [client_nickname]" the bot will run a function that will do this

You can always send a private message to your bot, that has nothing to do with servernotifyregister.
Your python code handles that event. wait_for_event() returns a new event object, which contains all the data of the event, like which event it was, which client triggered the event, such things.
What you do with that event is entirely up to you, you can log it, call a function, whatever you want.
Just take a look at the examples

Ok, thanks <3
I love you!