PythonistaGuild / TwitchIO

An Async Bot/API wrapper for Twitch made in Python.
https://twitchio.dev
MIT License
791 stars 163 forks source link

Support reply for any message #380

Closed alkim0 closed 1 year ago

alkim0 commented 1 year ago

As it is right now, the only way to use the reply functionality (without interacting directly with the websocket) is to use ctx.reply, but that's a problem when no context is constructed like in the event_message handler.

May I suggest that the reply function be moved back to the Messageable class and the interface changed to look like:

async def reply(self, message: Message, content: str)

in which the message argument is the message we want to reply to. This would seem to solve the problem.

Right now I'm manually creating a Context object and calling reply on that, but that seems a bit jank.

github-actions[bot] commented 1 year ago

Hello! Thanks for the issue. If this is a general help question, for a faster response consider joining the official Discord Server

Else if you have an issue with the library please wait for someone to help you here.

chillymosh commented 1 year ago

get_context exists for these scenarios https://twitchio.dev/en/latest/exts/commands.html#twitchio.ext.commands.Bot.get_context

    async def event_message(self, message: twitchio.Message):
        if message.echo:
            return

        ctx: commands.Context = await self.get_context(message)
        await ctx.reply("Hello this is a reply")

        await self.handle_commands(message)
alkim0 commented 1 year ago

I must've missed that. Thanks!