From a7240b56fda2efa62487e767c7b20f65504e0e58 Mon Sep 17 00:00:00 2001 From: Ching Date: Sun, 24 Sep 2023 19:00:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(bot.py):=20=E5=A2=9E=E5=8A=A0=20mod=5Ffrie?= =?UTF-8?q?nd=20=E4=BF=AE=E6=94=B9=E6=9C=8B=E5=8F=8B=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加 mod_friend 修改朋友名字功能 Signed-off-by: Ching --- discord_bot.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/discord_bot.py b/discord_bot.py index 9d5bc02..c94c296 100644 --- a/discord_bot.py +++ b/discord_bot.py @@ -63,6 +63,17 @@ async def get_friends(ctx): msg += f'{friend.name} {friend.steam_id}\n' await ctx.respond(content=msg) +@bot.command(description='修改朋友信息', name='mod_friend') +async def mod_friend(ctx, steam_id, name): + logger.info(f'mod_friend {steam_id} {name}') + friend = dota.Friend.get_or_none(steam_id=steam_id) + if friend: + friend.name = name + friend.save() + await ctx.respond(content=f'修改成功 {steam_id} {name}') + else: + await ctx.respond(content=f'找不到 {steam_id}') + @tasks.loop(minutes=1) async def heartbeat(): utils.heartbeat()