MKE0108 commited on
Commit
729b742
·
1 Parent(s): 6675dca
Files changed (5) hide show
  1. .DS_Store +0 -0
  2. Dockerfile → Dockerfile +5 -1
  3. README.md +3 -4
  4. app.py +2 -1
  5. bot_main.py +56 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
Dockerfile → Dockerfile RENAMED
@@ -1,3 +1,6 @@
 
 
 
1
  FROM python:3.9
2
 
3
  RUN useradd -m -u 1000 user
@@ -10,4 +13,5 @@ COPY --chown=user ./requirements.txt requirements.txt
10
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
11
 
12
  COPY --chown=user . /app
13
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
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
 
13
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
14
 
15
  COPY --chown=user . /app
16
+ RUN python bot_main.py
17
+ # CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -1,10 +1,9 @@
1
  ---
2
- title: DiscordBot
3
- emoji: 🔥
4
  colorFrom: gray
5
- colorTo: blue
6
  sdk: docker
7
- app_port: 7860
8
  pinned: false
9
  ---
10
 
 
1
  ---
2
+ title: Test
3
+ emoji: 🐨
4
  colorFrom: gray
5
+ colorTo: indigo
6
  sdk: docker
 
7
  pinned: false
8
  ---
9
 
app.py CHANGED
@@ -1,6 +1,7 @@
1
  from fastapi import FastAPI
 
2
  app = FastAPI()
3
 
4
  @app.get("/")
5
  def greet_json():
6
- return {"Hello": "World!"}
 
1
  from fastapi import FastAPI
2
+
3
  app = FastAPI()
4
 
5
  @app.get("/")
6
  def greet_json():
7
+ return {"Hello": "World!"}
bot_main.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'))