三丰云搭建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)

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

相关推荐
dualven_in_csdn13 小时前
mqtt消息及日志查看
linux·运维·服务器
Yupureki14 小时前
《MySQL数据库基础》9.索引原理
linux·运维·服务器·网络·数据库·mysql
Yupureki15 小时前
《MySQL数据库基础》8.复合查询
linux·运维·服务器·网络·数据库·mysql
方芯半导体15 小时前
ST系列MCU EtherCAT协议栈框架结构详解
服务器·网络·数据库·网络协议·机器人·自动化·工业以太网
上海云盾安全满满15 小时前
海外服务器使用高防CDN的优势
运维·服务器
Mortalbreeze15 小时前
进程间通信 ---- System V 共享内存
linux·运维·服务器
hyunbar15 小时前
腾讯云OpenClaw服务器配置AI绘画完整指南
服务器·ai作画·腾讯云
fiveym16 小时前
Debian 12 PXE 安装报错:Bad archive mirror 复合型故障排查全记录
运维·服务器·debian·php
xingyuzhisuan17 小时前
从零精通GPU服务器模型部署:标准化流程与性能调优实战
运维·服务器·人工智能
s_w.h17 小时前
【 linux 】文件管理与重定向
linux·运维·服务器