MKE0108 commited on
Commit
51fe8a0
·
1 Parent(s): 7623e41
Files changed (4) hide show
  1. Dockerfile +0 -1
  2. README.md +8 -6
  3. app.py +0 -3
  4. bot_main.py +0 -56
Dockerfile CHANGED
@@ -10,5 +10,4 @@ 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
- # RUN python bot_main.py
14
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
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"]
README.md CHANGED
@@ -1,8 +1,10 @@
1
  ---
2
- title: Basic Docker SDK Space
3
- emoji: 🐳
4
- colorFrom: purple
5
- colorTo: gray
6
  sdk: docker
7
- app_port: 7860
8
- ---
 
 
 
1
  ---
2
+ title: DiscordBot
3
+ emoji: 🔥
4
+ colorFrom: gray
5
+ colorTo: blue
6
  sdk: docker
7
+ pinned: false
8
+ ---
9
+
10
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -1,9 +1,6 @@
1
  from fastapi import FastAPI
2
- import os
3
  app = FastAPI()
4
 
5
  @app.get("/")
6
  def greet_json():
7
- #跑python bot_main.py
8
- # os.system("python bot_main.py")
9
  return {"Hello": "World!"}
 
1
  from fastapi import FastAPI
 
2
  app = FastAPI()
3
 
4
  @app.get("/")
5
  def greet_json():
 
 
6
  return {"Hello": "World!"}
bot_main.py DELETED
@@ -1,56 +0,0 @@
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'))