#๐ Async Queue not working as expected
5 messages ยท Page 1 of 1 (latest)
@celest laurel
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
# Twitch parser
class Bot(commands.Bot):
def __init__(self, queue):
super().__init__(token=ACCESS_TOKEN, prefix='?', initial_channels=[twitch_channel])
self.queue = queue
async def event_ready(self):
print(f'Logged into twitch as | {self.nick}')
async def event_message(self, message):
if message.echo:
return
msg_author = message.author.name
msg_content = message.content
print(f"Twitch message from {msg_author} : " + msg_content)
chat_prompt = {msg_author: msg_content}
await self.handle_commands(message)
await self.queue.put(msg_content) # put chat_prompt into the queue
return chat_prompt, msg_content
# Main wrapper
async def main(queue):
message = await queue.get()
await send_message(f"{message}")
async def run_bot_and_client(queue):
bot = Bot(queue)
client = MyClient(queue, intents=intents)
await asyncio.gather(bot.start(), client.start(token))
queue = asyncio.Queue()
asyncio.run(run_bot_and_client(queue))
@celest laurel
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.