Spaces:
Paused
Paused
add
Browse files- Dockerfile +16 -0
- app.py +56 -0
- keys/__pycache__/init.cpython-39.pyc +0 -0
- keys/init.py +4 -0
- requirement.txt → requirements.txt +1 -0
Dockerfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
+
# you will also find guides on how best to write your Dockerfile
|
| 3 |
+
|
| 4 |
+
FROM python:3.9
|
| 5 |
+
|
| 6 |
+
RUN useradd -m -u 1000 user
|
| 7 |
+
USER user
|
| 8 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 9 |
+
|
| 10 |
+
WORKDIR /app
|
| 11 |
+
|
| 12 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 13 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 14 |
+
|
| 15 |
+
COPY --chown=user . /app
|
| 16 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import discord
|
| 2 |
+
from discord.ext import commands
|
| 3 |
+
import os
|
| 4 |
+
if(os.getenv('BOT_TOKENS') == None):
|
| 5 |
+
from keys import init
|
| 6 |
+
intents = discord.Intents.default()
|
| 7 |
+
intents.message_content = True
|
| 8 |
+
|
| 9 |
+
bot = commands.Bot(command_prefix='!', intents=intents)
|
| 10 |
+
|
| 11 |
+
@bot.event
|
| 12 |
+
async def on_ready():
|
| 13 |
+
print(f'{bot.user} 已連線到 Discord!')
|
| 14 |
+
|
| 15 |
+
@bot.command()
|
| 16 |
+
async def synccommands(ctx):
|
| 17 |
+
await bot.tree.sync()
|
| 18 |
+
await ctx.send('同步完成')
|
| 19 |
+
|
| 20 |
+
@bot.hybrid_command(description="這個指令會回覆你的問候")
|
| 21 |
+
async def hello(ctx):
|
| 22 |
+
await ctx.send(f'你好 {ctx.author.name}!')
|
| 23 |
+
|
| 24 |
+
@bot.hybrid_command(description="測試延遲")
|
| 25 |
+
async def ping(ctx):
|
| 26 |
+
await ctx.send(f'Pong! 延遲: {round(bot.latency * 1000)}ms')
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
@bot.hybrid_command(description="顯示機器人資訊")
|
| 30 |
+
async def info(ctx):
|
| 31 |
+
embed = discord.Embed(title="機器人資訊", color=0x00ff00)
|
| 32 |
+
embed.add_field(name="名稱", value=bot.user.name, inline=True)
|
| 33 |
+
embed.add_field(name="ID", value=bot.user.id, inline=True)
|
| 34 |
+
embed.add_field(name="伺服器數量", value=len(bot.guilds), inline=True)
|
| 35 |
+
await ctx.send(embed=embed)
|
| 36 |
+
|
| 37 |
+
@bot.hybrid_command(description="抽路線指令, 用法: !pick 人名1 人名2 人名3 ...")
|
| 38 |
+
async def pick(ctx,str):
|
| 39 |
+
import random
|
| 40 |
+
player = str.split(' ')
|
| 41 |
+
if(len(player) > 5):
|
| 42 |
+
await ctx.send('請輸入<5個人')
|
| 43 |
+
return
|
| 44 |
+
lane=["🗡️ 上路","💰 打野","🔮 中路","🏹 下路","🚑 輔助"]
|
| 45 |
+
while(len(player) < 5):
|
| 46 |
+
player.append("---")
|
| 47 |
+
random.shuffle(player)
|
| 48 |
+
embed = discord.Embed(title="抽獎結果", color=0x00ff00)
|
| 49 |
+
for i in range(len(player)):
|
| 50 |
+
embed.add_field(value=player[i], name=lane[i], inline=False)
|
| 51 |
+
solgan = ["我從不覺得在召喚峽谷快樂過","一但加入了召喚峽谷就再也回不去了","我們的遊戲就是要讓你們不開心","你們的不開心就是我們的快樂","你們滿腦子只想著自己","還真是虛情假義呢"]
|
| 52 |
+
|
| 53 |
+
await ctx.send(random.sample(solgan,1)[0],embed=embed)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
bot.run(os.getenv('BOT_TOKENS'))
|
keys/__pycache__/init.cpython-39.pyc
ADDED
|
Binary file (349 Bytes). View file
|
|
|
keys/init.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
BOT_TOKENS="MTI4MDAwMDE1MzQ2OTcxNDQ2NA.GwY-6B.a-Jd9H3wwle-FHHGZuZz_IuLV-oKilPWGZl3kM"
|
| 3 |
+
#把BOT_TOKENS的值寫到環境變數
|
| 4 |
+
os.environ['BOT_TOKENS'] = BOT_TOKENS
|
requirement.txt → requirements.txt
RENAMED
|
@@ -1,2 +1,3 @@
|
|
| 1 |
fastapi
|
|
|
|
| 2 |
uvicorn[standard]
|
|
|
|
| 1 |
fastapi
|
| 2 |
+
discord.py
|
| 3 |
uvicorn[standard]
|