Teekeks / pyTwitchAPI

A Python 3.7 compatible implementation of the Twitch API, EventSub, PubSub and Chat
https://pytwitchapi.dev
MIT License
254 stars 38 forks source link

Send Messages to Twitchchat #164

Closed yschulzy closed 1 year ago

yschulzy commented 1 year ago

hi,

I pulled the latest version from your repository today. I find it very simple and easy to use. Now I am trying to use the new chatbot. This works very well in itself. Allergings is not clear to me how I can post a message in the chat. I would use the send_message class, which is already stored. However, this does not work for me. Do you have a working example where you can see how this is done correctly ? In the documentation example is unfortunately nothing to see.

Best regards and happy new year

Teekeks commented 1 year ago

The docs have a working example: https://pytwitchapi.readthedocs.io/en/latest/modules/twitchAPI.chat.html#code-example

In test_command() you can see cmd.reply being used. you can also just use cmd.send to send a message to the channel the command was issued in.

If you want to send a message outside the context of a command, you can use send_message (https://pytwitchapi.readthedocs.io/en/latest/modules/twitchAPI.chat.html#twitchAPI.chat.Chat.send_message).

yschulzy commented 1 year ago

Yes I would like to send a message without the context to commands. The documentation is really good. However, sending does not work for me. Therefore the request for an example function based on the general example.

Teekeks commented 1 year ago

make sure that the bot actually joined the channel you want to send the message in. And please show me the code you have that is not working.

yschulzy commented 1 year ago

The problem is that I can't figure it out from the doc. Usecase would be to send the message from another Python file. I am still a python beginner and would like to program my own chatbot. I have only tried out how to do it with the example so far. So far without success. The code would therefore not look much different. Sending a message at startup works, but unfortunately I need a message that is triggered when in another Python script the function is called.

Example:

File_1: if sendmymessage == True: send_message(room="#channelname" ,msg= "Messagetext")

Twitch_chatbot_file: def send_message(room, msg) .....DO THINGS TO SEND THE MESSAGE.....