Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/GPT3Discord/src/commit/64ce627bb7e2c34c9e65c30b1c72014b11c58b66/services/deletion_service.py You should set ROOT_URL correctly, otherwise the web may not work correctly.
GPT3Discord/services/deletion_service.py

44 lines
1.7 KiB

import asyncio
import traceback
from datetime import datetime
import discord
class Deletion:
def __init__(self, message, timestamp):
self.message = message
self.timestamp = timestamp
# This function will be called by the bot to process the message queue
@staticmethod
async def process_deletion_queue(
deletion_queue, PROCESS_WAIT_TIME, EMPTY_WAIT_TIME
):
while True:
try:
# If the queue is empty, sleep for a short time before checking again
if deletion_queue.empty():
await asyncio.sleep(EMPTY_WAIT_TIME)
continue
# Get the next message from the queue
deletion = await deletion_queue.get()
# Check if the current timestamp is greater than the deletion timestamp
if datetime.now().timestamp() > deletion.timestamp:
# If the deletion timestamp has passed, delete the message
# check if deletion.message is of type discord.Message
if isinstance(deletion.message, discord.Message):
await deletion.message.delete()
else:
await deletion.message.delete_original_response()
else:
await deletion_queue.put(deletion)
# Sleep for a short time before processing the next message
# This will prevent the bot from spamming messages too quickly
await asyncio.sleep(PROCESS_WAIT_TIME)
except Exception:
traceback.print_exc()