-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
435 additions
and
481 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,46 @@ | ||
{ | ||
"agreeAutoApprove": { "friend": 1, "group": 0 }, | ||
"numControl": { "maxNum": 5, "time": 2, "unit": "h" }, | ||
"maxViewNum": 20, | ||
"recipientList": ["1990248284"], | ||
"forwardSet": 0, | ||
"blackDict": { | ||
"friend": { "text": [], "id": [] }, | ||
"group": { "text": [], "id": [] }, | ||
"forward": {} | ||
}, | ||
"warnDict": { | ||
"friend": { "text": [], "id": [] }, | ||
"group": { "text": [], "id": [] }, | ||
"forward": {} | ||
}, | ||
"allowAddFriednText": [], | ||
"botName": "姚奕", | ||
"friend_msg": { | ||
"notice_msg": "请求添加好友,验证消息为", | ||
"welcome_msg": "你吼,我是姚奕!我的信息都会在我的说说更新,绝对不会骚扰到你滴!\n同时,如果有疑问,可以发送help哦" | ||
}, | ||
"group_msg": { | ||
"notice_msg": "发送群邀请,验证消息为", | ||
"welcome_msg": "很高兴有你的邀请,但要等我一下!" | ||
}, | ||
"statusDict": { | ||
"1184441051": { | ||
"agreeAutoApprove": { "friend": 1, "group": 1 }, | ||
"recipientList": ["1990248284"], | ||
"forwardSet": 0, | ||
"numControl": { | ||
"useAlgorithm": 0, | ||
"maxNum": 6, | ||
"time": 2, | ||
"unit": "h", | ||
"friend": { "maxNum": 6, "time": 2, "unit": "h" }, | ||
"group": { "maxNum": 5, "time": 2, "unit": "h" } | ||
}, | ||
"maxViewNum": 20, | ||
"blackDict": { | ||
"friend": { "status": "拉黑QQ,已拒绝,仅作提示" }, | ||
"group": { "status": "拉黑群聊,已拒绝,仅作提示" } | ||
"friend": { "text": [], "id": [] }, | ||
"group": { "text": [], "id": [] }, | ||
"forward": {} | ||
}, | ||
"warnDict": { | ||
"friend": { "status": "警告QQ,手动同意,是否同意" }, | ||
"group": { "status": "警告群聊,手动同意,是否同意" } | ||
"friend": { "text": [], "id": [] }, | ||
"group": { "text": [], "id": [] }, | ||
"forward": {} | ||
}, | ||
"allowAddFriednText": [], | ||
"botName": "姚奕", | ||
"friend_msg": { | ||
"notice_msg": "请求添加好友,验证消息为", | ||
"welcome_msg": "你吼,我是姚奕!我的信息都会在我的说说更新,绝对不会骚扰到你滴!\n同时,如果有疑问,可以发送help哦" | ||
}, | ||
"group_msg": { | ||
"notice_msg": "发送群邀请,验证消息为", | ||
"welcome_msg": "很高兴有你的邀请,但要等我一下!" | ||
}, | ||
"statusDict": { | ||
"blackDict": { | ||
"friend": { "status": "拉黑QQ,已拒绝,仅作提示" }, | ||
"group": { "status": "拉黑群聊,已拒绝,仅作提示" } | ||
}, | ||
"warnDict": { | ||
"friend": { "status": "警告QQ,手动同意,是否同意" }, | ||
"group": { "status": "警告群聊,手动同意,是否同意" } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,107 @@ | ||
|
||
|
||
|
||
from os.path import dirname,exists | ||
import copy | ||
from datetime import datetime | ||
from os.path import dirname, exists | ||
from nonebot import get_driver | ||
import json | ||
from nonebot.adapters.onebot.v11 import Bot | ||
from .utils import writeTime | ||
|
||
basedir = dirname(__file__) | ||
numPath=basedir+'/num.txt' | ||
configPath=basedir+'/config.json' | ||
requestorPath=basedir+'/requestor.json' | ||
max=5 | ||
blackLogPath=basedir+'/.json' | ||
def readData(path,content={}): | ||
# numDictPath=basedir+'/num.txt' | ||
configPath = f"{basedir}/config.json" | ||
requestorDictPath = f"{basedir}/requestor.json" | ||
numDictPath = f"{basedir}/num.json" | ||
max = 6 | ||
blackLogPath = f"{basedir}/blackLog.txt" | ||
|
||
|
||
def check_dict_key_bot_id(config: dict, requestorDict: dict, numDict: dict, bot: Bot): | ||
print(1) | ||
if config.get(bot.self_id) is None: | ||
config[bot.self_id] = copy.deepcopy(configModel) | ||
writeData(configPath, config) | ||
if requestorDict.get(bot.self_id) is None: | ||
requestorDict[bot.self_id] = copy.deepcopy(requestorDictModel) | ||
writeData(requestorDictPath, requestorDict) | ||
if numDict.get(bot.self_id) is None: | ||
numDict[bot.self_id] = copy.deepcopy(numDictModel) | ||
for type in numDict[bot.self_id].keys(): | ||
numDict[bot.self_id][type]["time"] = datetime.strptime( | ||
numDict[bot.self_id][type]["time"], "%Y-%m-%d %H:%M:%S.%f" | ||
) | ||
writeTime(numDictPath, numDict) | ||
# return True | ||
|
||
|
||
def readData(path, content={}, update=0) -> dict: | ||
if not exists(path): | ||
with open(path,'w',encoding='utf-8') as fp: | ||
json.dump(content,fp,ensure_ascii=False) | ||
with open(path,'r',encoding='utf-8') as fp: | ||
with open(path, "w", encoding="utf-8") as fp: | ||
json.dump(content, fp, ensure_ascii=False) | ||
with open(path, "r", encoding="utf-8") as fp: | ||
data = json.loads(fp.read()) | ||
return data | ||
def writeData(path,content): | ||
with open(path,'w',encoding='utf-8') as fp: | ||
json.dump(content,fp,ensure_ascii=False) | ||
|
||
|
||
def writeData(path, content): | ||
with open(path, "w", encoding="utf-8") as fp: | ||
json.dump(content, fp, ensure_ascii=False) | ||
|
||
|
||
# if not exists(configPath): | ||
recipientList=list(get_driver().config.superusers) | ||
recipientList = list(get_driver().config.superusers) | ||
# recipients=str(recipients)[1:-1].replace(' ','').replace("'",'') | ||
configModel={ | ||
"agreeAutoApprove": { "friend": 1, "group": 0 }, | ||
"numControl": {"maxNum":5,"time":2,"unit":'h'}, | ||
"maxViewNum":20, | ||
# 可以在这里修改默认模板哦 | ||
configModel = { | ||
"agreeAutoApprove": {"friend": 1, "group": 0}, | ||
"recipientList": recipientList[:2], | ||
"forwardSet":0, | ||
"blackDict":{"friend":{"text":[],"id":[]},"group":{"text":[],"id":[]},"forward":{}},#"群号":"管理员号,转发给其用来揪出在群里拉人头的人" | ||
"warnDict":{"friend":{"text":[],"id":[]},"group":{"text":[],"id":[]},"forward":{}}, | ||
"allowAddFriednText":[], | ||
"forwardSet": 0, | ||
"numControl": { | ||
"useAlgorithm": 0, | ||
"maxNum": 6, | ||
"time": 2, | ||
"unit": "h", | ||
"friend": {"maxNum": 6, "time": 2, "unit": "h"}, | ||
"group": {"maxNum": 2, "time": 8, "unit": "h"}, | ||
}, | ||
"maxViewNum": 20, | ||
"blackDict": { | ||
"friend": {"text": [], "id": []}, | ||
"group": {"text": [], "id": []}, | ||
"forward": {}, | ||
}, # "群号":"管理员号,转发给其用来揪出在群里拉人头的人" | ||
"warnDict": { | ||
"friend": {"text": [], "id": []}, | ||
"group": {"text": [], "id": []}, | ||
"forward": {}, | ||
}, | ||
"allowAddFriednText": [], | ||
"botName": "我", | ||
"friend_msg": { | ||
"notice_msg": "请求添加好友,验证消息为", | ||
"welcome_msg": "我未知的的朋友啊,很高兴你添加我为qq好友哦!\n同时,如果有疑问,可以发送/help哦" | ||
"welcome_msg": "我未知的的朋友啊,很高兴你添加我为qq好友哦!\n同时,如果有疑问,可以发送/help哦", | ||
}, | ||
"group_msg": { | ||
"notice_msg": "发送群邀请,验证消息为", | ||
"welcome_msg": "我亲爱的的朋友啊,很高兴你邀请我哦!" | ||
"group_msg": {"notice_msg": "发送群邀请,验证消息为", "welcome_msg": "我亲爱的的朋友啊,很高兴你邀请我哦!"}, | ||
"statusDict": { | ||
"blackDict": { | ||
"friend": {"status": "拉黑QQ,已拒绝,仅作提示"}, | ||
"group": {"status": "拉黑群聊,已拒绝,仅作提示"}, | ||
}, | ||
"warnDict": { | ||
"friend": {"status": "警告QQ,手动同意,是否同意"}, | ||
"group": {"status": "警告群聊,手动同意,是否同意"}, | ||
}, | ||
}, | ||
"statusDict":{ | ||
"blackDict":{"friend":{"status":"拉黑QQ,已拒绝,仅作提示"},"group":{"status":"拉黑群聊,已拒绝,仅作提示"}}, | ||
"warnDict":{"friend":{"status":"警告QQ,手动同意,是否同意"},"group":{"status":"警告群聊,手动同意,是否同意"}} | ||
} | ||
} | ||
config=readData(configPath,configModel) | ||
requestorDict=readData(requestorPath,{"friend":{},"group":{}}) | ||
# if not exists(requestorPath): | ||
# requestorDict={} | ||
# with open(requestorPath,'w',encoding='utf-8') as fp: | ||
# json.dump(requestorDict,fp,ensure_ascii=False) | ||
|
||
# with open(requestorPath,'r',encoding='utf-8') as fp: | ||
# requestorDict=json.loads(fp.read()) | ||
# blackDictFriend=config["blackDict"]['friend'] | ||
# warnDictFriend=config["warnDict"]['friend'] | ||
# blackDictGroup=config["blackDict"]['group'] | ||
# warnDictGroup=config["warnDict"]['group'] | ||
|
||
|
||
requestorDictModel = {"friend": {}, "group": {}} | ||
numDictModel = { | ||
"friend": {"count": 0, "time": str(datetime.now())}, | ||
"group": {"count": 0, "time": str(datetime.now())}, | ||
} | ||
config = readData(configPath) | ||
requestorDict = readData(requestorDictPath) | ||
numDict = readData(numDictPath) | ||
for bot_id in numDict.keys(): | ||
for type in numDict[bot_id].keys(): | ||
numDict[bot_id][type]["time"] = datetime.strptime( | ||
numDict[bot_id][type]["time"], "%Y-%m-%d %H:%M:%S.%f" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"1184441051": {"friend": {"count": 0, "time": "2024-01-08 01:53:02.962721"}, "group": {"count": 0, "time": "2024-01-08 01:53:02.962741"}}} |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.