mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-01 17:49:58 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
401886805b | ||
|
|
efcdf79f57 | ||
|
|
616f215075 | ||
|
|
00b674cebb | ||
|
|
8ac440335e | ||
|
|
4b1821ce42 | ||
|
|
3ad955abf9 | ||
|
|
5fabb974ce | ||
|
|
5325bc3e32 | ||
|
|
6688c4626b | ||
|
|
2b95ab3d7e | ||
|
|
23e6d7e27e | ||
|
|
2760e22336 | ||
|
|
d026d09f98 | ||
|
|
e6fd1ce791 | ||
|
|
342eaa9a97 | ||
|
|
dc7681357e | ||
|
|
b61cb49c1a | ||
|
|
c7b341393d | ||
|
|
1f9fa2adb9 | ||
|
|
133b927d9d | ||
|
|
46e6b26d75 | ||
|
|
8d0b0e5505 | ||
|
|
754a0c111c | ||
|
|
81ef3f04e4 | ||
|
|
e7c00484b3 |
@@ -11,7 +11,9 @@
|
|||||||
用爱发电,某些功能学习借鉴了大佬们的代码,因为绪山真寻实在太可爱了因此开发了
|
用爱发电,某些功能学习借鉴了大佬们的代码,因为绪山真寻实在太可爱了因此开发了
|
||||||
绪山真寻bot,实现了一些对群友的娱乐功能和实用功能(大概)。
|
绪山真寻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
|
python bot.py
|
||||||
```
|
```
|
||||||
|
|
||||||
## 配置(暂时不更新 json 配置,请将USE_CONFIG_FILE设置为False)
|
## 配置
|
||||||
在 configs/config.py 中的 USE_CONFIG_FILE,默认为False
|
在 configs/config.py 中的 USE_CONFIG_FILE,默认为False
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -302,167 +304,38 @@ python bot.py
|
|||||||
在./configs/config.py中配置基本配置(除API KEY ,数据库和代理外都含有默认值)
|
在./configs/config.py中配置基本配置(除API KEY ,数据库和代理外都含有默认值)
|
||||||
在./configs/path_config.py配置路径(含有默认配置)
|
在./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
|
# 如果不使用配置文件,将USE_CONFIG_FILE设置为False
|
||||||
#可在./configs/config.py文件中修改配置,在./configs/path_config.py修改资源路径
|
#可在./configs/config.py文件中修改配置,在./configs/path_config.py修改资源路径
|
||||||
# 已在./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
|
### 2021/9/5
|
||||||
* 添加配置PIX_IMAGE_SIZE,调整PIX下载图片大小,当设置的图片404时,改为原图
|
* 添加配置PIX_IMAGE_SIZE,调整PIX下载图片大小,当设置的图片404时,改为原图
|
||||||
* 新增配置DEFAULT_GROUP_LEVEL,默认群等级
|
* 新增配置DEFAULT_GROUP_LEVEL,默认群等级
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
__version__: v0.0.4.3
|
__version__: v0.0.4.7
|
||||||
|
|||||||
+17
-10
@@ -1,8 +1,7 @@
|
|||||||
from typing import List, Optional, Tuple
|
from typing import List, Optional, Tuple
|
||||||
from services.service_config import TL_M_KEY, SYSTEM_M_PROXY, ALAPI_M_TOKEN
|
from services.service_config import TL_M_KEY, SYSTEM_M_PROXY, ALAPI_M_TOKEN
|
||||||
from .path_config import DATA_PATH
|
from .utils.init_config import init_config
|
||||||
from pathlib import Path
|
from configs.path_config import DATA_PATH
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ujson as json
|
import ujson as json
|
||||||
except ModuleNotFoundError:
|
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
|
USE_CONFIG_FILE: bool = False
|
||||||
|
|
||||||
# 回复消息名称
|
# 回复消息名称
|
||||||
@@ -55,12 +58,12 @@ MAXINFO_PRIVATE_ANIME: int = 20 # 私聊搜索动漫返回的最大数量
|
|||||||
MAXINFO_GROUP_ANIME: int = 5 # 群搜索动漫返回的最大数量
|
MAXINFO_GROUP_ANIME: int = 5 # 群搜索动漫返回的最大数量
|
||||||
MAX_FIND_IMG_COUNT: int = 3 # 识图最大返回数
|
MAX_FIND_IMG_COUNT: int = 3 # 识图最大返回数
|
||||||
# 参1:延迟撤回色图时间(秒),0 为关闭 | 参2:监控聊天类型,0(私聊) 1(群聊) 2(群聊+私聊)
|
# 参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(群聊+私聊)
|
# 参1:延迟撤回PIX图片时间(秒),0 为关闭 | 参2:监控聊天类型,0(私聊) 1(群聊) 2(群聊+私聊)
|
||||||
WITHDRAW_PIX_TIME: Tuple[int, int] = (0, 1)
|
WITHDRAW_PIX_TIME: Tuple[int, int] = (0, 1)
|
||||||
|
|
||||||
# PIX图库 与 额外图库OmegaPixivIllusts 混合搜索的比例 参1:PIX图库 参2:OmegaPixivIllusts扩展图库(没有此图库请设置为0)
|
# 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 # 明日方舟
|
PRTS_FLAG = True # 明日方舟
|
||||||
@@ -92,7 +95,7 @@ CHECK_NOTICE_INFO_CD = 300 # 群检测,个人权限检测等各种检测提
|
|||||||
|
|
||||||
# 注:即在 MALICIOUS_CHECK_TIME 时间内触发相同命令 MALICIOUS_BAN_COUNT 将被ban MALICIOUS_BAN_TIME 分钟
|
# 注:即在 MALICIOUS_CHECK_TIME 时间内触发相同命令 MALICIOUS_BAN_COUNT 将被ban MALICIOUS_BAN_TIME 分钟
|
||||||
MALICIOUS_BAN_TIME: int = 30 # 恶意命令触发检测触发后ban的时长(分钟)
|
MALICIOUS_BAN_TIME: int = 30 # 恶意命令触发检测触发后ban的时长(分钟)
|
||||||
MALICIOUS_BAN_COUNT: int = 8 # 恶意命令触发检测最大触发次数
|
MALICIOUS_BAN_COUNT: int = 3 # 恶意命令触发检测最大触发次数
|
||||||
MALICIOUS_CHECK_TIME: int = 5 # 恶意命令触发检测规定时间内(秒)
|
MALICIOUS_CHECK_TIME: int = 5 # 恶意命令触发检测规定时间内(秒)
|
||||||
|
|
||||||
# LEVEL
|
# LEVEL
|
||||||
@@ -102,6 +105,7 @@ UPLOAD_LEVEL: int = 6 # 上传图片权限
|
|||||||
BAN_LEVEL: int = 5 # BAN权限
|
BAN_LEVEL: int = 5 # BAN权限
|
||||||
OC_LEVEL: int = 2 # 开关群功能权限
|
OC_LEVEL: int = 2 # 开关群功能权限
|
||||||
MUTE_LEVEL: int = 5 # 更改禁言设置权限
|
MUTE_LEVEL: int = 5 # 更改禁言设置权限
|
||||||
|
MEMBER_ACTIVITY_LEVEL = 5 # 群员活跃检测设置权限
|
||||||
GROUP_BILIBILI_SUB_LEVEL = 5 # 群内bilibili订阅需要的权限
|
GROUP_BILIBILI_SUB_LEVEL = 5 # 群内bilibili订阅需要的权限
|
||||||
|
|
||||||
DEFAULT_GROUP_LEVEL = 5 # 默认群等级
|
DEFAULT_GROUP_LEVEL = 5 # 默认群等级
|
||||||
@@ -140,6 +144,7 @@ admin_plugins_auth = {
|
|||||||
"upload_img": UPLOAD_LEVEL,
|
"upload_img": UPLOAD_LEVEL,
|
||||||
"admin_help": 1,
|
"admin_help": 1,
|
||||||
"mute": MUTE_LEVEL,
|
"mute": MUTE_LEVEL,
|
||||||
|
"member_activity_handle": MEMBER_ACTIVITY_LEVEL,
|
||||||
}
|
}
|
||||||
|
|
||||||
# 需要cd的功能(方便管理)[秒]
|
# 需要cd的功能(方便管理)[秒]
|
||||||
@@ -307,10 +312,12 @@ HIBIAPI = HIBIAPI[:-1] if HIBIAPI[-1] == "/" else HIBIAPI
|
|||||||
RSSHUBAPP = RSSHUBAPP[:-1] if RSSHUBAPP[-1] == "/" else RSSHUBAPP
|
RSSHUBAPP = RSSHUBAPP[:-1] if RSSHUBAPP[-1] == "/" else RSSHUBAPP
|
||||||
|
|
||||||
|
|
||||||
# plugins2info_file = Path(DATA_PATH) / 'configs' / 'plugins2info.json'
|
if USE_CONFIG_FILE:
|
||||||
# plugins2info_file.parent.mkdir(exist_ok=True, parents=True)
|
# 读取配置文件
|
||||||
#
|
plugins2info_dict, plugins2cd_dict, plugins2exists_dict = init_config(
|
||||||
# with open(f'{DATA_PATH}/configs/')
|
plugins2info_dict, plugins2cd_dict, plugins2exists_dict, DATA_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# 配置文件应用
|
# 配置文件应用
|
||||||
# if USE_CONFIG_FILE:
|
# if USE_CONFIG_FILE:
|
||||||
|
|||||||
+33
-167
@@ -1,176 +1,42 @@
|
|||||||
# import nonebot
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
try:
|
try:
|
||||||
import ujson as json
|
import ujson as json
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
import json
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class GroupInfoUser(db.Model):
|
|||||||
belonging_group: int,
|
belonging_group: int,
|
||||||
user_name: str,
|
user_name: str,
|
||||||
user_join_time: datetime,
|
user_join_time: datetime,
|
||||||
|
uid: Optional[int] = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
@@ -33,6 +34,7 @@ class GroupInfoUser(db.Model):
|
|||||||
:param belonging_group: 群号
|
:param belonging_group: 群号
|
||||||
:param user_name: 用户名称
|
:param user_name: 用户名称
|
||||||
:param user_join_time: 入群时间
|
:param user_join_time: 入群时间
|
||||||
|
:param uid: 用户唯一 id(自动生成)
|
||||||
"""
|
"""
|
||||||
query = cls.query.where(
|
query = cls.query.where(
|
||||||
(cls.user_qq == user_qq) & (cls.belonging_group == belonging_group)
|
(cls.user_qq == user_qq) & (cls.belonging_group == belonging_group)
|
||||||
@@ -44,6 +46,7 @@ class GroupInfoUser(db.Model):
|
|||||||
user_name=user_name,
|
user_name=user_name,
|
||||||
belonging_group=belonging_group,
|
belonging_group=belonging_group,
|
||||||
user_join_time=user_join_time,
|
user_join_time=user_join_time,
|
||||||
|
uid=uid
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@@ -118,14 +118,15 @@ class OmegaPixivIllusts(db.Model):
|
|||||||
参数:
|
参数:
|
||||||
:param tags: 关键词/Tag
|
:param tags: 关键词/Tag
|
||||||
"""
|
"""
|
||||||
query = cls.query
|
setattr(OmegaPixivIllusts, 'count', db.func.count(cls.pid).label('count'))
|
||||||
|
query = cls.select('count')
|
||||||
if tags:
|
if tags:
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
query = query.where(cls.tags.contains(tag))
|
query = query.where(cls.tags.contains(tag))
|
||||||
count = len(await query.where(cls.nsfw_tag == 0).gino.all())
|
count = await query.where(cls.nsfw_tag == 0).gino.first()
|
||||||
setu_count = len(await query.where(cls.nsfw_tag == 1).gino.all())
|
setu_count = await query.where(cls.nsfw_tag == 1).gino.first()
|
||||||
r18_count = len(await query.where(cls.nsfw_tag == 2).gino.all())
|
r18_count = await query.where(cls.nsfw_tag == 2).gino.first()
|
||||||
return count, setu_count, r18_count
|
return count[0], setu_count[0], r18_count[0]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_all_pid(cls) -> List[int]:
|
async def get_all_pid(cls) -> List[int]:
|
||||||
@@ -133,6 +134,6 @@ class OmegaPixivIllusts(db.Model):
|
|||||||
说明:
|
说明:
|
||||||
获取所有图片PID
|
获取所有图片PID
|
||||||
"""
|
"""
|
||||||
data = await cls.query.gino.all()
|
data = await cls.select('pid').gino.all()
|
||||||
return [x.pid for x in data]
|
return [x[0] for x in data]
|
||||||
|
|
||||||
|
|||||||
+6
-5
@@ -159,11 +159,12 @@ class Pixiv(db.Model):
|
|||||||
参数:
|
参数:
|
||||||
:param tags: 关键词/Tag
|
:param tags: 关键词/Tag
|
||||||
"""
|
"""
|
||||||
query = cls.query
|
setattr(Pixiv, 'count', db.func.count(cls.pid).label('count'))
|
||||||
|
query = cls.select('count')
|
||||||
if tags:
|
if tags:
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
query = cls.query.where(cls.tags.contains(tag))
|
query = query.where(cls.tags.contains(tag))
|
||||||
count = len(await query.where(cls.is_r18 == False).gino.all())
|
count = await query.where(cls.is_r18 == False).gino.first()
|
||||||
r18_count = len(await query.where(cls.is_r18 == True).gino.all())
|
r18_count = await query.where(cls.is_r18 == True).gino.first()
|
||||||
return count, r18_count
|
return count[0], r18_count[0]
|
||||||
|
|
||||||
|
|||||||
+8
-3
@@ -57,6 +57,7 @@ class Setu(db.Model):
|
|||||||
local_id: Optional[int] = None,
|
local_id: Optional[int] = None,
|
||||||
tags: Optional[List[str]] = None,
|
tags: Optional[List[str]] = None,
|
||||||
r18: int = 0,
|
r18: int = 0,
|
||||||
|
limit: int = 50,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
@@ -65,6 +66,7 @@ class Setu(db.Model):
|
|||||||
:param local_id: 本地色图 id
|
:param local_id: 本地色图 id
|
||||||
:param tags: tags
|
:param tags: tags
|
||||||
:param r18: 是否 r18,0:非r18 1:r18 2:混合
|
:param r18: 是否 r18,0:非r18 1:r18 2:混合
|
||||||
|
:param limit: 获取数量
|
||||||
"""
|
"""
|
||||||
if local_id:
|
if local_id:
|
||||||
flag = True if r18 == 1 else False
|
flag = True if r18 == 1 else False
|
||||||
@@ -80,7 +82,7 @@ class Setu(db.Model):
|
|||||||
if tags:
|
if tags:
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
query = query.where(cls.tags.contains(tag) | cls.title.contains(tag) | cls.author.contains(tag))
|
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()
|
return await query.gino.all()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -89,8 +91,10 @@ class Setu(db.Model):
|
|||||||
说明:
|
说明:
|
||||||
查询图片数量
|
查询图片数量
|
||||||
"""
|
"""
|
||||||
return len(await cls.query_image(r18=r18))
|
flag = False if r18 == 0 else True
|
||||||
# return await db.func.count(cls.local_id).gino.scalar()
|
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
|
@classmethod
|
||||||
async def get_image_in_hash(cls, img_hash: str) -> "Setu":
|
async def get_image_in_hash(cls, img_hash: str) -> "Setu":
|
||||||
@@ -168,3 +172,4 @@ class Setu(db.Model):
|
|||||||
获取所有图片对象
|
获取所有图片对象
|
||||||
"""
|
"""
|
||||||
return await cls.query.gino.all()
|
return await cls.query.gino.all()
|
||||||
|
|
||||||
|
|||||||
@@ -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.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
|
from .data_source import update_member_info
|
||||||
|
|
||||||
__plugin_name__ = "更新群组成员列表"
|
__plugin_name__ = "更新群组成员列表"
|
||||||
@@ -12,8 +12,6 @@ __plugin_usage__ = """
|
|||||||
更新群组成员列表
|
更新群组成员列表
|
||||||
"""
|
"""
|
||||||
|
|
||||||
export = export()
|
|
||||||
export.update_member_info = update_member_info
|
|
||||||
|
|
||||||
refresh_member_group = on_command(
|
refresh_member_group = on_command(
|
||||||
"更新群组成员列表", aliases={"更新群组成员信息"}, permission=GROUP, priority=5, block=True
|
"更新群组成员列表", 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)
|
await refresh_member_group.finish("更新群员信息成功!", at_sender=True)
|
||||||
else:
|
else:
|
||||||
await refresh_member_group.finish("更新群员信息失败!", at_sender=True)
|
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)
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ __plugin_usage__ = f'''[权限等级]管理帮助:
|
|||||||
\t\t/设置检测次数/设置禁言时长
|
\t\t/设置检测次数/设置禁言时长
|
||||||
[5]7.群订阅相关 -> 指令:添加订阅 [主播/up/番剧] [id/番名/链接]
|
[5]7.群订阅相关 -> 指令:添加订阅 [主播/up/番剧] [id/番名/链接]
|
||||||
\t\t/删除订阅 [id]/ 查看订阅
|
\t\t/删除订阅 [id]/ 查看订阅
|
||||||
|
[5]8.群员活跃度相关 --> 指令:群员活跃检测设置
|
||||||
|
设置群员活跃检测时长(天)
|
||||||
|
添加群员活跃检测白名单[at]...
|
||||||
|
查看群员活跃检测白名单
|
||||||
[6]8.上传图片/连续上传图片(6)
|
[6]8.上传图片/连续上传图片(6)
|
||||||
[7]9.移动图片(7)
|
[7]9.移动图片(7)
|
||||||
[7]10.删除图片(7)
|
[7]10.删除图片(7)
|
||||||
|
|||||||
@@ -279,9 +279,13 @@ async def _get_season_status(id_) -> Optional[str]:
|
|||||||
_idx = (await BilibiliSub.get_sub(id_)).season_current_episode
|
_idx = (await BilibiliSub.get_sub(id_)).season_current_episode
|
||||||
new_ep = season_info["media"]["new_ep"]["index"]
|
new_ep = season_info["media"]["new_ep"]["index"]
|
||||||
if new_ep != _idx:
|
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 (
|
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
|
return None
|
||||||
|
|
||||||
@@ -363,6 +367,8 @@ class SubManager:
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
sub = None
|
sub = None
|
||||||
|
if not self.live_data and not self.up_data and not self.season_data:
|
||||||
|
return sub
|
||||||
self.current_index += 1
|
self.current_index += 1
|
||||||
if self.current_index == 0:
|
if self.current_index == 0:
|
||||||
if self.live_data:
|
if self.live_data:
|
||||||
@@ -382,5 +388,3 @@ class SubManager:
|
|||||||
return sub
|
return sub
|
||||||
await self.reload_sub_data()
|
await self.reload_sub_data()
|
||||||
return await self.random_sub_data()
|
return await self.random_sub_data()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+13
-11
@@ -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()
|
@coser.handle()
|
||||||
@@ -29,20 +29,22 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
|
|||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
try:
|
try:
|
||||||
async with session.get(url, timeout=2) as response:
|
async with session.get(url, timeout=2) as response:
|
||||||
r = re.search(r'±img=(.*)±', await response.text())
|
_url = await response.text()
|
||||||
if r:
|
async with session.get(_url, timeout=5, verify_ssl=False) as res:
|
||||||
async with session.get(r.group(1), 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:
|
async with aiofiles.open(f'{IMAGE_PATH}/temp/{event.user_id}_coser.jpg', 'wb') as f:
|
||||||
await f.write(await res.read())
|
await f.write(await res.read())
|
||||||
logger.info(
|
logger.info(
|
||||||
f"(USER {event.user_id}, "
|
f"(USER {event.user_id}, "
|
||||||
f"GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
|
f"GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
|
||||||
f" 发送COSER"
|
f" 发送COSER"
|
||||||
)
|
)
|
||||||
await coser.send(image(f'{event.user_id}_coser.jpg', 'temp'))
|
await coser.send(image(f'{event.user_id}_coser.jpg', 'temp'))
|
||||||
break
|
break
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
await coser.send('你cos给我看!')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await coser.send('发生了预料之外的错误..请稍后再试或联系管理员修复...')
|
await coser.send('发生了预料之外的错误..请稍后再试或联系管理员修复...')
|
||||||
logger.error(f'coser 发送了未知错误 {type(e)}:{e}')
|
logger.error(f'coser 发送了未知错误 {type(e)}:{e}')
|
||||||
|
|||||||
@@ -164,40 +164,18 @@ async def download_map_init(
|
|||||||
if not _map.exists():
|
if not _map.exists():
|
||||||
# padding_w, padding_h = data['padding']
|
# padding_w, padding_h = data['padding']
|
||||||
data = data["slices"]
|
data = data["slices"]
|
||||||
idx = 0
|
map_url = data[0][0]['url']
|
||||||
for x in data:
|
await download_image(
|
||||||
idj = 0
|
map_url,
|
||||||
for j in x:
|
f"{map_path}/map.png",
|
||||||
await download_image(
|
session,
|
||||||
j["url"],
|
semaphore,
|
||||||
f"{map_path}/{idx}_{idj}.png",
|
force_flag=flag,
|
||||||
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")]
|
|
||||||
)
|
)
|
||||||
background_image = CreateImg(
|
map_file = CreateImg(
|
||||||
map_width * lens, map_height * lens, map_width, map_height
|
0, 0, background=f"{map_path}/map.png", ratio=MAP_RATIO
|
||||||
)
|
)
|
||||||
for i in range(idx):
|
map_file.save(f"{map_path}/map.png")
|
||||||
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")
|
|
||||||
else:
|
else:
|
||||||
logger.warning(f'获取原神地图失败 msg: {data["message"]}')
|
logger.warning(f'获取原神地图失败 msg: {data["message"]}')
|
||||||
else:
|
else:
|
||||||
|
|||||||
+1
-9
@@ -116,15 +116,10 @@ async def _(matcher: Matcher, bot: Bot, event: GroupMessageEvent, state: T_State
|
|||||||
return
|
return
|
||||||
if matcher.type == "message" and matcher.priority not in [1, 9]:
|
if matcher.type == "message" and matcher.priority not in [1, 9]:
|
||||||
if state["_prefix"]["raw_command"]:
|
if state["_prefix"]["raw_command"]:
|
||||||
# print(state["_prefix"]["raw_command"])
|
|
||||||
if _blmt.check(f'{event.user_id}{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):
|
if await BanUser.ban(event.user_id, 9, MALICIOUS_BAN_TIME * 60):
|
||||||
logger.info(f"USER {event.user_id} 触发了恶意触发检测")
|
logger.info(f"USER {event.user_id} 触发了恶意触发检测")
|
||||||
# await update_img.finish('检测到恶意触发命令,您将被封禁 30 分钟', at_sender=True)
|
if isinstance(event, GroupMessageEvent):
|
||||||
if event.message_type == "group":
|
|
||||||
if not static_flmt.check(event.user_id):
|
|
||||||
return
|
|
||||||
static_flmt.start_cd(event.user_id)
|
|
||||||
try:
|
try:
|
||||||
await bot.send_group_msg(
|
await bot.send_group_msg(
|
||||||
group_id=event.group_id,
|
group_id=event.group_id,
|
||||||
@@ -133,9 +128,6 @@ async def _(matcher: Matcher, bot: Bot, event: GroupMessageEvent, state: T_State
|
|||||||
except ActionFailed:
|
except ActionFailed:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if not static_flmt.check(event.user_id):
|
|
||||||
return
|
|
||||||
static_flmt.start_cd(event.user_id)
|
|
||||||
try:
|
try:
|
||||||
await bot.send_private_msg(
|
await bot.send_private_msg(
|
||||||
user_id=event.user_id,
|
user_id=event.user_id,
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ async def get_setu_list(
|
|||||||
index: Optional[int] = None, tags: Optional[List[str]] = None, r18: int = 0
|
index: Optional[int] = None, tags: Optional[List[str]] = None, r18: int = 0
|
||||||
) -> "list, int":
|
) -> "list, int":
|
||||||
if index:
|
if index:
|
||||||
image_count = await Setu.get_image_count(r18)
|
image_count = await Setu.get_image_count(r18) - 1
|
||||||
if index < 0 or index > image_count:
|
if index < 0 or index > image_count:
|
||||||
return [f"超过当前上下限!({image_count})"], 999
|
return [f"超过当前上下限!({image_count})"], 999
|
||||||
image_list = [await Setu.query_image(index, r18=r18)]
|
image_list = [await Setu.query_image(index, r18=r18)]
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ async def group_user_check_in(
|
|||||||
# 取得相应用户
|
# 取得相应用户
|
||||||
user = await SignGroupUser.ensure(user_qq, group, for_update=True)
|
user = await SignGroupUser.ensure(user_qq, group, for_update=True)
|
||||||
# 如果同一天签到过,特殊处理
|
# 如果同一天签到过,特殊处理
|
||||||
# if (
|
if (
|
||||||
# user.checkin_time_last + timedelta(hours=8)
|
user.checkin_time_last + timedelta(hours=8)
|
||||||
# ).date() >= present.date() or f"{user}_{group}_sign_{datetime.now().date()}" in os.listdir(
|
).date() >= present.date() or f"{user}_{group}_sign_{datetime.now().date()}" in os.listdir(
|
||||||
# SIGN_TODAY_CARD_PATH
|
SIGN_TODAY_CARD_PATH
|
||||||
# ):
|
):
|
||||||
# gold = await BagUser.get_gold(user_qq, group)
|
gold = await BagUser.get_gold(user_qq, group)
|
||||||
# return await get_card(user, nickname, -1, gold, "")
|
return await get_card(user, nickname, -1, gold, "")
|
||||||
return await _handle_check_in(nickname, user_qq, group, present) # ok
|
return await _handle_check_in(nickname, user_qq, group, present) # ok
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,10 @@ driver: Driver = nonebot.get_driver()
|
|||||||
@driver.on_startup
|
@driver.on_startup
|
||||||
async def init_image():
|
async def init_image():
|
||||||
SIGN_RESOURCE_PATH.mkdir(parents=True, exist_ok=True)
|
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()
|
generate_progress_bar_pic()
|
||||||
clear_sign_data_pic()
|
clear_sign_data_pic()
|
||||||
|
|
||||||
|
|||||||
+14
-13
@@ -15,16 +15,17 @@ yiqing = on_command("疫情", aliases={"查询疫情", "疫情查询"}, priority
|
|||||||
@yiqing.handle()
|
@yiqing.handle()
|
||||||
async def _(bot: Bot, event: MessageEvent, state: T_State):
|
async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||||
msg = get_message_text(event.json())
|
msg = get_message_text(event.json())
|
||||||
result = await get_yiqing_data(msg)
|
if msg:
|
||||||
if result:
|
result = await get_yiqing_data(msg)
|
||||||
await yiqing.send(result)
|
if result:
|
||||||
logger.info(
|
await yiqing.send(result)
|
||||||
f"(USER {event.user_id}, GROUP "
|
logger.info(
|
||||||
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) 查询疫情: {msg}"
|
f"(USER {event.user_id}, GROUP "
|
||||||
)
|
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) 查询疫情: {msg}"
|
||||||
else:
|
)
|
||||||
await yiqing.send("查询失败!!!!", at_sender=True)
|
else:
|
||||||
logger.info(
|
await yiqing.send("查询失败!!!!", at_sender=True)
|
||||||
f"(USER {event.user_id}, GROUP "
|
logger.info(
|
||||||
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) 查询疫情失败"
|
f"(USER {event.user_id}, GROUP "
|
||||||
)
|
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) 查询疫情失败"
|
||||||
|
)
|
||||||
|
|||||||
+5
-5
@@ -2,13 +2,14 @@
|
|||||||
"update_file": [
|
"update_file": [
|
||||||
"README.md",
|
"README.md",
|
||||||
"configs/config.py",
|
"configs/config.py",
|
||||||
|
"configs/utils/init_config.py",
|
||||||
"models/ban_user.py",
|
"models/ban_user.py",
|
||||||
"models/group_member_info.py",
|
"models/group_member_info.py",
|
||||||
"models/pixiv.py",
|
"models/pixiv.py",
|
||||||
"models/russian_user.py",
|
"models/russian_user.py",
|
||||||
"models/setu.py",
|
"models/setu.py",
|
||||||
"plugins/admin_bot_manage/data_source.py",
|
"models/omega_pixiv_illusts.py",
|
||||||
"plugins/admin_bot_manage/switch_rule.py",
|
"plugins/admin_bot_manage",
|
||||||
"plugins/admin_help/__init__.py",
|
"plugins/admin_help/__init__.py",
|
||||||
"plugins/ai/__init__.py",
|
"plugins/ai/__init__.py",
|
||||||
"plugins/ai/data_source.py",
|
"plugins/ai/data_source.py",
|
||||||
@@ -65,9 +66,7 @@
|
|||||||
"utils/static_data/__init__.py",
|
"utils/static_data/__init__.py",
|
||||||
"utils/static_data/data_class.py",
|
"utils/static_data/data_class.py",
|
||||||
"utils/static_data/group_manager.py",
|
"utils/static_data/group_manager.py",
|
||||||
"utils/utils.py"
|
"utils/utils.py",
|
||||||
],
|
|
||||||
"add_file": [
|
|
||||||
"models/omega_pixiv_illusts.py",
|
"models/omega_pixiv_illusts.py",
|
||||||
"models/sign_group_user.py",
|
"models/sign_group_user.py",
|
||||||
"plugins/bilibili_sub",
|
"plugins/bilibili_sub",
|
||||||
@@ -79,5 +78,6 @@
|
|||||||
"plugins/withdraw.py",
|
"plugins/withdraw.py",
|
||||||
"resources/img/sign"
|
"resources/img/sign"
|
||||||
],
|
],
|
||||||
|
"add_file": [],
|
||||||
"delete_file": ["plugins/nonebot_plugin_withdraw", "models/sigin_group_user.py"]
|
"delete_file": ["plugins/nonebot_plugin_withdraw", "models/sigin_group_user.py"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ from pathlib import Path
|
|||||||
import cv2
|
import cv2
|
||||||
import base64
|
import base64
|
||||||
import imagehash
|
import imagehash
|
||||||
|
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
||||||
|
Image.MAX_IMAGE_PIXELS = None
|
||||||
|
|
||||||
|
|
||||||
def compare_image_with_hash(
|
def compare_image_with_hash(
|
||||||
|
|||||||
Reference in New Issue
Block a user