Python +酷Q机器人开发QQ群 机器人

安装酷Q机器人:
https://cqp.cc/t/23253/
pip install nonebot
自己看着下载
**安装插件 **
https://pan.baidu.com/s/1qY55zp6#list/path=%2F
将下载好的 插件放在 \app 就好
登入QQ 启动 插件
配置对应的 QQ.json 下面是我的路径
C:\Users\Administrator\Desktop\酷Q Air\data\app\io.github.richardchien.coolqhttpapi\config
配置完成重启

{
    "host": "[::]",
    "port": 5701,
    "use_http": true,
    "ws_host": "[::]",
    "ws_port": 6701,
    "use_ws": false,
    "ws_reverse_url": "ws://127.0.0.1:8081/ws/",
    "ws_reverse_api_url": "",
    "ws_reverse_event_url": "",
    "ws_reverse_reconnect_interval": 3000,
    "ws_reverse_reconnect_on_code_1000": true,
    "use_ws_reverse": true,
    "post_url": "",
    "access_token": "",
    "secret": "",
    "post_message_format": "string",
    "serve_data_files": false,
    "update_source": "china",
    "update_channel": "stable",
    "auto_check_update": false,
    "auto_perform_update": false,
    "show_log_console": true,
    "log_level": "info",
	"enable_heartbeat": true
}

bot.py 文件代码:

from os import path
import nonebot
import os,threading,time
import config
import requests
import schedule
import datetime
import threading
import pymysql
if __name__ == '__main__':
    nonebot.init(config)
    nonebot.load_plugins(
        path.join(path.dirname(__file__), 'awesome', 'plugins'),
        'awesome.plugins'
    )
    timer.start()
    nonebot.run()

confing.py 文件内容:

from nonebot.default_config import *
import re
SUPERUSERS = {1591547785}
NICKNAME = {'小明', '明明'}
COMMAND_START = {'', '/', '!', '/', '!'}
HOST = '127.0.0.1'
PORT = 8081
TULING_API_KEY = ''

启动bot.py 文件
这是接收群消息的处理注解 @on_command(“签到”, only_to_me=True)
把 only_to_me=True去了 就是私消息 处理
注意 表情 的话 要转 url码
参考文档:
nonebot官方文档:https://none.rclab.tk/guide/
cqhttp官方文档:https://cqhttp.cc/docs/4.10/#/
https://www.jianshu.com/p/58b2a329813a?_wv=1031

你可能感兴趣的:(python)