三丰云搭建QQ-bot的服务器-代码实现(3)

网址:https://www.sanfengyun.com >> 三丰云免费云服务器

代码实现

书接上回装饰器,显而易见,只有装饰器还不完善,所以我们接着来补充代码

首先定义一个 MyClient 类

python 复制代码
class MyClient(botpy.Client):
    async def on_ready(self):
        _log.info(f"robot 「{self.robot.name}」 on_ready!")
# 加上这一条代码就能初步判断代码有没有成功跑起来了

接着补充测试代码

python 复制代码
judge_result = False
# 注册指令handler
handlers = [
    hello #可以继续补充
]
for handler in handlers:
if await handler(api=self.api, message=message):
    judge_result = True
    return  judge_result
if judge_result==False:
    messageResult = await message._api.post_group_message(
        group_openid=message.group_openid,
          msg_type=0, 
          msg_id=message.id,
          content=f"{bot_functions.repeater(message.content)}")
        _log.info(messageResult)

有了这段代码,里能够正常跑起来就不远了

相关推荐
网络小白不怕黑35 分钟前
10.邮件服务器搭建并脚本实现监控httpd状态
linux·运维·服务器
CN_HW1 小时前
Nginx 流量镜像配置文档-双轨国产化
服务器·前端·网络
jsons13 小时前
rocky8内网离线批量补丁(你之前搭建的架构,多台服务器首选,无订阅)
linux·运维·服务器
进击切图仔3 小时前
SAM3 微调标注流水线和 Label Studio
java·服务器·前端
Bomangedd3 小时前
NSK RA25BN 滚子直线导轨技术详解
运维·服务器·经验分享·规格说明书
本尊是喵4 小时前
AutoDL--FileZilla--VS Code远程连接
运维·服务器
网络小白不怕黑4 小时前
11.虚拟机模拟路由器实验
linux·运维·服务器·网络
Mapleay4 小时前
Linux 内核编程基础
linux·运维·服务器
小则又沐风a4 小时前
深入理解文件系统(二)
java·服务器·前端
Misnearch4 小时前
服务器redfish技术知识介绍
服务器·ipmi·bmc·redfish