Compare commits

...
39 Commits
Author SHA1 Message Date
HibiKier 00b674cebb Update setu.py 2021-09-09 18:16:15 +08:00
HibiKier 8ac440335e Update README.md 2021-09-09 17:17:13 +08:00
HibiKier 4b1821ce42 Update query_resource.py 2021-09-09 17:15:26 +08:00
HibiKier 3ad955abf9 Update image_utils.py 2021-09-09 17:14:33 +08:00
HibiKier 5fabb974ce Update config.py 2021-09-09 16:39:37 +08:00
HibiKier 5325bc3e32 Update init_config.py 2021-09-09 16:39:03 +08:00
HibiKier 6688c4626b Update update_info.json 2021-09-09 16:26:29 +08:00
HibiKier 2b95ab3d7e Update init_config.py 2021-09-09 16:25:42 +08:00
HibiKier 23e6d7e27e Update config.py 2021-09-09 16:25:09 +08:00
HibiKier 2760e22336 Update update_info.json 2021-09-09 16:05:48 +08:00
HibiKier d026d09f98 Update __version__ 2021-09-09 16:04:34 +08:00
HibiKier e6fd1ce791 Update README.md 2021-09-09 16:02:58 +08:00
HibiKier 342eaa9a97 Update pixiv.py 2021-09-09 16:02:12 +08:00
HibiKier dc7681357e Update omega_pixiv_illusts.py 2021-09-09 16:01:50 +08:00
HibiKier b61cb49c1a Update setu.py 2021-09-09 16:01:35 +08:00
HibiKier c7b341393d Update setu.py 2021-09-09 14:30:42 +08:00
HibiKier 1f9fa2adb9 Update README.md 2021-09-09 12:59:23 +08:00
HibiKier 133b927d9d Update __version__ 2021-09-09 10:53:37 +08:00
HibiKier 46e6b26d75 Update README.md 2021-09-09 10:51:50 +08:00
hibiki 8d0b0e5505 update code 2021-09-09 10:47:26 +08:00
HibiKier 754a0c111c Update README.md 2021-09-08 15:16:58 +08:00
HibiKier 81ef3f04e4 Update group_user_checkin.py 2021-09-08 11:05:23 +08:00
HibiKier e7c00484b3 Update README.md 2021-09-07 11:17:19 +08:00
HibiKier 065432448f Merge pull request #40 from Ailitonia/patch-1
Fix: Check info_list to avoid TypeError
2021-09-07 11:11:38 +08:00
HibiKier 5d45a9c28a Update README.md 2021-09-07 11:08:43 +08:00
Ailitonia 7db5b3b5c0 Fix: Check info_list to avoid TypeError 2021-09-07 02:08:56 +08:00
HibiKier 5eb64060dc Update data_source.py 2021-09-06 21:14:26 +08:00
HibiKier 2c4877b9f8 Update update_info.json 2021-09-06 21:10:44 +08:00
HibiKier 218dad3b86 fix bilibili_sub 2021-09-06 21:03:50 +08:00
HibiKier 974c6b106a Update update_info.json 2021-09-06 20:42:06 +08:00
HibiKier 954b281b69 Update data_source.py 2021-09-06 18:09:16 +08:00
HibiKier b1b15b63a1 Update data_source.py 2021-09-06 18:03:21 +08:00
HibiKier 49567aa958 Update __version__ 2021-09-05 13:57:27 +08:00
HibiKier a7a470066b Update update_info.json 2021-09-05 13:57:06 +08:00
HibiKier 4e3010d75e Update data_source.py 2021-09-05 13:56:29 +08:00
HibiKier cbacd726ef Update __init__.py 2021-09-05 13:54:55 +08:00
HibiKier 58a1fc1ca0 Update __version__ 2021-09-05 13:06:41 +08:00
HibiKier a704f88d75 Update update_info.json 2021-09-05 13:05:06 +08:00
HibiKier 10d0ad7d47 Update update_info.json 2021-09-05 12:15:47 +08:00
24 changed files with 229 additions and 469 deletions
+25 -152
View File
@@ -2,7 +2,7 @@
![maven](https://img.shields.io/badge/python-3.8%2B-blue)
![maven](https://img.shields.io/badge/nonebot-2.0.0-yellow)
![maven](https://img.shields.io/badge/go--cqhttp-0.9.40--fix4-red)
![maven](https://img.shields.io/badge/go--cqhttp-1.0.0-red)
# 绪山真寻Bot
****
@@ -11,7 +11,9 @@
用爱发电,某些功能学习借鉴了大佬们的代码,因为绪山真寻实在太可爱了因此开发了
绪山真寻bot,实现了一些对群友的娱乐功能和实用功能(大概)。
如果该项目的图片等等侵犯猫豆腐老师权益请联系我删除!
如果该项目的图片等等侵犯猫豆腐老师权益请联系我删除!
如果希望有个地方讨论绪山真寻Bot,或者有问题或建议,可以发送issues或加入[ <strong>[是真寻酱哒](https://jq.qq.com/?_wv=1027&k=u8PgBkMZ) </strong>]
## 声明
此项目仅用于学习交流,请勿用于非法用途
@@ -286,7 +288,7 @@ pip install -r requirements.txt
python bot.py
```
## 配置(暂时不更新 json 配置,请将USE_CONFIG_FILE设置为False)
## 配置
在 configs/config.py 中的 USE_CONFIG_FILE,默认为False
```
@@ -302,167 +304,38 @@ python bot.py
在./configs/config.py中配置基本配置(除API KEY ,数据库和代理外都含有默认值)
在./configs/path_config.py配置路径(含有默认配置)
########(暂时不更新 json 配置,请将USE_CONFIG_FILE设置为False,直接进入./configs/config.py进行配置)
# 是否使用配置文件(为True时这将会生成三份配置文件
./config.json:主要配置
./configs/plugins2cmd_config.json: 功能模块与对应命令配置
./configs/other_config.json: 一些插件配置)
USE_CONFIG_FILE = True
USE_CONFIG_FILE = False
# 如果不使用配置文件,将USE_CONFIG_FILE设置为False
#可在./configs/config.py文件中修改配置,在./configs/path_config.py修改资源路径
# 已在./configs/config.py和./configs/path_config.py中为各个配置提供注解!
```
## 配置文件注解(如果使用配置文件的话)
<details>
<summary>配置文件注解</summary>
./config.json
```
{
# 必填(影响功能运行)
"apikey": {
"LOLICON_KEY": "", # loliconAPI,缺失会导致色图功能异常
"TL_KEY": [] # 图灵Key(为什么要用列表?因为白嫖用户能拿5个apikey,每个apikey每日限制100条)
},
# (必填!!!)
# 数据库配置(如果填写了bind,后面就不用再填了)只是帮你拼接好)
# 示例:"bind": "postgresql://user:password@127.0.0.1:5432/database"
"sql": {
"bind": "",
"sql_name": "",
"user": "",
"password": "",
"address": "",
"port": "",
"database": ""
},
# 路径设置(不填则使用默认)
"path": {
"IMAGE_PATH": "", # 图片路径
"VOICE_PATH": "", # 音频路径
"TXT_PATH": "", # 文本路径
"LOG_PATH": "", # 日志路径
"DATA_PATH": "", # 数据路径
"DRAW_PATH": "" # 抽卡数据路径
"TEMP_PATH": "" # 临时图片路径
},
# 代理设置
"proxy": {
"system_proxy": "", # 系统代理
"buff_proxy": "" # buff代理
},
# RSSHUB地址
"rsshub": {
"RSSHUBAPP": "https:\/\/docs.rsshub.app\/"
},
# 各个管理员功能 对应的 权限
"level": {
"DELETE_IMG_LEVEL": 7,
"MOVE_IMG_LEVEL": 7,
"UPLOAD_LEVEL": 6,
"BAN_LEVEL": 5,
"OC_LEVEL": 2,
"MUTE_LEVEL": 5
}
}
```
./configs/plugins2cmd_config.json
```
# 单个例子注解
"send_img": [
"发送图片",
"萝莉",
"美图",
"壁纸"
]
# 发送 关闭发送图片/关闭萝莉/关闭美图/关闭壁纸 都将触发命令 关闭send_img
```
./configs/other_config.json
```
{
"base": {
# 图库配置,会影响 上传/删除/移动/发送图片等功能
"IMAGE_DIR_LIST": [
"色图",
"美图",
"萝莉",
"壁纸"
],
"BAN_RESULT": "才不会给你发消息." # 当被ban用户触发命令后发送的消息
},
"bool": {
"AUTO_ADD_FRIEND": true, # 是否自动添加好友
"DOWNLOAD_SETU": true # 是否下载bot发送过的色图(不会重复)
},
"max_count": {
"MAXINFO_REIMU": 7, # 上车(reimu)功能查找目的地的最大数
"COUNT_PER_DAY_REIMU": 5, # 每日上车(reimu)次数限制
"MAXINFO_BT": 10, # bt功能单次查找最大数
"MAXINFO_PRIVATE_ANIME": 20, # 私聊搜索动漫返回的最大数量
"MAXINFO_GROUP_ANIME": 5, # 群搜索动漫返回的最大数量
"MAX_FIND_IMG_COUNT": 3, # 识图最大返回数
"MAX_SIGN_GOLD": 200, # 签到好感度加成额外获得的最大金币数
"MAX_SETU_R_COUNT": 5, # 每日色图r次数限制
},
"probability": {
"INITIAL_SETU_PROBABILITY": 0.7, # 涩图触发的基础概率(触发概率 = 基础概率 + 好感度)
"FUDU_PROBABILITY": 0.7 # 复读概率
},
# 注:即在 MALICIOUS_CHECK_TIME 时间内触发相同命令 MALICIOUS_BAN_COUNT 将被ban MALICIOUS_BAN_TIME 分钟
"malicious_ban": {
"MALICIOUS_BAN_TIME": 30, # 恶意触发命令被ban的时长(分钟)
"MALICIOUS_BAN_COUNT": 4, # 恶意触发命令的规定次数
"MALICIOUS_CHECK_TIME": 5 # 恶意触发命令的规定时间(秒)
},
"open_case": {
"INITIAL_OPEN_CASE_COUNT": 20 # 每日开箱的基本数量(总数量=基本数量 + 好感度/3)
},
# 注:即在 MUTE_DEFAULT_TIME 内发送相似(包含)消息超过 MUTE_DEFAULT_COUNT 将会被 MUTE_DEFAULT_DURATION 分钟
# 这只是默认配置,各个群可以自由设置群内刷屏检测配置
"mute": {
"MUTE_DEFAULT_COUNT": 10, # 刷屏检测默认检测最大次数
"MUTE_DEFAULT_TIME": 7, # 刷屏检测默认规定时间(秒)
"MUTE_DEFAULT_DURATION": 10 # 刷屏检测默认禁言时长(分钟)
},
"other": {
"UPDATE_GOCQ_GROUP": [], # 是否需要为某些群上传最新版的gocq?
"ADMIN_DEFAULT_AUTH": 5 # 默认群管理员权限
},
# 管理员功能 和 对应的 权限
"auth": {
"admin_plugins_auth": {
"admin_bot_manage": 2,
"ban": 5,
"delete_img": 7,
"move_img": 7,
"upload_img": 6,
"admin_help": 1,
"mute": 5
}
}
}
```
</details>
## 更新
### 2021/9/9
* 替换coser API
* 修复签到uid可能不默认为0
* 修复签到可能重复的问题
* 修复无订阅时递归出错
* 启用了plugins2info_dict, plugins2cd_dict, plugins2exists_dict配置文件,通过USE_CONFIG_FILE=True开启
* 修复涩图local_id会被固定为50
* 优化图库数量查询
* 修复原神大地图过大无法打开报错
### 2021/9/7
* 修改 update_info.json
* 修改 更新信息 图片大小
* 修复 查看订阅 命令 UP和番剧无法正常显示
* 修复订阅推送无法正确推送
* 修复搜图返回列表为空时无法正确回复 @[pull/40](https://github.com/HibiKier/zhenxun_bot/pull/40)
### 2021/9/5
* 添加配置PIX_IMAGE_SIZE,调整PIX下载图片大小,当设置的图片404时,改为原图
* 新增配置DEFAULT_GROUP_LEVEL,默认群等级
+1 -1
View File
@@ -1 +1 @@
__version__: v0.0.4.0
__version__: v0.0.4.6
+17 -10
View File
@@ -1,8 +1,7 @@
from typing import List, Optional, Tuple
from services.service_config import TL_M_KEY, SYSTEM_M_PROXY, ALAPI_M_TOKEN
from .path_config import DATA_PATH
from pathlib import Path
from .utils.init_config import init_config
from configs.path_config import DATA_PATH
try:
import ujson as json
except ModuleNotFoundError:
@@ -10,6 +9,10 @@ except ModuleNotFoundError:
# 是否使用配置文件
# 使用配置文件在每次启动时 plugins2info_dict, plugins2cd_dict, plugins2exists_dict 将从本地读取
# 除了 plugins2info_dict 新增内容键值会写入 plugins2info_file
# 其他修改或新增在 configs.config.py中对 plugins2info_dict, plugins2cd_dict, plugins2exists_dict 的配置无效
# 目录:data/configs/
USE_CONFIG_FILE: bool = False
# 回复消息名称
@@ -55,12 +58,12 @@ MAXINFO_PRIVATE_ANIME: int = 20 # 私聊搜索动漫返回的最大数量
MAXINFO_GROUP_ANIME: int = 5 # 群搜索动漫返回的最大数量
MAX_FIND_IMG_COUNT: int = 3 # 识图最大返回数
# 参1:延迟撤回色图时间(秒),0 为关闭 | 参2:监控聊天类型,0(私聊) 1(群聊) 2(群聊+私聊)
WITHDRAW_SETU_TIME: Tuple[int, int] = (0, 1)
WITHDRAW_SETU_TIME: Tuple[int, int] = (90, 1)
# 参1:延迟撤回PIX图片时间(秒),0 为关闭 | 参2:监控聊天类型,0(私聊) 1(群聊) 2(群聊+私聊)
WITHDRAW_PIX_TIME: Tuple[int, int] = (0, 1)
# PIX图库 与 额外图库OmegaPixivIllusts 混合搜索的比例 参1:PIX图库 参2:OmegaPixivIllusts扩展图库(没有此图库请设置为0)
PIX_OMEGA_PIXIV_RATIO: Tuple[int, int] = (10, 0)
PIX_OMEGA_PIXIV_RATIO: Tuple[int, int] = (2, 8)
# 各种卡池的开关
PRTS_FLAG = True # 明日方舟
@@ -92,7 +95,7 @@ CHECK_NOTICE_INFO_CD = 300 # 群检测,个人权限检测等各种检测提
# 注:即在 MALICIOUS_CHECK_TIME 时间内触发相同命令 MALICIOUS_BAN_COUNT 将被ban MALICIOUS_BAN_TIME 分钟
MALICIOUS_BAN_TIME: int = 30 # 恶意命令触发检测触发后ban的时长(分钟)
MALICIOUS_BAN_COUNT: int = 8 # 恶意命令触发检测最大触发次数
MALICIOUS_BAN_COUNT: int = 3 # 恶意命令触发检测最大触发次数
MALICIOUS_CHECK_TIME: int = 5 # 恶意命令触发检测规定时间内(秒)
# LEVEL
@@ -102,6 +105,7 @@ UPLOAD_LEVEL: int = 6 # 上传图片权限
BAN_LEVEL: int = 5 # BAN权限
OC_LEVEL: int = 2 # 开关群功能权限
MUTE_LEVEL: int = 5 # 更改禁言设置权限
MEMBER_ACTIVITY_LEVEL = 5 # 群员活跃检测设置权限
GROUP_BILIBILI_SUB_LEVEL = 5 # 群内bilibili订阅需要的权限
DEFAULT_GROUP_LEVEL = 5 # 默认群等级
@@ -140,6 +144,7 @@ admin_plugins_auth = {
"upload_img": UPLOAD_LEVEL,
"admin_help": 1,
"mute": MUTE_LEVEL,
"member_activity_handle": MEMBER_ACTIVITY_LEVEL,
}
# 需要cd的功能(方便管理)[秒]
@@ -307,10 +312,12 @@ HIBIAPI = HIBIAPI[:-1] if HIBIAPI[-1] == "/" else HIBIAPI
RSSHUBAPP = RSSHUBAPP[:-1] if RSSHUBAPP[-1] == "/" else RSSHUBAPP
# plugins2info_file = Path(DATA_PATH) / 'configs' / 'plugins2info.json'
# plugins2info_file.parent.mkdir(exist_ok=True, parents=True)
#
# with open(f'{DATA_PATH}/configs/')
if USE_CONFIG_FILE:
# 读取配置文件
plugins2info_dict, plugins2cd_dict, plugins2exists_dict = init_config(
plugins2info_dict, plugins2cd_dict, plugins2exists_dict, DATA_PATH
)
# 配置文件应用
# if USE_CONFIG_FILE:
+33 -167
View File
@@ -1,176 +1,42 @@
# import nonebot
from pathlib import Path
try:
import ujson as json
except ModuleNotFoundError:
import json
# driver: nonebot.Driver = nonebot.get_driver()
base_config = Path() / 'config.json'
plugins_cmd_config = Path() / 'configs' / 'plugins2cmd_config.json'
plugins_setting = Path() / 'configs' / 'plugins_setting.json'
def init_config():
if not base_config.exists():
base_config.parent.mkdir(parents=True, exist_ok=True)
config_dict = {
'apikey': {
'LOLICON_KEY': '',
'TL_KEY': [],
},
'sql': {
'bind': '',
'sql_name': '',
'user': '',
'password': '',
'address': '',
'port': '',
'database': '',
},
'path': {
'IMAGE_PATH': '',
'VOICE_PATH': '',
'TXT_PATH': '',
'LOG_PATH': '',
'DATA_PATH': '',
'DRAW_PATH': '',
'TEMP_PATH': '',
},
'proxy': {
'system_proxy': '',
'buff_proxy': ''
},
'level': {
'DELETE_IMG_LEVEL': 7,
'MOVE_IMG_LEVEL': 7,
'UPLOAD_LEVEL': 6,
'BAN_LEVEL': 5,
'OC_LEVEL': 2,
'MUTE_LEVEL': 5,
},
'auth': {
'ADMIN_DEFAULT_AUTH': 5,
'admin_plugins_auth': {
"admin_bot_manage": 2,
"ban": 5,
"delete_img": 7,
"move_img": 7,
"upload_img": 6,
"admin_help": 1,
"mute": 5
}
}
}
with open(base_config, 'w', encoding='utf8') as f:
json.dump(config_dict, f, indent=4, ensure_ascii=False)
if not plugins_cmd_config.exists():
plugins_cmd_config.parent.mkdir(parents=True, exist_ok=True)
config_dict = {
'base_config': {
'sign_in': ['签到'],
'send_img': ['发送图片', '萝莉', '美图', '壁纸'],
'send_setu': ['色图', '涩图', '瑟图', '查色图'],
'white2black': ['黑白图', '黑白草图'],
'coser': ['coser', 'cos'],
'quotations': ['语录'],
'jitang': ['鸡汤'],
'send_dinggong_voice': ['骂我', '骂老子', '骂劳资'],
'open_cases': ['开箱', '我的开箱', '群开箱统计', '我的金色'],
'luxun': ['鲁迅说过', '鲁迅说'],
'fake_msg': ['假消息'],
'buy': ['购买', '购买道具'],
'my_gold': ['我的金币'],
'my_props': ['我的道具'],
'shop_handle': ['商店'],
'nonebot_plugin_cocdicer': ['骰子娘'],
'update_pic': ['图片', '操作图片', '修改图片'],
'search_buff_skin_price': ['查询皮肤'],
'weather': ['天气', '查询天气', '天气查询'],
'yiqing': ['疫情', '疫情查询', '查询疫情'],
'what_anime': ['识番'],
'search_anime': ['搜番'],
'songpicker2': ['点歌'],
'epic': ['epic'],
'pixiv': ['pixiv', 'p站排行', '搜图'],
'poke': ['戳一戳'],
'draw_card': ['游戏抽卡', '原神一井', '原神来一井', '方舟一井', '方舟来一井'],
'ai': ['ai', 'Ai', 'AI', 'aI'],
'one_friend': ['我有一个朋友', '我有一个朋友想问问'],
'translate': ['翻译', '英翻', '翻英', '日翻', '翻日', '韩翻', '翻韩'],
'nonebot_plugin_picsearcher': ['识图'],
'almanac': ['原神黄历', '黄历'],
'material_remind': ['今日素材', '天赋材料'],
'qiu_qiu_translation': ['丘丘翻译', '丘丘一下', '丘丘语翻译'],
'query_resource_points': ['原神资源查询', '原神资源列表'],
}
}
with open(plugins_cmd_config, 'w', encoding='utf8') as f:
json.dump(config_dict, f, indent=4, ensure_ascii=False)
if not plugins_setting.exists():
plugins_setting.parent.mkdir(parents=True, exist_ok=True)
config_dict = {
'base': {
'IMAGE_DIR_LIST': ["色图", "美图", "萝莉", "壁纸"],
'BAN_RESULT': "才不会给你发消息.",
},
'draw_card': {
'PRTS_FLAG': True, # 明日方舟
'GENSHIN_FLAG': True, # 原神
'PRETTY_FLAG': True, # 赛马娘
'GUARDIAN_FLAG': True, # 坎公骑冠剑
'PCR_FLAG': True, # 公主连结
'AZUR_FLAG': True, # 碧蓝航线
'FGO_FLAG': True, # 命运-冠位指定(FGO)
'ONMYOJI_FLAG': True, # 阴阳师
'PCR_TAI': False # pcr是否开启台服卡池
},
'fudu': {
'FUDU_PROBABILITY': 0.7,
},
'reimu': {
'MAXINFO_REIMU': 7,
'COUNT_PER_DAY_REIMU': 5,
},
'bt': {
'MAXINFO_BT': 10,
},
'search_anime': {
'MAXINFO_PRIVATE_ANIME': 20,
'MAXINFO_GROUP_ANIME': 5,
},
'picsearcher': {
'MAX_FIND_IMG_COUNT': 3,
},
'sign': {
'MAX_SIGN_GOLD': 200,
},
'send_setu': {
'INITIAL_SETU_PROBABILITY': 0.7,
'MAX_SETU_R_COUNT': 5,
'DOWNLOAD_SETU': True,
},
'malicious_ban': {
'MALICIOUS_BAN_TIME': 30,
'MALICIOUS_BAN_COUNT': 8,
'MALICIOUS_CHECK_TIME': 5,
},
'open_case': {
'INITIAL_OPEN_CASE_COUNT': 20,
},
'mute': {
'MUTE_DEFAULT_COUNT': 10,
'MUTE_DEFAULT_TIME': 7,
'MUTE_DEFAULT_DURATION': 10,
},
'update_gocq': {
'UPDATE_GOCQ_GROUP': [],
},
}
with open(plugins_setting, 'w', encoding='utf8') as f:
json.dump(config_dict, f, indent=4, ensure_ascii=False)
def init_config(plugins2info_dict, plugins2cd_dict, plugins2exists_dict, DATA_PATH):
plugins2info_file = Path(DATA_PATH) / 'configs' / 'plugins2info.json'
plugins2info_file.parent.mkdir(exist_ok=True, parents=True)
if plugins2info_file.exists():
with open(plugins2info_file, 'r', encoding='utf8') as f:
_data = json.load(f)
for p in plugins2info_dict:
if not _data.get(p):
_data[p] = plugins2info_dict[p]
with open(plugins2info_file, 'w') as wf:
json.dump(_data, wf, ensure_ascii=False, indent=4)
plugins2info_dict = _data
else:
with open(plugins2info_file, 'w', encoding='utf8') as wf:
json.dump(plugins2info_dict, wf, ensure_ascii=False, indent=4)
plugins2cd_file = Path(DATA_PATH) / 'configs' / 'plugins2cd.json'
if plugins2cd_file.exists():
with open(plugins2cd_file, 'r', encoding='utf8') as f:
plugins2cd_dict = json.load(f)
else:
with open(plugins2cd_file, 'w', encoding='utf8') as wf:
json.dump(plugins2cd_dict, wf, ensure_ascii=False, indent=4)
plugins2exists_file = Path(DATA_PATH) / 'configs' / 'plugins2exists.json'
if plugins2exists_file.exists():
with open(plugins2exists_file, 'r', encoding='utf8') as f:
plugins2exists_dict = json.load(f)
else:
with open(plugins2exists_file, 'w', encoding='utf8') as wf:
json.dump(plugins2exists_dict, wf, ensure_ascii=False, indent=4)
return plugins2info_dict, plugins2cd_dict, plugins2exists_dict
+3
View File
@@ -24,6 +24,7 @@ class GroupInfoUser(db.Model):
belonging_group: int,
user_name: str,
user_join_time: datetime,
uid: Optional[int] = None,
) -> bool:
"""
说明:
@@ -33,6 +34,7 @@ class GroupInfoUser(db.Model):
:param belonging_group: 群号
:param user_name: 用户名称
:param user_join_time: 入群时间
:param uid: 用户唯一 id(自动生成)
"""
query = cls.query.where(
(cls.user_qq == user_qq) & (cls.belonging_group == belonging_group)
@@ -44,6 +46,7 @@ class GroupInfoUser(db.Model):
user_name=user_name,
belonging_group=belonging_group,
user_join_time=user_join_time,
uid=uid
)
return True
except Exception:
+8 -7
View File
@@ -118,14 +118,15 @@ class OmegaPixivIllusts(db.Model):
参数:
:param tags: 关键词/Tag
"""
query = cls.query
setattr(OmegaPixivIllusts, 'count', db.func.count(cls.pid).label('count'))
query = cls.select('count')
if tags:
for tag in tags:
query = query.where(cls.tags.contains(tag))
count = len(await query.where(cls.nsfw_tag == 0).gino.all())
setu_count = len(await query.where(cls.nsfw_tag == 1).gino.all())
r18_count = len(await query.where(cls.nsfw_tag == 2).gino.all())
return count, setu_count, r18_count
count = await query.where(cls.nsfw_tag == 0).gino.first()
setu_count = await query.where(cls.nsfw_tag == 1).gino.first()
r18_count = await query.where(cls.nsfw_tag == 2).gino.first()
return count[0], setu_count[0], r18_count[0]
@classmethod
async def get_all_pid(cls) -> List[int]:
@@ -133,6 +134,6 @@ class OmegaPixivIllusts(db.Model):
说明:
获取所有图片PID
"""
data = await cls.query.gino.all()
return [x.pid for x in data]
data = await cls.select('pid').gino.all()
return [x[0] for x in data]
+6 -5
View File
@@ -159,11 +159,12 @@ class Pixiv(db.Model):
参数:
:param tags: 关键词/Tag
"""
query = cls.query
setattr(Pixiv, 'count', db.func.count(cls.pid).label('count'))
query = cls.select('count')
if tags:
for tag in tags:
query = cls.query.where(cls.tags.contains(tag))
count = len(await query.where(cls.is_r18 == False).gino.all())
r18_count = len(await query.where(cls.is_r18 == True).gino.all())
return count, r18_count
query = query.where(cls.tags.contains(tag))
count = await query.where(cls.is_r18 == False).gino.first()
r18_count = await query.where(cls.is_r18 == True).gino.first()
return count[0], r18_count[0]
+7 -3
View File
@@ -57,6 +57,7 @@ class Setu(db.Model):
local_id: Optional[int] = None,
tags: Optional[List[str]] = None,
r18: int = 0,
limit: int = 50,
):
"""
说明:
@@ -65,6 +66,7 @@ class Setu(db.Model):
:param local_id: 本地色图 id
:param tags: tags
:param r18: 是否 r18,0:非r18 1:r18 2:混合
:param limit: 获取数量
"""
if local_id:
flag = True if r18 == 1 else False
@@ -80,7 +82,7 @@ class Setu(db.Model):
if tags:
for tag in tags:
query = query.where(cls.tags.contains(tag) | cls.title.contains(tag) | cls.author.contains(tag))
query = query.order_by(db.func.random()).limit(50)
query = query.order_by(db.func.random()).limit(limit)
return await query.gino.all()
@classmethod
@@ -89,8 +91,10 @@ class Setu(db.Model):
说明:
查询图片数量
"""
return len(await cls.query_image(r18=r18))
# return await db.func.count(cls.local_id).gino.scalar()
flag = False if r18 == 0 else True
setattr(Setu, 'count', db.func.count(cls.local_id).label('count'))
count = await cls.select('count').where(cls.is_r18 == flag).gino.first()
return count[0]
@classmethod
async def get_image_in_hash(cls, img_hash: str) -> "Setu":
@@ -1,6 +1,6 @@
from nonebot import on_command, export
from nonebot import on_command, on_notice
from nonebot.typing import T_State
from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, GROUP
from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, GROUP, GroupIncreaseNoticeEvent
from .data_source import update_member_info
__plugin_name__ = "更新群组成员列表"
@@ -12,8 +12,6 @@ __plugin_usage__ = """
更新群组成员列表
"""
export = export()
export.update_member_info = update_member_info
refresh_member_group = on_command(
"更新群组成员列表", aliases={"更新群组成员信息"}, permission=GROUP, priority=5, block=True
@@ -26,3 +24,12 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State):
await refresh_member_group.finish("更新群员信息成功!", at_sender=True)
else:
await refresh_member_group.finish("更新群员信息失败!", at_sender=True)
group_increase_handle = on_notice(priority=1, block=False)
@group_increase_handle.handle()
async def _(bot: Bot, event: GroupIncreaseNoticeEvent, state: dict):
if event.user_id == int(bot.self_id):
await update_member_info(event.group_id)
+4
View File
@@ -19,6 +19,10 @@ __plugin_usage__ = f'''[权限等级]管理帮助:
\t\t/设置检测次数/设置禁言时长
[5]7.群订阅相关 -> 指令:添加订阅 [主播/up/番剧] [id/番名/链接]
\t\t/删除订阅 [id]/ 查看订阅
[5]8.群员活跃度相关 --> 指令:群员活跃检测设置
设置群员活跃检测时长(天)
添加群员活跃检测白名单[at]...
查看群员活跃检测白名单
[6]8.上传图片/连续上传图片(6)
[7]9.移动图片(7)
[7]10.删除图片(7)
+3 -3
View File
@@ -132,7 +132,7 @@ def hello() -> str:
(
"哦豁?!",
"你好!Ov<",
f"库库库,呼唤{list(get_bot().config.nickname)[0]}做什么呢",
f"库库库,呼唤{NICKNAME}做什么呢",
"我在呢!",
"呼呼,叫俺干嘛",
)
@@ -170,8 +170,8 @@ async def check_text(text: str, sess: ClientSession) -> str:
async with sess.get(check_url, timeout=2, params=params) as response:
data = await response.json()
if data["code"] == 200:
if data["conclusion_type"] == 2:
if data['data']["conclusion_type"] == 2:
return ''
except Exception as e:
logger.error(f"检测违规文本错误...e:{e}")
logger.error(f"检测违规文本错误...{type(e)}:{e}")
return text
+2 -4
View File
@@ -80,7 +80,6 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
if sub_type in ["season", "动漫", "番剧"]:
rst = "*以为您找到以下番剧,请输入Id选择:*\n"
state["season_data"] = await get_media_id(id_)
print(state["season_data"])
if len(state["season_data"]) == 0:
await add_sub.finish(f"未找到番剧:{msg}")
for i, x in enumerate(state["season_data"]):
@@ -105,7 +104,6 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
await add_sub.send(await add_season_sub(id_, sub_user))
else:
await add_sub.finish("参数错误,第一参数必须为:主播/up/番剧!")
sub_manager.reload_flag = True
logger.info(
f"(USER {event.user_id}, GROUP "
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
@@ -151,8 +149,8 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
f'\t当前集数:{x.season_current_episode}\n' \
f'------------------\n'
live_rst = '当前订阅的直播:\n' + live_rst if live_rst else live_rst
up_rst = '当前订阅的UP:\n' if up_rst else up_rst
season_rst = '当前订阅的番剧:\n' if season_rst else season_rst
up_rst = '当前订阅的UP:\n' + up_rst if up_rst else up_rst
season_rst = '当前订阅的番剧:\n' + season_rst if season_rst else season_rst
if not live_rst and not up_rst and not season_rst:
live_rst = '您目前没有任何订阅...'
await show_sub_info.send(live_rst + up_rst + season_rst)
+38 -27
View File
@@ -279,9 +279,13 @@ async def _get_season_status(id_) -> Optional[str]:
_idx = (await BilibiliSub.get_sub(id_)).season_current_episode
new_ep = season_info["media"]["new_ep"]["index"]
if new_ep != _idx:
await BilibiliSub.update_sub_info(id_, season_current_episode=new_ep, season_update_time=datetime.now())
await BilibiliSub.update_sub_info(
id_, season_current_episode=new_ep, season_update_time=datetime.now()
)
return (
f'{image(season_info["media"]["cover"])}\n' f"[{title}]更新啦\n" f"最新集数:{new_ep}"
f'{image(season_info["media"]["cover"])}\n'
f"[{title}]更新啦\n"
f"最新集数:{new_ep}"
)
return None
@@ -335,45 +339,52 @@ async def get_user_dynamic(
class SubManager:
def __init__(self):
self.reload_flag = True
self.live_data = []
self.up_data = []
self.season_data = []
self.sub_list = []
self.current_index = -1
async def reload_sub_data(self):
"""
重载数据
"""
if self.reload_flag or not self.sub_list:
if not self.live_data or not self.up_data or not self.season_data:
(
self.live_data,
self.up_data,
self.season_data,
_live_data,
_up_data,
_season_data,
) = await BilibiliSub.get_all_sub_data()
for x, i, j in zip(self.live_data, self.up_data, self.season_data):
self.sub_list.append(x)
self.sub_list.append(i)
self.sub_list.append(j)
self.reload_flag = False
def append(self, data: BilibiliSub):
"""
增加新数据
:param data: 数据
"""
self.sub_list.append(data)
if not self.live_data:
self.live_data = _live_data
if not self.up_data:
self.up_data = _up_data
if not self.season_data:
self.season_data = _season_data
async def random_sub_data(self) -> Optional[BilibiliSub]:
"""
随机获取一条数据
:return:
"""
if not self.sub_list:
await self.reload_sub_data()
if self.sub_list:
sub = random.choice(self.sub_list)
self.sub_list.remove(sub)
sub = None
if not self.live_data and not self.up_data and not self.season_data:
return sub
return None
self.current_index += 1
if self.current_index == 0:
if self.live_data:
sub = random.choice(self.live_data)
self.live_data.remove(sub)
elif self.current_index == 1:
if self.up_data:
sub = random.choice(self.up_data)
self.up_data.remove(sub)
elif self.current_index == 2:
if self.season_data:
sub = random.choice(self.season_data)
self.season_data.remove(sub)
else:
self.current_index = -1
if sub:
return sub
await self.reload_sub_data()
return await self.random_sub_data()
+1 -1
View File
@@ -20,7 +20,7 @@ restart = on_command('重启', aliases={'restart'}, permission=SUPERUSER, rule=t
@update_zhenxun.handle()
async def _(bot: Bot, event: MessageEvent, state: T_State):
try:
error, code = await check_update(bot)
code, error = await check_update(bot)
if error:
logger.error(f'更新真寻未知错误 {error}')
await bot.send_private_msg(
+6 -3
View File
@@ -89,10 +89,12 @@ async def check_update(bot: Bot) -> 'int, str':
update_info = data["body"]
width = 0
height = len(update_info.split('\n')) * 24
for m in update_info.split('\n'):
if len(m) * 20 > width:
width = len(m) * 18
A = CreateImg(width, height, font_size=20)
for m in update_info.split('\n'):
w, h = A.getsize(m)
if w > width:
width = w
A = CreateImg(width + 50, height, font_size=20)
A.text((10, 10), update_info)
A.save(f'{IMAGE_PATH}/update_info.png')
await bot.send_private_msg(
@@ -115,6 +117,7 @@ async def check_update(bot: Bot) -> 'int, str':
user_id=int(list(bot.config.superusers)[0]),
message=f"自动获取真寻版本成功:{latest_version},当前版本为最新版,无需更新...",
)
return 200, ''
else:
logger.warning("自动获取真寻版本失败....")
await bot.send_private_msg(
+13 -11
View File
@@ -19,7 +19,7 @@ coser = on_command(
)
url = "http://81.70.100.130/api/cosplay.php"
url = "http://api520.ltd/api/cosplay.php"
@coser.handle()
@@ -29,20 +29,22 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
for _ in range(3):
try:
async with session.get(url, timeout=2) as response:
r = re.search(r'±img=(.*)±', await response.text())
if r:
async with session.get(r.group(1), timeout=5, verify_ssl=False) as res:
_url = await response.text()
async with session.get(_url, timeout=5, verify_ssl=False) as res:
if res.status == 200:
async with aiofiles.open(f'{IMAGE_PATH}/temp/{event.user_id}_coser.jpg', 'wb') as f:
await f.write(await res.read())
logger.info(
f"(USER {event.user_id}, "
f"GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
f" 发送COSER"
)
await coser.send(image(f'{event.user_id}_coser.jpg', 'temp'))
break
logger.info(
f"(USER {event.user_id}, "
f"GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
f" 发送COSER"
)
await coser.send(image(f'{event.user_id}_coser.jpg', 'temp'))
break
except TimeoutError:
pass
else:
await coser.send('你cos给我看!')
except Exception as e:
await coser.send('发生了预料之外的错误..请稍后再试或联系管理员修复...')
logger.error(f'coser 发送了未知错误 {type(e)}:{e}')
@@ -164,40 +164,18 @@ async def download_map_init(
if not _map.exists():
# padding_w, padding_h = data['padding']
data = data["slices"]
idx = 0
for x in data:
idj = 0
for j in x:
await download_image(
j["url"],
f"{map_path}/{idx}_{idj}.png",
session,
semaphore,
force_flag=flag,
)
idj += 1
idx += 1
map_width, map_height = CreateImg(
0, 0, background=f"{map_path}/0_0.png"
).size
map_width = map_width * MAP_RATIO
map_height = map_height * MAP_RATIO
lens = len(
[x for x in os.listdir(f"{map_path}") if x.startswith("0")]
map_url = data[0][0]['url']
await download_image(
map_url,
f"{map_path}/map.png",
session,
semaphore,
force_flag=flag,
)
background_image = CreateImg(
map_width * lens, map_height * lens, map_width, map_height
map_file = CreateImg(
0, 0, background=f"{map_path}/map.png", ratio=MAP_RATIO
)
for i in range(idx):
for j in range(idj):
x = CreateImg(
0,
0,
background=f"{map_path}/{i}_{j}.png",
ratio=MAP_RATIO,
)
background_image.paste(x)
background_image.save(f"{map_path}/map.png")
map_file.save(f"{map_path}/map.png")
else:
logger.warning(f'获取原神地图失败 msg: {data["message"]}')
else:
+1 -9
View File
@@ -116,15 +116,10 @@ async def _(matcher: Matcher, bot: Bot, event: GroupMessageEvent, state: T_State
return
if matcher.type == "message" and matcher.priority not in [1, 9]:
if state["_prefix"]["raw_command"]:
# print(state["_prefix"]["raw_command"])
if _blmt.check(f'{event.user_id}{state["_prefix"]["raw_command"]}'):
if await BanUser.ban(event.user_id, 9, MALICIOUS_BAN_TIME * 60):
logger.info(f"USER {event.user_id} 触发了恶意触发检测")
# await update_img.finish('检测到恶意触发命令,您将被封禁 30 分钟', at_sender=True)
if event.message_type == "group":
if not static_flmt.check(event.user_id):
return
static_flmt.start_cd(event.user_id)
if isinstance(event, GroupMessageEvent):
try:
await bot.send_group_msg(
group_id=event.group_id,
@@ -133,9 +128,6 @@ async def _(matcher: Matcher, bot: Bot, event: GroupMessageEvent, state: T_State
except ActionFailed:
pass
else:
if not static_flmt.check(event.user_id):
return
static_flmt.start_cd(event.user_id)
try:
await bot.send_private_msg(
user_id=event.user_id,
+2
View File
@@ -131,6 +131,8 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
info_list, code = await search_pixiv_urls(keyword, num, page, r18)
if code != 200:
await pixiv_keyword.finish(info_list[0])
if not info_list:
await pixiv_keyword.finish("没有找到啊,等等再试试吧~V", at_sender=True)
await send_image(info_list, pixiv_keyword, bot, event)
logger.info(
f"(USER {event.user_id}, GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
+7 -7
View File
@@ -27,13 +27,13 @@ async def group_user_check_in(
# 取得相应用户
user = await SignGroupUser.ensure(user_qq, group, for_update=True)
# 如果同一天签到过,特殊处理
# if (
# user.checkin_time_last + timedelta(hours=8)
# ).date() >= present.date() or f"{user}_{group}_sign_{datetime.now().date()}" in os.listdir(
# SIGN_TODAY_CARD_PATH
# ):
# gold = await BagUser.get_gold(user_qq, group)
# return await get_card(user, nickname, -1, gold, "")
if (
user.checkin_time_last + timedelta(hours=8)
).date() >= present.date() or f"{user}_{group}_sign_{datetime.now().date()}" in os.listdir(
SIGN_TODAY_CARD_PATH
):
gold = await BagUser.get_gold(user_qq, group)
return await get_card(user, nickname, -1, gold, "")
return await _handle_check_in(nickname, user_qq, group, present) # ok
+4 -1
View File
@@ -31,7 +31,10 @@ driver: Driver = nonebot.get_driver()
@driver.on_startup
async def init_image():
SIGN_RESOURCE_PATH.mkdir(parents=True, exist_ok=True)
await GroupInfoUser.add_member_info(114514, 114514, "", datetime.min)
await GroupInfoUser.add_member_info(114514, 114514, "", datetime.min, 0)
_u = await GroupInfoUser.get_member_info(114514, 114514)
if _u.uid is None:
await _u.update(uid=0).apply()
generate_progress_bar_pic()
clear_sign_data_pic()
+14 -13
View File
@@ -15,16 +15,17 @@ yiqing = on_command("疫情", aliases={"查询疫情", "疫情查询"}, priority
@yiqing.handle()
async def _(bot: Bot, event: MessageEvent, state: T_State):
msg = get_message_text(event.json())
result = await get_yiqing_data(msg)
if result:
await yiqing.send(result)
logger.info(
f"(USER {event.user_id}, GROUP "
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) 查询疫情: {msg}"
)
else:
await yiqing.send("查询失败!!!!", at_sender=True)
logger.info(
f"(USER {event.user_id}, GROUP "
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) 查询疫情失败"
)
if msg:
result = await get_yiqing_data(msg)
if result:
await yiqing.send(result)
logger.info(
f"(USER {event.user_id}, GROUP "
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) 查询疫情: {msg}"
)
else:
await yiqing.send("查询失败!!!!", at_sender=True)
logger.info(
f"(USER {event.user_id}, GROUP "
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) 查询疫情失败"
)
+11 -9
View File
@@ -2,13 +2,14 @@
"update_file": [
"README.md",
"configs/config.py",
"configs/utils/init_config.py",
"models/ban_user.py",
"models/group_member_info.py",
"models/pixiv.py",
"models/russian_user.py",
"models/setu.py",
"plugins/admin_bot_manage/data_source.py",
"plugins/admin_bot_manage/switch_rule.py",
"models/omega_pixiv_illusts.py",
"plugins/admin_bot_manage",
"plugins/admin_help/__init__.py",
"plugins/ai/__init__.py",
"plugins/ai/data_source.py",
@@ -55,6 +56,8 @@
"plugins/super_help/__init__.py",
"plugins/update_gocqhttp/__init__.py",
"plugins/what_anime/__init__.py",
"plugins/bilibili_sub",
"models/bilibili_sub.py",
"services/log.py",
"update_info.json",
"utils/browser.py",
@@ -63,19 +66,18 @@
"utils/static_data/__init__.py",
"utils/static_data/data_class.py",
"utils/static_data/group_manager.py",
"utils/utils.py"
],
"add_file": [
"__version__",
"models/bilibili_sub.py",
"utils/utils.py",
"models/omega_pixiv_illusts.py",
"models/sign_group_user.py",
"plugins/bilibili_sub",
"models/bilibili_sub.py",
"plugins/database_scripts.py",
"plugins/sign_in/config.py",
"plugins/sign_in/random_event.py",
"plugins/sign_in/utils.py",
"plugins/withdraw.py",
"resources/img/sign/sign_res"
"resources/img/sign"
],
"delete_file": ["plugins/nonebot_plugin_withdraw"]
"add_file": [],
"delete_file": ["plugins/nonebot_plugin_withdraw", "models/sigin_group_user.py"]
}
+2
View File
@@ -8,6 +8,8 @@ from pathlib import Path
import cv2
import base64
import imagehash
ImageFile.LOAD_TRUNCATED_IMAGES = True
Image.MAX_IMAGE_PIXELS = None
def compare_image_with_hash(