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

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

相关推荐
lqjun08271 小时前
Linux 下 Hermes Agent 代理配置不生效问题的解决
linux·服务器
c_lb72881 小时前
期货量化策略从 Windows 迁到 Linux 服务器:环境注意点
linux·服务器·windows·python
hweiyu001 小时前
Linux命令:newgrp
linux·运维·服务器
Full Stack Developme1 小时前
计算机加密与解密的历史
运维·服务器·网络·云计算
tedcloud1232 小时前
Supermemory部署教程:打造Agent记忆与RAG环境
服务器·人工智能·学习·自动化·powerpoint
m0_737302582 小时前
读懂OpenClaw:重塑人机交互的开源AI智能体
服务器
Web极客码2 小时前
使用人工智能翻译WordPress网站
服务器·人工智能·wordpress
IPDEEP全球代理2 小时前
静态住宅ip哪家好?2026年静态住宅ip测评
运维·服务器·网络
哆啦A梦15882 小时前
服务器基础知识
运维·服务器
大树882 小时前
本周液冷三件事 #2|Vera Rubin 227kW 全液冷量产 · 34 省 PUE 政策汇编 · 光模块也要液冷了
大数据·服务器·人工智能