Update app.py
Browse files
app.py
CHANGED
@@ -3,17 +3,17 @@ import threading
|
|
3 |
import os
|
4 |
import gradio as gr
|
5 |
|
6 |
-
|
7 |
DISCORD_BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
|
8 |
|
9 |
-
|
10 |
MONITORED_CHANNEL_ID = 1269327567534559244 # Replace with the actual channel ID
|
11 |
|
12 |
-
|
13 |
deleted_message = None
|
14 |
username = None
|
15 |
|
16 |
-
# Discord bot setup
|
17 |
intents = discord.Intents.default()
|
18 |
intents.message_content = True
|
19 |
intents.messages = True
|
@@ -28,7 +28,7 @@ async def on_ready():
|
|
28 |
async def on_message_delete(message):
|
29 |
global deleted_message, username
|
30 |
|
31 |
-
# Check if the deleted message is in the
|
32 |
if message.channel.id == MONITORED_CHANNEL_ID:
|
33 |
deleted_message = message.content
|
34 |
username = message.author.name
|
@@ -42,7 +42,7 @@ async def on_message(message):
|
|
42 |
if message.author == client.user:
|
43 |
return
|
44 |
|
45 |
-
#
|
46 |
if message.content.lower() == ",s":
|
47 |
if deleted_message and username:
|
48 |
response = f"{username} : {deleted_message}"
|
@@ -51,7 +51,7 @@ async def on_message(message):
|
|
51 |
|
52 |
await message.channel.send(response)
|
53 |
|
54 |
-
#
|
55 |
def run_discord_bot():
|
56 |
client.run(DISCORD_BOT_TOKEN)
|
57 |
|
@@ -62,12 +62,12 @@ def show_snipe():
|
|
62 |
else:
|
63 |
return "No recently deleted messages."
|
64 |
|
65 |
-
|
66 |
iface = gr.Interface(fn=show_snipe, inputs=None, outputs="text")
|
67 |
|
68 |
-
|
69 |
discord_thread = threading.Thread(target=run_discord_bot)
|
70 |
discord_thread.start()
|
71 |
|
72 |
-
|
73 |
iface.launch()
|
|
|
3 |
import os
|
4 |
import gradio as gr
|
5 |
|
6 |
+
|
7 |
DISCORD_BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
|
8 |
|
9 |
+
|
10 |
MONITORED_CHANNEL_ID = 1269327567534559244 # Replace with the actual channel ID
|
11 |
|
12 |
+
|
13 |
deleted_message = None
|
14 |
username = None
|
15 |
|
16 |
+
# goofy ahh Discord bot setup
|
17 |
intents = discord.Intents.default()
|
18 |
intents.message_content = True
|
19 |
intents.messages = True
|
|
|
28 |
async def on_message_delete(message):
|
29 |
global deleted_message, username
|
30 |
|
31 |
+
# Check if the deleted message is in the reqd channel
|
32 |
if message.channel.id == MONITORED_CHANNEL_ID:
|
33 |
deleted_message = message.content
|
34 |
username = message.author.name
|
|
|
42 |
if message.author == client.user:
|
43 |
return
|
44 |
|
45 |
+
# ultra cool bot responding
|
46 |
if message.content.lower() == ",s":
|
47 |
if deleted_message and username:
|
48 |
response = f"{username} : {deleted_message}"
|
|
|
51 |
|
52 |
await message.channel.send(response)
|
53 |
|
54 |
+
# separate thread stuffs
|
55 |
def run_discord_bot():
|
56 |
client.run(DISCORD_BOT_TOKEN)
|
57 |
|
|
|
62 |
else:
|
63 |
return "No recently deleted messages."
|
64 |
|
65 |
+
|
66 |
iface = gr.Interface(fn=show_snipe, inputs=None, outputs="text")
|
67 |
|
68 |
+
|
69 |
discord_thread = threading.Thread(target=run_discord_bot)
|
70 |
discord_thread.start()
|
71 |
|
72 |
+
|
73 |
iface.launch()
|