import sqlite3 from pathlib import Path from random import choice from nonebot.plugin import on_command from nonebot.typing import Bot, Event from nonebot.permission import SUPERUSER from ATRI.utils.utils_error import errorRepo from ATRI.utils.utils_rule import check_banlist # States parameter: # ├info # └sqlite # * DEMO: status info status_info = on_command('/status', rule=check_banlist()) @status_info.handle() async def _(bot: Bot, event: Event, state: dict) -> None: msg = str(event.message).strip() if not msg: await status_info.finish("请查看文档获取帮助(") if msg == "info": try: cpu = psutil.cpu_percent(interval=1) memory = psutil.virtual_memory().percent disk = psutil.disk_usage('/').percent inteSENT = psutil.net_io_counters().bytes_sent # type: ignore
from nonebot.plugin import on_command from nonebot.typing import Bot, Event from nonebot.permission import GROUP_ADMIN, GROUP_OWNER, SUPERUSER from ATRI.utils.utils_yml import load_yaml from ATRI.utils.utils_error import errorRepo from ATRI.utils.utils_rule import check_banlist from ATRI.utils.utils_textcheck import PUBLIC_OPINION_PATH, Textcheck from ATRI.utils.utils_switch import controlSwitch CONFIG_PATH = Path('.') / 'config.yml' master = load_yaml(CONFIG_PATH)['bot']['superusers'] switch = on_command('/switch', rule=check_banlist(), permission=(SUPERUSER | GROUP_OWNER | GROUP_ADMIN)) @switch.handle() async def _(bot: Bot, event: Event, state: dict) -> None: user = str(event.user_id) group = str(event.group_id) func = str(event.message).strip() SWITCH_PATH = Path('.') / 'ATRI' / 'utils' / 'utils_rule' / 'switch.json' with open(SWITCH_PATH, 'r') as f: data = json.load(f) if not func: await switch.finish('请查看文档获取帮助(')
__author__ = 'kyomotoi' import re import json from nonebot.plugin import on_command from nonebot.typing import Bot, Event from ATRI.utils.utils_error import errorRepo from ATRI.utils.utils_img import aio_download_pics from ATRI.utils.utils_request import aio_get_bytes from ATRI.utils.utils_rule import check_banlist, check_switch plugin_name_0 = "pixiv-pic-search" pixivSearchIMG = on_command('p站搜图', rule=check_banlist() & check_switch(plugin_name_0, True)) @pixivSearchIMG.handle() async def _(bot: Bot, event: Event, state: dict) -> None: user = str(event.user_id) group = str(event.group_id) state["user"] = user state["group"] = group pid = str(event.message).strip() if pid: state["pid"] = pid
import re import random from time import strftime from datetime import datetime, timedelta from nonebot.plugin import on_command from nonebot.typing import Bot, Event from ATRI.utils.utils_error import errorRepo from ATRI.utils.utils_rule import check_banlist, check_switch from .data_source import Generate, Genshin, Roll, RCNB plugin_name_0 = "one-key-adult" generateID = on_command("我要转大人,一天打25小时游戏", aliases={'虚拟身份', '一键成年', '登dua郎'}, rule=check_banlist() & check_switch(plugin_name_0, True)) @generateID.handle() async def _(bot: Bot, event: Event, state: dict) -> None: NAME, AREA = Generate().infoID() BIRTH_BEGIN = datetime(*[1980, 10, 10]) # type: ignore BIRTH_END = datetime(*[2002, 10, 10]) # type: ignore id_card_area = int(random.choice(list(AREA.keys()))) id_card_area_name = AREA[str(id_card_area)] id_card_year_old = timedelta( days=random.randint(0, (BIRTH_END - BIRTH_BEGIN).days) + 1) id_card_birth_day = strftime("%Y%m%d",
# 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()) @keyRepo.handle() 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()) @keyRepoADD.handle() async def _(bot: Bot, event: Event, state: dict) -> None:
from ATRI.utils.utils_times import countX from ATRI.utils.utils_rule import check_banlist from ATRI.utils.utils_request import request_get from .data_source import dec BILI_REPORT_FORMAT = """[{aid}] Info: Title: {title} bid: {bid} Viev: {view} Like: {like} Coin: {coin} Share: {share} Link: {aid_link} {bid_link}""" bilibiliRich = on_message(rule=check_banlist()) b_list = [] @bilibiliRich.handle() async def _(bot: Bot, event: Event, state: dict) -> None: global b_list user = event.user_id msg = str(event.message) # 防刷屏机制:回复次数达到五次自动忽略下一次 if countX(b_list, user) == 5: return if "qqdocurl" not in msg: try:
from ATRI.utils.utils_history import getMessage from ATRI.utils.utils_translate import toSimpleString from ATRI.utils.utils_rule import check_banlist, check_switch from ATRI.utils.utils_request import aio_get_bytes, request_get from ATRI.utils.utils_img import compress_image, aio_download_pics from .data_source import resultRepo CONFIG_PATH = Path('.') / 'config.yml' config = load_yaml(CONFIG_PATH) plugin_name_0 = "anime-pic-search" key_SauceNAO = config['api']['SauceNaoKEY'] SaucenaoSearch = on_command('以图搜图', rule=check_banlist() & check_switch(plugin_name_0, True)) @SaucenaoSearch.handle() async def _(bot: Bot, event: Event, state: dict) -> None: user = str(event.user_id) group = str(event.group_id) state["user"] = user state["group"] = group img = str(event.message).strip() if img: state["img_url"] = img