File size: 1,903 Bytes
6827a6b b830e20 6ee8b88 6827a6b c355492 b830e20 6827a6b c355492 6827a6b c355492 6827a6b c355492 6827a6b c355492 6827a6b c355492 50e6bc6 c355492 6827a6b c355492 6827a6b c355492 6827a6b c355492 6827a6b b830e20 6827a6b b830e20 6827a6b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
import discord
import threading
import os
import gradio as gr
DISCORD_BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
MONITORED_CHANNEL_IDS = [1269327567534559246, 1269536568172089448, 1269327567534559245, 1270219422472077344, 1269327567740211272, 1269327567534559244]
deleted_messages = {}
intents = discord.Intents.default()
intents.message_content = True
intents.messages = True
intents.guilds = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'Logged in as {client.user}')
@client.event
async def on_message_delete(message):
global deleted_messages
if message.channel.id in MONITORED_CHANNEL_IDS:
deleted_messages[message.channel.id] = {
'message': message.content,
'username': message.author.name
}
print(f"Message deleted in channel {message.channel.id}: {message.content} by {message.author.name}")
@client.event
async def on_message(message):
global deleted_messages
if message.author == client.user:
return
if message.content.lower() == ",s":
if message.channel.id in deleted_messages:
response = f"{deleted_messages[message.channel.id]['username']} : {deleted_messages[message.channel.id]['message']}"
else:
response = "No recently deleted messages in this channel."
await message.channel.send(response)
def run_discord_bot():
client.run(DISCORD_BOT_TOKEN)
def show_snipe():
output = ""
for channel_id, data in deleted_messages.items():
output += f"Channel {channel_id}:\n{data['username']} : {data['message']}\n\n"
return output if output else "No recently deleted messages in monitored channels."
iface = gr.Interface(fn=show_snipe, inputs=None, outputs="text")
discord_thread = threading.Thread(target=run_discord_bot)
discord_thread.start()
iface.launch()
|