2

Is there a way to send a message via the TwitchIO library? for example, send a message if the time is 10:43 PM? This is not an event nor a message from twitch chat, that's an if/else totally invoked from within the application. I tried the code below, by reading a bit of its source code, but it didn't work! no errors either.

bot = commands.Bot(...)
bot._ws.send_privmsg(bot.get_channel("some_channel_that_is_connected_to_right_now"),"Time is: "+time.time())

again, the bot works with events, but I wasn't able to find anything else on this matter! the bot's documentation is a little bit all over the place

A.R.H
  • 383
  • 2
  • 6
  • 25

1 Answers1

2

Got some pointers from the TwitchIO discord chat logs where this has been asked few times.

Due to async nature you have to add a task to the running event loop from external code having reference to the bot like this:

chan = bot.get_channel("channelname")
loop = asyncio.get_event_loop()
loop.create_task(chan.send("Send this message"))