├── dx.json ├── README.md └── serve.py /dx.json: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dxxQQbot 2 | 一键自动催收大学习截图,提醒懒狗刷大学习QQ机器人 3 | 4 | 本机器人依托与coolq及coolq-http-api插件,请自行去官网下载 5 | 6 | 使用前: 7 | 须进入脚本更改参数,然后给dx.json读写权限, 8 | 最后python2 build.py建立班级库,(机器人应入群,最好是加群员好友), 9 | nohup python2 serve.py & 10 | 后台运行 11 | 12 | 使用方法 13 | 14 | 向机器人提交截图后并输入“ok”(大小写敏感),则不再进行提醒。 15 | 向机器人输入“ccc”一键自动催命懒狗提交大学习截图。 16 | 向机器人输入“list”一键查询没有刷大学习的懒狗。 17 | 18 | 由于作者limu也是个懒狗,所以,本程序需要师傅们每星期自己重新启动一次 19 | 20 | 21 | 2020-06-07 22 | 23 | 进行了第一次的升级,添加了未提交截图懒狗的qq对应群昵称,添加管理员QQ,这样除了管理员,其他人发送指令是无效的 24 | 25 | 2020-06-27 26 | 27 | 添加新功能,输入build可以直接创建或重置dx.json文件,省却登录服务器执行build.py重置dx.json文件的麻烦 28 | -------------------------------------------------------------------------------- /serve.py: -------------------------------------------------------------------------------- 1 | #!coding: utf-8 2 | from flask import * 3 | from json import * 4 | import requests 5 | import sys 6 | import os 7 | 8 | reload(sys) 9 | sys.setdefaultencoding('utf8') 10 | 11 | bot_server = Flask(__name__) 12 | 13 | @bot_server.route('/api/message',methods=['POST']) 14 | ## coolq-http-api设定的路径 15 | def server(): 16 | api_url2 = 'http://IP:端口/send_msg' 17 | data_1 = request.get_data().decode('utf-8') 18 | print data_1 19 | data_2 = json.loads(data_1) 20 | #print(data) 21 | message = data_2['raw_message'] 22 | print message 23 | qq_id = data_2['user_id'] 24 | print qq_id 25 | manager_id = "管理员QQ" 26 | if message == 'ok': 27 | asd_dist = [] 28 | with open("./dx.json",'r') as p: 29 | dict = json.load(p) 30 | for load_dict in dict: 31 | if load_dict['user_id'] == qq_id: 32 | load_dict['status_id'] = '1' 33 | asd_dist.append(load_dict) 34 | with open('./dx.json','w') as g: 35 | json.dump(asd_dist,g) 36 | if message == 'list' and str(qq_id) == str(manager_id): 37 | with open("./dx.json",'r') as k: 38 | awd = json.load(k) 39 | for asd_list in awd: 40 | if asd_list['status_id'] == '0': 41 | msg1 = { 42 | "message_type":'private', 43 | "user_id":manager_id, 44 | "message":"QQ: " + str(asd_list['user_id']) + " 昵称:" + str(asd_list['user_name']).decode('utf-8'), 45 | "auto_escape":False 46 | } 47 | xbg = requests.post(api_url2,data=msg1) 48 | print(xbg) 49 | if message == 'ccc' and str(qq_id) == str(manager_id): 50 | with open("./dx.json",'r') as k: 51 | awd = json.load(k) 52 | for asd_list in awd: 53 | if asd_list['status_id'] == '0': 54 | msg2 = { 55 | "message_type":'private', 56 | "user_id":asd_list['user_id'], 57 | "message":"请大佬尽快将截图发给我这个机器人,并且给他回复一个ok(大小写注意),如果已经发过截图还受骚扰的,请再次给本机器人发一次截图,并且回复一个ok,最后请暴打本机器人制作者————limu。", 58 | "auto_escape":False 59 | } 60 | aaa = requests.post(api_url2,data=msg2) 61 | print(aaa) 62 | if message == 'build' and str(qq_id) == str(manager_id): 63 | os.system('python2 ./build.py') 64 | msg3 = { 65 | "message_type":'private', 66 | "user_id":manager_id, 67 | "message":"重置成功!\n 机器人制作者————limu。", 68 | "auto_escape":False 69 | } 70 | bbb = requests.post(api_url2,data=msg3) 71 | return '' 72 | 73 | 74 | 75 | if __name__ == '__main__': 76 | bot_server.run(host='0.0.0.0' , port=40002) 77 | ##coolq-http-api设定的端口 78 | 79 | --------------------------------------------------------------------------------