summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ATRI/plugins/plugin_admin/__init__.py98
-rw-r--r--ATRI/plugins/plugin_admin/key_repo_waiting.json1
-rw-r--r--ATRI/plugins/plugin_chat/__init__.py125
-rw-r--r--ATRI/plugins/plugin_chat/key_repo.json1
-rw-r--r--ATRI/plugins/plugin_utils/__init__.py7
5 files changed, 168 insertions, 64 deletions
diff --git a/ATRI/plugins/plugin_admin/__init__.py b/ATRI/plugins/plugin_admin/__init__.py
index 7dd18e7..4ba222a 100644
--- a/ATRI/plugins/plugin_admin/__init__.py
+++ b/ATRI/plugins/plugin_admin/__init__.py
@@ -14,7 +14,7 @@ import re
import json
import asyncio
from pathlib import Path
-from random import randint
+from random import randint, sample
from nonebot.plugin import on_command
from nonebot.typing import Bot, Event
@@ -29,7 +29,7 @@ from ATRI.utils.utils_switch import controlSwitch
CONFIG_PATH = Path('.') / 'config.yml'
master = load_yaml(CONFIG_PATH)['bot']['superusers']
-switch = on_command('switch',
+switch = on_command('/switch',
rule=check_banlist(),
permission=(SUPERUSER | GROUP_OWNER | GROUP_ADMIN))
@@ -46,9 +46,9 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
if not func:
msg0 = "-==ATRI Switch Control System==-\n"
- msg0 += "Usage: switch on/off-{service}\n"
+ msg0 += "Usage: /switch on/off-{service}\n"
msg0 += "* For SUPERUSER:\n"
- msg0 += " - Usage: switch all-on/off-{service}\n"
+ msg0 += " - Usage: /switch all-on/off-{service}\n"
msg0 += "Service:\n"
for i in data.keys():
@@ -83,7 +83,9 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
# 舆情监控系统
-publicOpinion = on_command("舆情", rule=check_banlist(), permission=SUPERUSER)
+publicOpinion = on_command("/pubopin",
+ rule=check_banlist(),
+ permission=SUPERUSER)
@publicOpinion.handle()
@@ -96,12 +98,10 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
if msg[0] == '':
msg0 = "---=====ATRI POM System=====---\n"
msg0 += "Usage:\n"
- msg0 += " - 舆情 [key] [repo] [times] [ban time(bot)]\n"
- msg0 += " - 舆情 del [key]\n"
- msg0 += " - 舆情 list\n"
+ msg0 += " - /pubopin [key] [repo] [times] [ban time(bot)]\n"
+ msg0 += " - /pubopin del [key]\n"
+ msg0 += " - /pubopin list\n"
msg0 += "Tips:\n"
- msg0 += " - 非 SUPERU 只能设置本群\n"
- msg0 += " - SUPERU 需在后跟随 -a 以启用全局效果\n"
msg0 += " - 参数类型:\n"
msg0 += " * key: 关键词(将使用正则匹配)\n"
msg0 += " * repo: 触发后的关键词(可选),如为图片,键入 img\n"
@@ -118,39 +118,21 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
for w in data.keys():
msg0 += f' {w}\n'
- if msg[0] and msg[1] and msg[2] and msg[3]:
- pass
- else:
- msg0 = "请检查格式奥~!\n"
- msg0 += "舆情 [key] [repo] [times] [ban time(bot)]\n"
- msg0 += " * key: 关键词(将使用正则匹配)\n"
- msg0 += " * repo: 触发后的关键词(可选),如为图片,键入 img\n"
- msg0 += " * times: 容忍次数(n>0, int)\n"
- msg0 += " * ban time: bot对其失效时间(min, int)"
- await publicOpinion.finish(msg0)
+ if not msg[0] or not msg[1] or not msg[2] or not msg[3]:
+ await publicOpinion.finish("ごんめなさい...请检查格式嗷...")
- key = msg[0]
- repo = msg[1]
- max_times = msg[2]
- ban_time = msg[3]
+ if not re.findall(r"/^\d{1,}$/", msg[2]) or not re.findall(
+ r"/^\d{1,}$/", msg[3]):
+ await publicOpinion.finish("非法字符!咱不接受除int以外的类型!!")
- if key and repo and max_times and ban_time:
- if not re.findall(r"/^\d{1,}$/", max_times) and re.findall(
- r"/^\d{1,}$/", ban_time):
- await publicOpinion.finish("非法字符!请注意(times, ban time)类型为int(阿拉伯数字)"
- )
-
- else:
- await publicOpinion.finish("请键入完整信息!\n如需帮助,请键入:舆情")
-
- if repo == "img":
- state["key"] = key
- state["max_times"] = max_times
- state["ban_time"] = ban_time
+ if msg[1] == "img":
+ state["key"] = msg[0]
+ state["max_times"] = msg[2]
+ state["ban_time"] = msg[3]
else:
await publicOpinion.finish(Textcheck().add_word(
- key, repo, int(max_times), int(ban_time)))
+ msg[0], msg[1], int(msg[2]), int(msg[3])))
@publicOpinion.got("repo", prompt="检测到 repo 类型为 img,请发送一张图片")
@@ -167,7 +149,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
int(ban_time)))
-trackError = on_command("track", permission=SUPERUSER)
+trackError = on_command("/track", permission=SUPERUSER)
file_error = Path('.') / 'ATRI' / 'data' / 'data_Error' / 'error.json'
@@ -203,7 +185,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
await trackError.finish("未发现该ID")
-groupSendMessage = on_command("群发", permission=SUPERUSER)
+groupSendMessage = on_command("/groupsend", permission=SUPERUSER)
@groupSendMessage.handle()
@@ -248,3 +230,39 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
repo_msg += msg0
await groupSendMessage.finish(repo_msg)
+
+
+# keyRepoAddReview = on_command('关键词审核', permission=SUPERUSER)
+# KEY_PATH = Path('.') / 'ATRI' / 'plugins' / 'plugin_chat' / 'key_repo.json'
+# KEY_WAITING_PATH = Path(
+# '.') / 'ATRI' / 'plugins' / 'plugin_admin' / 'key_repo_waiting.json'
+# with open(KEY_PATH, 'r', encoding='utf-8') as f:
+# data = json.load(f)
+# with open(KEY_WAITING_PATH, 'r', encoding='utf-8') as f:
+# data_rev = json.load(f)
+
+
+# @keyRepoAddReview.got('rev')
+# @keyRepoAddReview.args_parser
+# async def _(bot: Bot, event: Event, state: dict) -> None:
+# rev = state['rev']
+# key = sample(data_rev.keys(), 1)
+# await bot.send(
+# event,
+# f'Key: {data_rev[key]}\nRepo: {data_rev[key][0]}\nProba: {data_rev[key][1]}\nSender: {data_rev[key][2]}\nGroup: {data_rev[key][3]}\nTime: {data_rev[key][4]}'
+# )
+
+# if rev == '歇了':
+# await keyRepoAddReview.finish("むー……ご苦労様でしたよ。")
+# else:
+# if rev == '通过' or rev == '过' or rev == '好' or rev == 'y':
+# await bot.send(event, '好!')
+# data[data_rev[key]] = [
+# data_rev[key][0], data_rev[key][1], data_rev[key][2],
+# data_rev[key][3], data_rev[key][4]
+# ]
+# with open(KEY_PATH, 'w') as f:
+# f.write(data)
+# elif rev == '不行' or rev == '不' or rev == 'n':
+# del data_rev[key]
+# await bot.send(event, '好8')
diff --git a/ATRI/plugins/plugin_admin/key_repo_waiting.json b/ATRI/plugins/plugin_admin/key_repo_waiting.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/ATRI/plugins/plugin_admin/key_repo_waiting.json
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/ATRI/plugins/plugin_chat/__init__.py b/ATRI/plugins/plugin_chat/__init__.py
index a2bab74..0474d46 100644
--- a/ATRI/plugins/plugin_chat/__init__.py
+++ b/ATRI/plugins/plugin_chat/__init__.py
@@ -11,7 +11,9 @@
__author__ = 'kyomotoi'
import os
+import re
import json
+import time
from pathlib import Path
from random import choice
from random import randint
@@ -24,7 +26,7 @@ from nonebot.rule import to_me
from nonebot.sched import scheduler
from nonebot.typing import Bot, Event
from nonebot.permission import SUPERUSER
-from nonebot.plugin import on_command, on_message, on_notice, on_request
+from nonebot.plugin import on_command, on_message, on_notice, on_request, on_regex
from ATRI.utils.utils_times import countX
from ATRI.utils.utils_yml import load_yaml
@@ -61,6 +63,90 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
)
+# ======================================================================
+# · 关键词回复,使用 json 存储,包含人设固定回复,以及咱添加的亿小部分
+# · 添加关键词位于此处,审核位于 plugin_admin 文件下。
+# Usage:
+# - /learnrepo [key] [repo] [proba]
+# For SUPERUSER:
+# - 关键词审核
+# - /learnrepo del [key]
+# Tips:
+# - 普通用户添加需等维护者审核
+# - 参数类型:
+# * key: 关键词(for匹配)
+# * repo: 回复
+# * proba: 机率(x>=1)(int)
+# ======================================================================
+KEY_PATH = Path('.') / 'ATRI' / 'plugins' / 'plugin_chat' / 'key_repo.json'
+KEY_WAITING_PATH = Path(
+ '.') / 'ATRI' / 'plugins' / 'plugin_admin' / 'key_repo_waiting.json'
+with open(KEY_PATH, 'r', encoding='utf-8') as f:
+ data = json.load(f)
+with open(KEY_WAITING_PATH, 'r', encoding='utf-8') as f:
+ data_rev = json.load(f)
+
+keyRepo = on_message(rule=check_banlist())
+
+
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ for key in data.keys():
+ proba = randint(1, data[key][1])
+ if proba == 1:
+ await keyRepo.finish(data.get(key, None))
+
+
+keyRepoADD = on_command('/learnrepo', rule=check_banlist())
+
+
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = event.user_id
+ group = event.group_id
+ msg = str(event.message).strip(' ')
+
+ if not msg:
+ await keyRepoADD.finish("请查看文档获取帮助(")
+
+ if not msg[0] or not msg[1] or not msg[2]:
+ await keyRepoADD.finish("ごんめなさい...请检查格式嗷...")
+
+ if not re.findall(r"/^\d{1,}$/", msg[2]):
+ await keyRepoADD.finish("非法字符!咱不接受除int以外的类型!!")
+
+ if msg[0] in data or msg[0] in data_rev:
+ await keyRepoADD.finish("相关关键词咱已经学习过了呢...")
+
+ msg0 = f"Key: {msg[0]}\n"
+ msg0 += f"Repo: {msg[1]}\n"
+ msg0 += f"Proba: {msg[2]}\n"
+
+ if user in master:
+ data[msg[0]] = [
+ msg[1], msg[2], user, group,
+ time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
+ ]
+
+ with open(KEY_PATH, 'w') as f:
+ f.write(json.dumps(data))
+ msg0 = "学習しました~!"
+
+ else:
+ data_rev[msg[0]] = [
+ msg[1], msg[2], user, group,
+ time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
+ ]
+
+ with open(KEY_WAITING_PATH, 'w') as f:
+ f.write(json.dumps(data_rev))
+ msg0 += "请等待咱主人审核嗷~"
+
+ await keyRepoADD.finish(msg0)
+
+
+# ========================[结束关键词回复部分]==========================
+
# Call bot
callMe = on_message(rule=check_banlist())
@@ -70,9 +156,12 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
msg = str(event.raw_event['raw_message']).strip()
if "萝卜子" in msg:
- await bot.send(event, "萝卜子是对咱的蔑称!!")
+ rep = choice(["萝卜子是对咱的蔑称!!", "差不多得了😅", "这好吗?这不好!", "吃咱一发火箭拳——!"])
+ await callMe.finish("萝卜子是对咱的蔑称!!")
elif msg in config['nickname']:
+ if event.user_id in master:
+ rep = choice(["w", "~~", ""])
await callMe.finish("叫咱有啥事吗w")
@@ -179,25 +268,22 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
# 控制 加好友 / 拉群 认证,默认关闭
-controlSelfEvent = on_command('selfevent', permission=SUPERUSER)
+# Tips:
+# - For SUPERUSERS
+# - Normal all false
+# Usage:
+# - selfevent group-true/false
+# - selfevent friend-true/false
+controlSelfEvent = on_command('/selfevent', permission=SUPERUSER)
@controlSelfEvent.handle()
async def _(bot: Bot, event: Event, state: dict) -> None:
args = str(event.message).strip()
- msg0 = ''
global FRIEND_ADD, GROUP_INVITE
if not args:
- msg0 = '-==ATRI INVITE Control System==-\n'
- msg0 += 'Tips:\n'
- msg0 += ' - For SUPERUSERS\n'
- msg0 += ' - Normal all false\n'
- msg0 += 'Usage:\n'
- msg0 += ' - selfevent group-true/false\n'
- msg0 += ' - selfevent friend-true/false\n'
-
- await controlSelfEvent.finish(msg0)
+ await controlSelfEvent.finish("请查看文档获取帮助(")
if 'group-' in args:
if 'true' in args:
@@ -206,7 +292,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
if 'true' in args:
FRIEND_ADD = 1
else:
- await controlSelfEvent.finish(msg0)
+ await controlSelfEvent.finish("请查看文档获取帮助(")
await controlSelfEvent.finish('DONE!')
@@ -364,6 +450,10 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
# 清除漂流瓶
+# *For SUPERUSERS
+# - delall
+# - del [num]
+# eg: 清除漂流瓶 del 123
delDriftingBottle = on_command('清除漂流瓶',
rule=check_banlist(),
permission=SUPERUSER)
@@ -374,13 +464,8 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
args = str(event.message).strip()
if not args:
- msg0 = 'Drifting Bottle:\n'
- msg0 += '*For SUPERUSERS'
- msg0 += '- delall\n'
- msg0 += '- del [num]\n'
- msg0 += 'eg: 清除漂流瓶 del 123'
- await delDriftingBottle.finish(msg0)
+ await delDriftingBottle.finish("请查看文档获取帮助(")
if not DRIFTING_BOTTLE_PATH.is_file():
with open(DRIFTING_BOTTLE_PATH, 'w') as f:
diff --git a/ATRI/plugins/plugin_chat/key_repo.json b/ATRI/plugins/plugin_chat/key_repo.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/ATRI/plugins/plugin_chat/key_repo.json
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/ATRI/plugins/plugin_utils/__init__.py b/ATRI/plugins/plugin_utils/__init__.py
index 16a57d2..177d523 100644
--- a/ATRI/plugins/plugin_utils/__init__.py
+++ b/ATRI/plugins/plugin_utils/__init__.py
@@ -24,7 +24,7 @@ from .data_source import Generate, Genshin, Roll
plugin_name_0 = "one-key-adult"
generateID = on_command("我要转大人,一天打25小时游戏",
- aliases={'虚拟身份', '一键成年'},
+ aliases={'虚拟身份', '一键成年', '登dua郎'},
rule=check_banlist()
& check_switch(plugin_name_0, True))
@@ -48,7 +48,6 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
id_card_birth_day) # type: ignore
msg0 = "恭喜,你已经成大人了!\n"
- msg0 += "这是你一天25h游戏的通行证:\n"
msg0 += f"NumberID: {id_card_id}\n"
msg0 += f"Sex: {'男' if id_card_sex == 1 else '女'}\n"
msg0 += f"Name: {id_card_name} || Address: {id_card_area_name}\n"
@@ -58,7 +57,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
await generateID.finish(msg0)
-rollD = on_command("roll", rule=check_banlist())
+rollD = on_command("/roll", rule=check_banlist())
@rollD.handle()
@@ -81,7 +80,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
plugin_name_1 = 'genshin-search'
-genshinInfo = on_command('genshin',
+genshinInfo = on_command('/genshin',
rule=check_banlist()
& check_switch(plugin_name_1, True))