This repository has been archived by the owner on Sep 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
78 lines (65 loc) · 2.52 KB
/
start.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import discord
from discord.ext import commands
import json
import service
from request.er_request import get_request
import request.get_data
import user.miyano_user as miyano_user
from result_image.cobalt import get_cobalt_image
import datetime
from conf import conf
bot = commands.Bot(command_prefix='/', help_command=None, intents=discord.Intents.all())
@bot.event
async def on_ready():
print(f'실험용 디스코드 봇 {bot.user}')
@bot.command()
async def say(message):
await message.reply('왈랄랄랄루~~~~~~')
@bot.command()
async def 전역(message):
await message.send(str((datetime.date(2023, 8, 7)-datetime.date.today()).days) + "ㅠㅠㅠ")
@bot.command()
async def recent(message, *arg):
if len(arg) == 0 or (len(arg) == 1 and arg[0] == "old"):
try:
user_str = miyano_user.get_er_nickname(message.author.id)
except:
await message.send('등록되지 않은 사용자입니다. /register 명령어를 통해 이터널 리턴 닉네임을 등록해주세요.')
return
else:
user_str = arg[0]
user_num = request.get_data.get_user_num(user_str)
req = request.get_data.get_user_game(user_num)
if len(arg) > 0 and arg[-1] == "old":
await message.reply(service.get_game_data(req[0]["gameId"], "text"))
else:
file_name = service.get_game_data(req[0]["gameId"], "image")
with open(f'/root/Miyano/temp_image/{file_name}.png', 'rb') as f:
await message.reply(file=discord.File(f))
@bot.command()
async def game(message, arg):
await message.send(service.get_game_data(arg, "text"))
# with open('/root/Miyano/temp_image/temp.png', 'rb') as f:
# await message.send(file=discord.File(f))
@bot.command()
async def register(message, er_nickname):
ret = miyano_user.register(message.author.id, er_nickname)
msg = f'{message.author.name}(discord) - {er_nickname}(ER) 등록 완료'
if not ret:
msg = '등록 실패'
await message.send(msg)
@bot.command()
async def failnote(message):
with open("/root/Miyano/document/failnote", 'r') as f:
await message.send(str(f.read()))
@bot.command()
async def help(message):
with open("/root/Miyano/document/help", 'r') as f:
await message.send(str(f.read()))
@bot.command()
async def debug(message, arg):
req = get_request(f'games/{arg}')
get_cobalt_image(req['userGames'], 'temp')
with open('/root/Miyano/temp_image/temp.png', 'rb') as f:
await message.send(file=discord.File(f))
bot.run(conf["discord-token"])