Skip to content

Commit

Permalink
Merge pull request #163 from Ailitonia/dev
Browse files Browse the repository at this point in the history
Releases: pre-release v1.0.0-delta
  • Loading branch information
Ailitonia authored Dec 31, 2024
2 parents 9b66fa8 + c038ee0 commit a5d8485
Show file tree
Hide file tree
Showing 374 changed files with 19,311 additions and 7,545 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,8 @@ tmp/
# alembic versions
alembic_scripts/versions/

# private script
*.private.py
*.nonpublic.py

# End of https://www.toptal.com/developers/gitignore/api/python
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ _基于 [Nonebot2](https://github.com/nonebot/nonebot2) 的多平台机器人_
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/Ailitonia/omega-miya?include_prereleases)
![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/Ailitonia/omega-miya)
<br>
![Nonebot2](https://img.shields.io/badge/Nonebot2-Release_v2.3.2-brightgreen)
![Nonebot2](https://img.shields.io/badge/Nonebot2-v2.4.1-lightgrey?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAaVBMVEX//////////////////////////////////////////////////////////////////////////////Pz+9/f++fn84+P729v73t7++Pj+8/P62dn97Oz97e3+9fX+9vb84uL98/P98vKkMaRVAAAAEnRSTlMRh+ztjBP5+o/q7/7x+5OO8hXWMtBoAAAAAWJLR0QAiAUdSAAAAAd0SU1FB+QIBRALHK18bjMAAACFSURBVBjTbY/bEoIwDESDgqjcNCm9kCro/3+kCU4tM9iX7JxMdzcAxQF/71hWUJxUkTGksz7DRcZonffOBpFXaBAnjrKmB09CQPb8/DrMHFZgY/KMVgE5SkAloPE51pt/YPcFl2y6rCmB522sFHulYm8tpqeFXL2Fst4e1/VQDW2OvfX3D9EcEtYPs4uwAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIwLTA4LTA1VDE2OjExOjI4KzAyOjAwtwGtpQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMC0wOC0wNVQxNjoxMToyOCswMjowMMZcFRkAAABXelRYdFJhdyBwcm9maWxlIHR5cGUgaXB0YwAAeJzj8gwIcVYoKMpPy8xJ5VIAAyMLLmMLEyMTS5MUAxMgRIA0w2QDI7NUIMvY1MjEzMQcxAfLgEigSi4A6hcRdPJCNZUAAAAASUVORK5CYII=)
![OneBot v11](https://img.shields.io/badge/OneBot-v11-black?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAAAAADAwMHBwceHh4UFBQNDQ0ZGRkoKCgvLy8iIiLWSdWYAAAAAXRSTlMAQObYZgAAAQVJREFUSMftlM0RgjAQhV+0ATYK6i1Xb+iMd0qgBEqgBEuwBOxU2QDKsjvojQPvkJ/ZL5sXkgWrFirK4MibYUdE3OR2nEpuKz1/q8CdNxNQgthZCXYVLjyoDQftaKuniHHWRnPh2GCUetR2/9HsMAXyUT4/3UHwtQT2AggSCGKeSAsFnxBIOuAggdh3AKTL7pDuCyABcMb0aQP7aM4AnAbc/wHwA5D2wDHTTe56gIIOUA/4YYV2e1sg713PXdZJAuncdZMAGkAukU9OAn40O849+0ornPwT93rphWF0mgAbauUrEOthlX8Zu7P5A6kZyKCJy75hhw1Mgr9RAUvX7A3csGqZegEdniCx30c3agAAAABJRU5ErkJggg==)
![QQ频道](https://img.shields.io/badge/QQ%E9%A2%91%E9%81%93-Bot-lightgrey?style=social&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMTIuODIgMTMwLjg5Ij48ZyBkYXRhLW5hbWU9IuWbvuWxgiAyIj48ZyB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IGZpbGw9IiMxMDlmZmUiLz48cGF0aCBkPSJNODAuMjcgNzkuMjdjLS41MyAzLjkxIDEuNzUgOS42NC01Ljg4IDEwLTcuNDcuMzctNi44MS00LjgyLTYuNjEtOS41LjItNC4zMi0xLjgzLTEwIDUuNzgtMTAuNDJzNi41OSA0Ljg5IDYuNzEgOS45MnoiIGZpbGw9IiMwODljZmUiLz48L2c+PC9nPjwvc3ZnPg==)
![Telegram](https://img.shields.io/badge/telegram-Bot-lightgrey?style=social&logo=telegram)
</div>

## 当前适配 nonebot2 版本

[Nonebot2 Release v2.3.3](https://github.com/nonebot/nonebot2/releases/tag/v2.3.3)

## 功能 & 特点

- 基于异步 SQLAlchemy ORM, 支持多种数据库连接
Expand All @@ -45,12 +41,12 @@ _基于 [Nonebot2](https://github.com/nonebot/nonebot2) 的多平台机器人_
- B站动态订阅
- B站直播间监控
- 微博用户订阅
- 图站作品预览 (需要 HTTP 代理, 或部署在外网)
- Pixiv用户订阅 (需要 HTTP 代理, 或部署在外网)
- Pixivision特辑订阅 (需要 HTTP 代理, 或部署在外网)
- 图站作品预览 (如不能直接访问各图站, 则需要 HTTP 代理)
- Pixiv用户订阅 (如不能直接访问 Pixiv 主站, 则需要 HTTP 代理)
- Pixivision特辑订阅 (如不能直接访问 Pixiv 主站, 则需要 HTTP 代理)
- 签到卡片
- 求签
- 抽卡
- 词云
- roll 点抽奖
- 塔罗牌
- 翻译插件 (使用腾讯云 API)
Expand All @@ -64,7 +60,7 @@ _基于 [Nonebot2](https://github.com/nonebot/nonebot2) 的多平台机器人_
- 来点萌图 / 来点涩图 (需要 HTTP 代理, 除非部署在外网 / 图片数据库需要自己导入)
- 表情包制作器
- 今天吃啥
- 自动锤轴姬 (需要 go-cqhttp v0.9.40 及以上版本)
- 自动锤轴姬 (需要 OneBot V11 协议端支持文件发送 API)
- 邮箱插件 (仅支持IMAP收件)

## 如何使用
Expand Down Expand Up @@ -100,12 +96,15 @@ danbooru/konachan/yande.re 的高评分作品

#### Classification: 主要体现图片由谁分级以及分级的**可靠性**

- `Ignored = -2` 可能是由于**XP不符**/低质/敏感话题/广告等因素, 被人工手动审核/标记为忽略该作品, 一般情况下不应当使用分类为此等级的图片
- `Unknown = -1` 无法确认分类级别, 一般为本地图片或无确切来源的图片
- `Unclassified = 0` 未分类, 一般为无分级图站作品默认分类级别
- `AIGenerated = 1` 确认/疑似为 AI 生成作品
- `Automatic = 2` 由图站分类/图站分级/第三方接口分类, 可能由人工进行分类但不完全可信, 一般可作为应用层插件使用的最低可信级别
- `Confirmed = 3` 由人工审核/确认为 "人类生成" 的作品, 且分级可信

~~说白了就是 `Classification = 3` 的才代表本人XP, 其他级别均为未分类/自动爬取/忽略排除, 本人概不负责~~

#### Rating: 图片分级

- `Unknown = -1` 未知, 可能为下面任意一种分级的其中之一, 绝对不要直接当作 G-rated 作品使用
Expand Down
9 changes: 4 additions & 5 deletions alembic_scripts/env.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import asyncio
from logging.config import fileConfig

from alembic import context
from sqlalchemy import pool
from sqlalchemy.engine import Connection
from sqlalchemy.ext.asyncio import async_engine_from_config

from alembic import context

from src.database.schema_base import OmegaDeclarativeBase

# this is the Alembic Config object, which provides
Expand Down Expand Up @@ -42,12 +41,12 @@ def run_migrations_offline() -> None:
script output.
"""
url = config.get_main_option("sqlalchemy.url")
url = config.get_main_option('sqlalchemy.url')
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
dialect_opts={'paramstyle': 'named'},
)

with context.begin_transaction():
Expand All @@ -69,7 +68,7 @@ async def run_async_migrations() -> None:

connectable = async_engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
prefix='sqlalchemy.',
poolclass=pool.NullPool,
)

Expand Down
25 changes: 6 additions & 19 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,18 @@
@Software : PyCharm
"""

import os
import sys
from datetime import datetime

import nonebot
from nonebot.log import logger, default_format

# Log file path
bot_log_path = os.path.abspath(os.path.join(sys.path[0], 'log'))
if not os.path.exists(bot_log_path):
os.makedirs(bot_log_path)

# Custom logger
log_info_name = f'{datetime.now().strftime("%Y%m%d-%H%M%S")}-INFO.log'
log_error_name = f'{datetime.now().strftime("%Y%m%d-%H%M%S")}-ERROR.log'
log_info_path = os.path.join(bot_log_path, log_info_name)
log_error_path = os.path.join(bot_log_path, log_error_name)
from src.resource import LogFileResource

logger.add(log_info_path, rotation='00:00', diagnose=False, level='INFO', format=default_format, encoding='utf-8')
logger.add(log_error_path, rotation='00:00', diagnose=False, level='ERROR', format=default_format, encoding='utf-8')
# Log file path
log_path = LogFileResource()
logger.add(log_path.info, rotation='00:00', diagnose=False, level='INFO', format=default_format, encoding='utf-8')
logger.add(log_path.error, rotation='00:00', diagnose=False, level='ERROR', format=default_format, encoding='utf-8')

# Add extra debug log file
# log_debug_name = f'{datetime.now().strftime("%Y%m%d-%H%M%S")}-DEBUG.log'
# log_debug_path = os.path.join(bot_log_path, log_debug_name)
# logger.add(log_debug_path, rotation='00:00', diagnose=False, level='DEBUG', format=default_format, encoding='utf-8')
# logger.add(log_path.debug, rotation='00:00', diagnose=False, level='DEBUG', format=default_format, encoding='utf-8')

# You can pass some keyword args config to init function
nonebot.init()
Expand Down
Loading

0 comments on commit a5d8485

Please sign in to comment.