Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ from typing import Optional
|
|
| 7 |
import discord
|
| 8 |
import gradio as gr
|
| 9 |
from discord import Permissions
|
|
|
|
| 10 |
from discord.ext import commands
|
| 11 |
from discord.utils import oauth_url
|
| 12 |
import gradio_client as grc
|
|
@@ -29,7 +30,7 @@ HF_TOKEN=os.getenv("HF_TOKEN")
|
|
| 29 |
# Setup DNS resolver to avoid potential issues
|
| 30 |
resolver = AsyncResolver(nameservers=["1.1.1.1", "8.8.8.8"])
|
| 31 |
connector = aiohttp.TCPConnector(resolver=resolver)
|
| 32 |
-
client = grc.Client("https://standarovskid-bot.hf.space/", hf_token=HF_TOKEN
|
| 33 |
|
| 34 |
# Instantiate bot
|
| 35 |
bot = commands.Bot(intents=intents, connector=connector, command_prefix="/")
|
|
@@ -61,14 +62,14 @@ def call_huggingface_space(input_text):
|
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
-
@
|
| 65 |
async def on_ready():
|
| 66 |
-
print(f"Logged in as {
|
| 67 |
|
| 68 |
-
@
|
| 69 |
async def on_message(message):
|
| 70 |
# 忽略自己的消息
|
| 71 |
-
if message.author ==
|
| 72 |
return
|
| 73 |
|
| 74 |
if message.content.startswith("!predict"):
|
|
@@ -77,4 +78,4 @@ async def on_message(message):
|
|
| 77 |
await message.channel.send(result)
|
| 78 |
|
| 79 |
# 启动 Bot
|
| 80 |
-
|
|
|
|
| 7 |
import discord
|
| 8 |
import gradio as gr
|
| 9 |
from discord import Permissions
|
| 10 |
+
import discord
|
| 11 |
from discord.ext import commands
|
| 12 |
from discord.utils import oauth_url
|
| 13 |
import gradio_client as grc
|
|
|
|
| 30 |
# Setup DNS resolver to avoid potential issues
|
| 31 |
resolver = AsyncResolver(nameservers=["1.1.1.1", "8.8.8.8"])
|
| 32 |
connector = aiohttp.TCPConnector(resolver=resolver)
|
| 33 |
+
client = grc.Client("https://standarovskid-bot.hf.space/", hf_token=HF_TOKEN)
|
| 34 |
|
| 35 |
# Instantiate bot
|
| 36 |
bot = commands.Bot(intents=intents, connector=connector, command_prefix="/")
|
|
|
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
+
@bot.event
|
| 66 |
async def on_ready():
|
| 67 |
+
print(f"Logged in as {bot.user}")
|
| 68 |
|
| 69 |
+
@bot.event
|
| 70 |
async def on_message(message):
|
| 71 |
# 忽略自己的消息
|
| 72 |
+
if message.author == bot.user:
|
| 73 |
return
|
| 74 |
|
| 75 |
if message.content.startswith("!predict"):
|
|
|
|
| 78 |
await message.channel.send(result)
|
| 79 |
|
| 80 |
# 启动 Bot
|
| 81 |
+
bot.run(DISCORD_TOKEN)
|