modified: bot.py
This commit is contained in:
22
bot.py
22
bot.py
@@ -489,25 +489,27 @@ async def stoplivechat(ctx):
|
|||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
if message.author.bot: # Bots ignorieren
|
if message.author.bot: # Bots ignorieren
|
||||||
return
|
return
|
||||||
|
|
||||||
channel =message.channel
|
|
||||||
|
|
||||||
await channel.send("test")
|
|
||||||
|
|
||||||
channel_id = message.channel.id
|
channel_id = message.channel.id
|
||||||
|
|
||||||
# Prüfen, ob der Live-Chat aktiv ist
|
|
||||||
if channel_id in live_chats and live_chats[channel_id]["active"]:
|
if channel_id in live_chats and live_chats[channel_id]["active"]:
|
||||||
await live_chat_queue.put((message, message.id, message.author.id, message.author.display_name, message.content))
|
# Alle benötigten Daten aus dem message-Objekt extrahieren
|
||||||
|
msg_id = str(message.id)
|
||||||
|
user_id = str(message.author.id)
|
||||||
|
nickname = message.author.display_name
|
||||||
|
content = message.content
|
||||||
|
|
||||||
|
# Füge die Nachricht zur Warteschlange hinzu
|
||||||
|
await live_chat_queue.put((message, msg_id, user_id, nickname, content))
|
||||||
await client.process_commands(message)
|
await client.process_commands(message)
|
||||||
|
|
||||||
async def process_live_chat_queue():
|
async def process_live_chat_queue():
|
||||||
while True:
|
while True:
|
||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
try:
|
try:
|
||||||
if not askmultus_queue.empty():
|
if not askmultus_queue.empty():
|
||||||
|
|
||||||
message, message.id, message.author.id, message.author.display_name, message.content = await live_chat_queue.get()
|
message, msg_id, user_id, nickname, content = await live_chat_queue.get()
|
||||||
|
|
||||||
live_introduction = read_file("live_introduction.txt")
|
live_introduction = read_file("live_introduction.txt")
|
||||||
live_background_data = read_file("live_background_data.txt")
|
live_background_data = read_file("live_background_data.txt")
|
||||||
@@ -516,7 +518,7 @@ async def process_live_chat_queue():
|
|||||||
|
|
||||||
timestamp = int(time.time()) # Unix-Timestamp
|
timestamp = int(time.time()) # Unix-Timestamp
|
||||||
|
|
||||||
content = timestamp + "/" + message.id + "/" + message.author.id + "/" + message.author.display_name + ":" + message.content
|
content = timestamp + "/" + msg_id + "/" + user_id + "/" + nickname + ":" + content
|
||||||
|
|
||||||
chat_history.append({"role": "user", "content": f"{content}"})
|
chat_history.append({"role": "user", "content": f"{content}"})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user