Merge branch 'HibiKier:main' into main

This commit is contained in:
yajiwa
2022-07-23 18:02:24 +08:00
committed by GitHub
40 changed files with 608 additions and 551 deletions
+29 -5
View File
@@ -1,6 +1,8 @@
from nonebot import on_command
from nonebot.typing import T_State
from nonebot.adapters.onebot.v11 import Bot, MessageEvent, GroupMessageEvent, Message
from utils.message_builder import at
from .data_source import (
add_live_sub,
delete_sub,
@@ -50,7 +52,17 @@ __plugin_configs__ = {
"value": 5,
"help": "群内bilibili订阅需要管理的权限",
"default_value": 5,
}
},
"LIVE_MSG_AT_ALL": {
"value": False,
"help": "直播提醒是否AT全体(仅在真寻是管理员时生效)",
"default_value": False,
},
"UP_MSG_AT_ALL": {
"value": False,
"help": "UP动态投稿提醒是否AT全体(仅在真寻是管理员时生效)",
"default_value": False,
},
}
add_sub = on_command("添加订阅", priority=5, block=True)
@@ -233,10 +245,22 @@ async def send_sub_msg(rst: str, sub: BilibiliSub, bot: Bot):
for x in sub.sub_users.split(",")[:-1]:
try:
if ":" in x and x.split(":")[1] not in temp_group:
temp_group.append(x.split(":")[1])
await bot.send_group_msg(
group_id=int(x.split(":")[1]), message=Message(rst)
)
group_id = int(x.split(":")[1])
temp_group.append(group_id)
if (
await bot.get_group_member_info(
group_id=group_id, user_id=int(bot.self_id), no_cache=True
)
)["role"] in ["owner", "admin"]:
if (
sub.sub_type == "live"
and Config.get_config("bilibili_sub", "LIVE_MSG_AT_ALL")
) or (
sub.sub_type == "up"
and Config.get_config("bilibili_sub", "UP_MSG_AT_ALL")
):
rst = "[CQ:at,qq=all]\n" + rst
await bot.send_group_msg(group_id=group_id, message=Message(rst))
else:
await bot.send_private_msg(user_id=int(x), message=Message(rst))
except Exception as e:
+3
View File
@@ -3,6 +3,8 @@ from nonebot.adapters.onebot.v11 import MessageSegment
from utils.manager import resources_manager
from asyncio.exceptions import TimeoutError
from utils.utils import get_bot
from .model import BilibiliSub
from bilireq.live import get_room_info_by_id
from .utils import get_meta
@@ -229,6 +231,7 @@ async def _get_live_status(id_: int) -> Optional[str]:
await BilibiliSub.update_sub_info(id_, live_status=live_status)
if sub.live_status == 0 and live_status == 1:
return (
f""
f"{image(cover)}\n"
f"{sub.uname} 开播啦!\n"
f"标题:{title}\n"
+9 -9
View File
@@ -47,9 +47,9 @@ class BilibiliSub(db.Model):
season_update_time: Optional[datetime] = None,
) -> bool:
"""
说明:
说明:
添加订阅
参数:
参数:
:param sub_id: 订阅名称,房间号,番剧号等
:param sub_type: 订阅类型
:param sub_user: 订阅此条目的用户
@@ -110,9 +110,9 @@ class BilibiliSub(db.Model):
@classmethod
async def delete_bilibili_sub(cls, sub_id: int, sub_user: str) -> bool:
"""
说明:
说明:
删除订阅
参数:
参数:
:param sub_id: 订阅名称
:param sub_user: 删除此条目的用户
"""
@@ -140,9 +140,9 @@ class BilibiliSub(db.Model):
@classmethod
async def get_sub(cls, sub_id: int) -> Optional["BilibiliSub"]:
"""
说明:
说明:
获取订阅对象
参数:
参数:
:param sub_id: 订阅 id
"""
return await cls.query.where(cls.sub_id == sub_id).gino.first()
@@ -173,9 +173,9 @@ class BilibiliSub(db.Model):
season_update_time: Optional[datetime] = None,
) -> bool:
"""
说明:
说明:
更新订阅信息
参数:
参数:
:param sub_id: 订阅名称,房间号,番剧号等
:param live_short_id: 直接短 id
:param live_status: 主播开播状态
@@ -232,7 +232,7 @@ class BilibiliSub(db.Model):
cls,
) -> "List[BilibiliSub], List[BilibiliSub], List[BilibiliSub]":
"""
说明:
说明:
分类获取所有数据
"""
live_data = []
+10 -10
View File
@@ -25,9 +25,9 @@ class BlackWord(db.Model):
punish_level: int,
):
"""
说明:
说明:
添加用户发送的敏感词
参数:
参数:
:param user_qq: 用户id
:param group_id: 群号
:param black_word: 黑名单词汇
@@ -52,9 +52,9 @@ class BlackWord(db.Model):
id_: Optional[int] = None,
) -> bool:
"""
说明:
说明:
设置处罚
参数:
参数:
:param user_qq: 用户id
:param punish: 处罚
:param black_word: 黑名单词汇
@@ -81,9 +81,9 @@ class BlackWord(db.Model):
cls, user_qq: int, days: int = 7, punish_level: Optional[int] = None
) -> int:
"""
说明:
说明:
获取用户规定周期内的犯事次数
参数:
参数:
:param user_qq: 用户qq
:param days: 周期天数
:param punish_level: 惩罚等级
@@ -101,9 +101,9 @@ class BlackWord(db.Model):
@classmethod
async def get_user_punish_level(cls, user_qq: int, days: int = 7) -> Optional[int]:
"""
说明:
说明:
获取用户最近一次的惩罚记录等级
参数:
参数:
:param user_qq: 用户qq
:param days: 周期天数
"""
@@ -125,9 +125,9 @@ class BlackWord(db.Model):
date_type: str = "=",
) -> List["BlackWord"]:
"""
说明:
说明:
通过指定条件查询数据
参数:
参数:
:param user_qq: 用户qq
:param group_id: 群号
:param date: 日期
-1
View File
@@ -71,7 +71,6 @@ async def _(bot: Bot):
)
@restart.got("flag", prompt=f"确定是否重启{NICKNAME}?确定请回复[是|好|确定](重启失败咱们将失去联系,请谨慎!)")
async def _(flag: str = ArgStr("flag")):
if flag.lower() in ["true", "是", "好", "确定", "确定是"]:
+20 -13
View File
@@ -1,4 +1,7 @@
from typing import Tuple, Any
from nonebot import on_regex
from nonebot.params import RegexGroup
from nonebot.typing import T_State
from nonebot.adapters.onebot.v11 import Bot, MessageEvent
from utils.message_builder import image
@@ -11,7 +14,9 @@ __plugin_usage__ = """
usage:
三次元也不戳,嘿嘿嘿
指令:
cos/coser
?N连cos/coser
示例:cos
示例:5连cos (单次请求张数小于9)
""".strip()
__plugin_des__ = "三次元也不戳,嘿嘿嘿"
__plugin_cmd__ = ["cos/coser"]
@@ -31,21 +36,23 @@ __plugin_configs__ = {
},
}
coser = on_regex("^(cos|COS|coser|括丝)$", priority=5, block=True)
coser = on_regex(r"^(\d)连?(cos|COS|coser|括丝)$", priority=5, block=True)
url = "https://api.iyk0.com/cos"
@coser.handle()
async def _(bot: Bot, event: MessageEvent, state: T_State):
try:
msg_id = await coser.send(image(url))
withdraw_message_manager.withdraw_message(
event,
msg_id["message_id"],
Config.get_config("coser", "WITHDRAW_COS_MESSAGE"),
)
except Exception as e:
await coser.send("你cos给我看!")
logger.error(f"coser 发送了未知错误 {type(e)}:{e}")
async def _(bot: Bot, event: MessageEvent, reg_group: Tuple[Any, ...] = RegexGroup()):
num = reg_group[0] or 1
for _ in range(int(num)):
try:
msg_id = await coser.send(image(url))
withdraw_message_manager.withdraw_message(
event,
msg_id["message_id"],
Config.get_config("coser", "WITHDRAW_COS_MESSAGE"),
)
except Exception as e:
await coser.send("你cos给我看!")
logger.error(f"coser 发送了未知错误 {type(e)}:{e}")
+1 -1
View File
@@ -30,7 +30,7 @@ class Map:
ratio: float = 1,
):
"""
参数:
参数:
:param resource_name: 资源名称
:param center_point: 中心点
:param deviation: 坐标误差
+46 -46
View File
@@ -25,9 +25,9 @@ class Genshin(db.Model):
@classmethod
async def add_uid(cls, user_qq: int, uid: int):
"""
说明:
说明:
添加一个uid
参数:
参数:
:param user_qq: 用户qq
:param uid: 原神uid
"""
@@ -44,9 +44,9 @@ class Genshin(db.Model):
@classmethod
async def set_mys_id(cls, uid: int, mys_id: int) -> bool:
"""
说明:
说明:
设置米游社id
参数:
参数:
:param uid: 原神uid
:param mys_id: 米游社id
"""
@@ -60,9 +60,9 @@ class Genshin(db.Model):
@classmethod
async def set_bind_group(cls, uid: int, bind_group) -> bool:
"""
说明:
说明:
绑定group_id,除私聊外的提醒将在此群发送
参数:
参数:
:param uid: uid
:param bind_group: 群号
"""
@@ -76,9 +76,9 @@ class Genshin(db.Model):
@classmethod
async def get_bind_group(cls, uid: int) -> Optional[int]:
"""
说明:
说明:
获取用户绑定的群聊
参数:
参数:
:param uid: uid
"""
user = await cls.query.where(cls.uid == uid).gino.first()
@@ -89,9 +89,9 @@ class Genshin(db.Model):
@classmethod
async def set_cookie(cls, uid: int, cookie: str) -> bool:
"""
说明:
说明:
设置cookie
参数:
参数:
:param uid: 原神uid
:param cookie: 米游社id
"""
@@ -105,9 +105,9 @@ class Genshin(db.Model):
@classmethod
async def set_resin_remind(cls, uid: int, flag: bool) -> bool:
"""
说明:
说明:
设置体力提醒
参数:
参数:
:param uid: 原神uid
:param flag: 开关状态
"""
@@ -121,9 +121,9 @@ class Genshin(db.Model):
@classmethod
async def set_user_resin_recovery_time(cls, uid: int, date: datetime):
"""
说明:
说明:
设置体力完成时间
参数:
参数:
:param uid: uid
:param date: 提醒日期
"""
@@ -134,9 +134,9 @@ class Genshin(db.Model):
@classmethod
async def get_user_resin_recovery_time(cls, uid: int) -> Optional[datetime]:
"""
说明:
说明:
获取体力完成时间
参数:
参数:
:param uid: uid
"""
u = await cls.query.where(cls.uid == uid).gino.first()
@@ -147,7 +147,7 @@ class Genshin(db.Model):
@classmethod
async def get_all_resin_remind_user(cls) -> List["Genshin"]:
"""
说明:
说明:
获取所有开启体力提醒的用户
"""
return await cls.query.where(cls.resin_remind == True).gino.all()
@@ -155,9 +155,9 @@ class Genshin(db.Model):
@classmethod
async def clear_resin_remind_time(cls, uid: int) -> bool:
"""
说明:
说明:
清空提醒日期
参数:
参数:
:param uid: uid
"""
user = await cls.query.where(cls.uid == uid).gino.first()
@@ -169,9 +169,9 @@ class Genshin(db.Model):
@classmethod
async def set_auto_sign(cls, uid: int, flag: bool) -> bool:
"""
说明:
说明:
设置米游社/原神自动签到
参数:
参数:
:param uid: 原神uid
:param flag: 开关状态
"""
@@ -185,7 +185,7 @@ class Genshin(db.Model):
@classmethod
async def get_all_auto_sign_user(cls) -> List["Genshin"]:
"""
说明:
说明:
获取所有开启自动签到的用户
"""
return await cls.query.where(cls.auto_sign == True).gino.all()
@@ -193,7 +193,7 @@ class Genshin(db.Model):
@classmethod
async def get_all_sign_user(cls) -> List["Genshin"]:
"""
说明:
说明:
获取 原神 所有今日签到用户
"""
return await cls.query.where(cls.auto_sign_time != None).gino.all()
@@ -201,9 +201,9 @@ class Genshin(db.Model):
@classmethod
async def clear_sign_time(cls, uid: int) -> bool:
"""
说明:
说明:
清空签到日期
参数:
参数:
:param uid: uid
"""
user = await cls.query.where(cls.uid == uid).gino.first()
@@ -215,9 +215,9 @@ class Genshin(db.Model):
@classmethod
async def random_sign_time(cls, uid: int) -> Optional[datetime]:
"""
说明:
说明:
随机签到时间
说明:
说明:
:param uid: uid
"""
query = cls.query.where(cls.uid == uid).with_for_update()
@@ -245,9 +245,9 @@ class Genshin(db.Model):
@classmethod
async def get_query_cookie(cls, uid: int) -> Optional[str]:
"""
说明:
说明:
获取查询角色信息cookie
参数:
参数:
:param uid: 原神uid
"""
# 查找用户今日是否已经查找过,防止重复
@@ -265,9 +265,9 @@ class Genshin(db.Model):
@classmethod
async def get_user_cookie(cls, uid: int, flag: bool = False) -> Optional[str]:
"""
说明:
说明:
获取用户cookie
参数:
参数:
:param uid:原神uid
:param flag:必须使用自己的cookie
"""
@@ -279,9 +279,9 @@ class Genshin(db.Model):
@classmethod
async def get_user_by_qq(cls, user_qq: int) -> Optional["Genshin"]:
"""
说明:
说明:
通过qq获取用户对象
参数:
参数:
:param user_qq: qq
"""
return await cls.query.where(cls.user_qq == user_qq).gino.first()
@@ -289,9 +289,9 @@ class Genshin(db.Model):
@classmethod
async def get_user_by_uid(cls, uid: int) -> Optional["Genshin"]:
"""
说明:
说明:
通过uid获取用户对象
参数:
参数:
:param uid: qq
"""
return await cls.query.where(cls.uid == uid).gino.first()
@@ -299,9 +299,9 @@ class Genshin(db.Model):
@classmethod
async def get_user_uid(cls, user_qq: int) -> Optional[int]:
"""
说明:
说明:
获取用户uid
参数:
参数:
:param user_qq:用户qq
"""
return await cls._get_user_data(user_qq, None, "uid")
@@ -311,7 +311,7 @@ class Genshin(db.Model):
"""
说嘛:
获取用户米游社id
参数:
参数:
:param uid:原神id
"""
return await cls._get_user_data(None, uid, "mys_id")
@@ -319,9 +319,9 @@ class Genshin(db.Model):
@classmethod
async def delete_user_cookie(cls, uid: int):
"""
说明:
说明:
删除用户cookie
参数:
参数:
:param uid: 原神uid
"""
query = cls.query.where(cls.uid == uid).with_for_update()
@@ -332,9 +332,9 @@ class Genshin(db.Model):
@classmethod
async def delete_user(cls, user_qq: int):
"""
说明:
说明:
删除用户数据
参数:
参数:
:param user_qq: 用户qq
"""
query = cls.query.where(cls.user_qq == user_qq).with_for_update()
@@ -347,9 +347,9 @@ class Genshin(db.Model):
@classmethod
async def _add_query_uid(cls, uid: int, cookie_uid: int):
"""
说明:
说明:
添加每日查询重复uid的cookie
参数:
参数:
:param uid: 原神uid
:param cookie_uid: cookie的uid
"""
@@ -362,9 +362,9 @@ class Genshin(db.Model):
cls, user_qq: Optional[int], uid: Optional[int], type_: str
) -> Optional[Union[int, str]]:
"""
说明:
说明:
获取用户数据
参数:
参数:
:param user_qq: 用户qq
:param uid: uid
:param type_: 数据类型
+6 -6
View File
@@ -18,9 +18,9 @@ class RedbagUser(db.Model):
@classmethod
async def add_redbag_data(cls, user_qq: int, group_id: int, itype: str, money: int):
"""
说明:
说明:
添加收发红包数据
参数:
参数:
:param user_qq: qq号
:param group_id: 群号
:param itype: 收或发
@@ -45,9 +45,9 @@ class RedbagUser(db.Model):
@classmethod
async def ensure(cls, user_qq: int, group_id: int) -> bool:
"""
说明:
说明:
获取用户对象
参数:
参数:
:param user_qq: qq号
:param group_id: 群号
"""
@@ -61,9 +61,9 @@ class RedbagUser(db.Model):
@classmethod
async def get_user_all(cls, group_id: int = None) -> List["RedbagUser"]:
"""
说明:
说明:
获取所有用户对象
参数:
参数:
:param group_id: 群号
"""
if not group_id:
+1 -1
View File
@@ -31,7 +31,7 @@ async def open_case(user_qq: int, group: int, case_name: str = "狂牙大行动"
async with db.transaction():
user = await OpenCasesUser.ensure(user_qq, group, for_update=True)
# 一天次数上限
if user.today_open_total == int(
if user.today_open_total > int(
Config.get_config("open_cases", "INITIAL_OPEN_CASE_COUNT")
+ int(impression)
/ Config.get_config("open_cases", "EACH_IMPRESSION_ADD_COUNT")
+11 -12
View File
@@ -56,18 +56,11 @@ async def _(event: GroupMessageEvent):
) as session:
async with session.get(
data["meta"]["detail_1"]["qqdocurl"],
proxy=get_local_proxy(),
timeout=7,
) as response:
url = str(response.url).split("?")[0]
bvid = url.split("/")[-1]
vd_info = await video.get_video_base_info(bvid)
# response = await AsyncHttpx.get(
# data["meta"]["detail_1"]["qqdocurl"], timeout=7
# )
# url = str(response.url).split("?")[0]
# bvid = url.split("/")[-1]
# vd_info = await video.Video(bvid=bvid).get_info()
# 转发专栏
if (
data.get("meta")
@@ -123,11 +116,17 @@ async def _(event: GroupMessageEvent):
url = f"https://www.bilibili.com/video/{msg}"
vd_info = await video.get_video_base_info(msg)
elif "https://b23.tv" in msg:
url = "https://" + msg[msg.find("b23.tv") : msg.find("b23.tv") + 13]
res = await AsyncHttpx.get(url, timeout=7)
url = str(res.url).split("?")[0]
bvid = url.split("/")[-1]
vd_info = await video.get_video_base_info(bvid)
url = "https://" + msg[msg.find("b23.tv"): msg.find("b23.tv") + 14]
async with aiohttp.ClientSession(
headers=get_user_agent()
) as session:
async with session.get(
url,
timeout=7,
) as response:
url = str(response.url).split("?")[0]
bvid = url.split("/")[-1]
vd_info = await video.get_video_base_info(bvid)
if vd_info:
if (
url in _tmp.keys() and time.time() - _tmp[url] > 30
@@ -38,9 +38,9 @@ class OmegaPixivIllusts(db.Model):
updated_at: datetime,
):
"""
说明:
说明:
添加图片信息
参数:
参数:
:param pid: pid
:param title: 标题
:param width: 宽度
@@ -78,9 +78,9 @@ class OmegaPixivIllusts(db.Model):
num: int = 100
) -> List[Optional["OmegaPixivIllusts"]]:
"""
说明:
说明:
查找符合条件的图片
参数:
参数:
:param keywords: 关键词
:param uid: 画师uid
:param pid: 图片pid
@@ -104,9 +104,9 @@ class OmegaPixivIllusts(db.Model):
@classmethod
async def check_exists(cls, pid: int) -> bool:
"""
说明:
说明:
检测pid是否已存在
参数:
参数:
:param pid: 图片PID
"""
query = await cls.query.where(cls.pid == pid).gino.all()
@@ -115,9 +115,9 @@ class OmegaPixivIllusts(db.Model):
@classmethod
async def get_keyword_num(cls, tags: List[str] = None) -> "int, int, int":
"""
说明:
说明:
获取相关关键词(keyword, tag)在图库中的数量
参数:
参数:
:param tags: 关键词/Tag
"""
setattr(OmegaPixivIllusts, 'count', db.func.count(cls.pid).label('count'))
@@ -133,7 +133,7 @@ class OmegaPixivIllusts(db.Model):
@classmethod
async def get_all_pid(cls) -> List[int]:
"""
说明:
说明:
获取所有图片PID
"""
data = await cls.select('pid').gino.all()
+11 -11
View File
@@ -38,9 +38,9 @@ class Pixiv(db.Model):
tags: str,
):
"""
说明:
说明:
添加图片信息
参数:
参数:
:param pid: pid
:param title: 标题
:param width: 宽度
@@ -74,9 +74,9 @@ class Pixiv(db.Model):
@classmethod
async def remove_image_data(cls, pid: int, img_p: str) -> bool:
"""
说明:
说明:
删除图片数据
参数:
参数:
:param pid: 图片pid
:param img_p: 图片pid的张数,如:p0,p1
"""
@@ -94,7 +94,7 @@ class Pixiv(db.Model):
@classmethod
async def get_all_pid(cls) -> List[int]:
"""
说明:
说明:
获取所有PID
"""
query = await cls.query.select("pid").gino.first()
@@ -112,9 +112,9 @@ class Pixiv(db.Model):
num: int = 100
) -> List[Optional["Pixiv"]]:
"""
说明:
说明:
查找符合条件的图片
参数:
参数:
:param keywords: 关键词
:param uid: 画师uid
:param pid: 图片pid
@@ -140,9 +140,9 @@ class Pixiv(db.Model):
@classmethod
async def check_exists(cls, pid: int, img_p: str) -> bool:
"""
说明:
说明:
检测pid是否已存在
参数:
参数:
:param pid: 图片PID
:param img_p: 张数
"""
@@ -154,9 +154,9 @@ class Pixiv(db.Model):
@classmethod
async def get_keyword_num(cls, tags: List[str] = None) -> "int, int":
"""
说明:
说明:
获取相关关键词(keyword, tag)在图库中的数量
参数:
参数:
:param tags: 关键词/Tag
"""
setattr(Pixiv, 'count', db.func.count(cls.pid).label('count'))
@@ -19,9 +19,9 @@ class PixivKeywordUser(db.Model):
cls, user_qq: int, group_id: int, keyword: str, superusers: Set[str]
) -> bool:
"""
说明:
说明:
添加搜图的关键词
参数:
参数:
:param user_qq: qq号
:param group_id: 群号
:param keyword: 关键词
@@ -38,9 +38,9 @@ class PixivKeywordUser(db.Model):
@classmethod
async def delete_keyword(cls, keyword: str) -> bool:
"""
说明:
说明:
删除关键词
参数:
参数:
:param keyword: 关键词
"""
if await cls._check_keyword_exists(keyword):
@@ -53,9 +53,9 @@ class PixivKeywordUser(db.Model):
@classmethod
async def set_keyword_pass(cls, keyword: str, is_pass: bool) -> "int, int":
"""
说明:
说明:
通过或禁用关键词
参数:
参数:
:param keyword: 关键词
:param is_pass: 通过状态
"""
@@ -71,7 +71,7 @@ class PixivKeywordUser(db.Model):
@classmethod
async def get_all_user_dict(cls) -> dict:
"""
说明:
说明:
获取关键词数据库各个用户贡献的关键词字典
"""
tmp = {}
@@ -85,7 +85,7 @@ class PixivKeywordUser(db.Model):
@classmethod
async def get_current_keyword(cls) -> "List[str], List[str]":
"""
说明:
说明:
获取当前通过与未通过的关键词
"""
pass_keyword = []
@@ -101,7 +101,7 @@ class PixivKeywordUser(db.Model):
@classmethod
async def get_black_pid(cls) -> List[str]:
"""
说明:
说明:
获取黑名单PID
"""
black_pid = []
@@ -113,9 +113,9 @@ class PixivKeywordUser(db.Model):
@classmethod
async def _check_keyword_exists(cls, keyword: str) -> bool:
"""
说明:
说明:
检测关键词是否已存在
参数:
参数:
:param keyword: 关键词
"""
current_keyword = []
+1 -1
View File
@@ -184,7 +184,7 @@ async def _():
logger.info(f"添加OmegaPixivIllusts图库数据已存在 ---> pid:{pid}")
omega_pixiv_illusts = None
for file in os.listdir("."):
if "omega_pixiv_illusts" in file and ".sql" in file:
if "omega_pixiv_artwork" in file and ".sql" in file:
omega_pixiv_illusts = Path() / file
if omega_pixiv_illusts:
with open(omega_pixiv_illusts, "r", encoding="utf8") as f:
+1 -1
View File
@@ -17,7 +17,7 @@ __zx_plugin_name__ = "P站排行/搜图"
__plugin_usage__ = """
usage:
P站排行:
可选参数:
可选参数:
类型:
1. 日排行
2. 周排行
+8 -8
View File
@@ -23,9 +23,9 @@ class RussianUser(db.Model):
@classmethod
async def ensure(cls, user_qq: int, group_id: int) -> "RussianUser":
"""
说明:
说明:
获取用户对象
参数:
参数:
:param user_qq: qq号
:param group_id: 群号
"""
@@ -39,9 +39,9 @@ class RussianUser(db.Model):
@classmethod
async def add_count(cls, user_qq: int, group_id: int, itype: str) -> bool:
"""
说明:
说明:
添加用户输赢次数
说明:
说明:
:param user_qq: qq号
:param group_id: 群号
:param itype: 输或赢 'win' or 'lose'
@@ -87,9 +87,9 @@ class RussianUser(db.Model):
@classmethod
async def money(cls, user_qq: int, group_id: int, itype: str, count: int) -> bool:
"""
说明:
说明:
添加用户输赢金钱
参数:
参数:
:param user_qq: qq号
:param group_id: 群号
:param itype: 输或赢 'win' or 'lose'
@@ -120,9 +120,9 @@ class RussianUser(db.Model):
@classmethod
async def get_all_user(cls, group_id: int) -> List["RussianUser"]:
"""
说明:
说明:
获取该群所有用户对象
参数:
参数:
:param group_id: 群号
"""
users = await cls.query.where((cls.group_id == group_id)).gino.all()
+14 -14
View File
@@ -30,9 +30,9 @@ class Setu(db.Model):
tags: str,
):
"""
说明:
说明:
添加一份色图数据
参数:
参数:
:param local_id: 本地存储id
:param title: 标题
:param author: 作者
@@ -62,9 +62,9 @@ class Setu(db.Model):
limit: int = 50,
):
"""
说明:
说明:
通过tag查找色图
参数:
参数:
:param local_id: 本地色图 id
:param tags: tags
:param r18: 是否 r18,0:非r18 1:r18 2:混合
@@ -90,7 +90,7 @@ class Setu(db.Model):
@classmethod
async def get_image_count(cls, r18: int = 0) -> int:
"""
说明:
说明:
查询图片数量
"""
flag = False if r18 == 0 else True
@@ -101,9 +101,9 @@ class Setu(db.Model):
@classmethod
async def get_image_in_hash(cls, img_hash: str) -> "Setu":
"""
说明:
说明:
通过图像hash获取图像信息
参数:
参数:
:param img_hash: = 图像hash值
"""
query = await cls.query.where(cls.img_hash == img_hash).gino.first()
@@ -112,9 +112,9 @@ class Setu(db.Model):
@classmethod
async def _check_exists(cls, pid: int, img_url: str) -> bool:
"""
说明:
说明:
检测图片是否存在
参数:
参数:
:param pid: 图片pid
:param img_url: 图片链接
"""
@@ -127,9 +127,9 @@ class Setu(db.Model):
@classmethod
async def delete_image(cls, pid: int) -> int:
"""
说明:
说明:
删除图片并替换
参数:
参数:
:param pid: 图片pid
"""
query = await cls.query.where(cls.pid == pid).gino.first()
@@ -157,9 +157,9 @@ class Setu(db.Model):
tags: Optional[str] = None,
) -> bool:
"""
说明:
说明:
根据PID修改图片数据
参数:
参数:
:param local_id: 本地id
:param pid: 图片pid
:param title: 标题
@@ -190,7 +190,7 @@ class Setu(db.Model):
@classmethod
async def get_all_setu(cls) -> List["Setu"]:
"""
说明:
说明:
获取所有图片对象
"""
return await cls.query.gino.all()
+7 -7
View File
@@ -76,7 +76,7 @@ async def _(user: User = Depends(token_to_user)) -> Result:
async def get_system_data(user: User = Depends(token_to_user)):
"""
说明:
说明:
获取系统信息,资源文件大小,网络状态等
"""
baidu = 200
@@ -107,7 +107,7 @@ async def get_system_data(user: User = Depends(token_to_user)):
def _get_system_status(user: User = Depends(token_to_user)) -> SystemStatus:
"""
说明:
说明:
获取系统信息等
"""
cpu = psutil.cpu_percent()
@@ -126,7 +126,7 @@ def _get_system_disk(
type_: Optional[str], user: User = Depends(token_to_user)
) -> Union[SystemFolderSize, Dict[str, Union[float, datetime]]]:
"""
说明:
说明:
获取资源文件大小等
"""
if not type_:
@@ -171,9 +171,9 @@ def _get_system_disk(
def _get_dir_size(dir_path: Path) -> float:
"""
说明:
说明:
获取文件夹大小
参数:
参数:
:param dir_path: 文件夹路径
"""
size = 0
@@ -184,9 +184,9 @@ def _get_dir_size(dir_path: Path) -> float:
def save_system_data(cpu: float, memory: float, disk: float):
"""
说明:
说明:
保存一些系统信息
参数:
参数:
:param cpu: cpu
:param memory: memory
:param disk: disk
+34 -34
View File
@@ -1,34 +1,34 @@
from configs.config import Config
import nonebot
Config.add_plugin_config(
"word_bank",
"WORD_BANK_LEVEL [LEVEL]",
5,
name="词库问答",
help_="设置增删词库的权限等级",
default_value=5
)
Config.add_plugin_config(
"word_bank",
"WORD_BANK_FUZZY",
False,
help_="模糊匹配",
default_value=False
)
Config.add_plugin_config(
"word_bank",
"WORD_BANK_KEY",
True,
help_="关键字匹配",
default_value=True
)
Config.add_plugin_config(
"word_bank",
"WORD_BANK_MIX",
25,
help_="查看词条时图片内最多显示条数",
default_value=25
)
nonebot.load_plugins("plugins/word_bank")
# from configs.config import Config
# import nonebot
#
# Config.add_plugin_config(
# "word_bank",
# "WORD_BANK_LEVEL [LEVEL]",
# 5,
# name="词库问答",
# help_="设置增删词库的权限等级",
# default_value=5
# )
#
# Config.add_plugin_config(
# "word_bank",
# "WORD_BANK_FUZZY",
# False,
# help_="模糊匹配",
# default_value=False
# )
# Config.add_plugin_config(
# "word_bank",
# "WORD_BANK_KEY",
# True,
# help_="关键字匹配",
# default_value=True
# )
# Config.add_plugin_config(
# "word_bank",
# "WORD_BANK_MIX",
# 25,
# help_="查看词条时图片内最多显示条数",
# default_value=25
# )
# nonebot.load_plugins("plugins/word_bank")