From fa94f38536e0b8c41d3021d2e8ab023893a2eadb Mon Sep 17 00:00:00 2001 From: Ching Date: Thu, 1 Feb 2024 11:49:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(discord=5Fbot):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=8B=E5=8F=8B=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加添加朋友功能 Signed-off-by: Ching --- discord_bot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/discord_bot.py b/discord_bot.py index 032d784..2249ac4 100644 --- a/discord_bot.py +++ b/discord_bot.py @@ -75,6 +75,16 @@ async def mod_friend(ctx, steam_id, name): else: await ctx.respond(content=f'找不到 {steam_id}') +@bot.command(description='添加朋友', name='add_friend') +async def add_friend(ctx, steam_id, name): + logger.info(f'add_friend {steam_id} {name}') + friend = dota.Friend.get_or_none(steam_id=steam_id) + if friend: + await ctx.respond(content=f'已经存在 {steam_id} {name}') + else: + friend = dota.Friend.create(steam_id=steam_id, name=name) + await ctx.respond(content=f'添加成功 {steam_id} {name}') + @tasks.loop(minutes=1) async def heartbeat(): utils.heartbeat()