Skip to content

Commit

Permalink
修复早报60s (#465)
Browse files Browse the repository at this point in the history
* 🔧 自动更新依赖文件

* 修改早报60s为可配置项,修改路径在派蒙管理后台:首页->配置项管理->其他配置

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Lin Mew and github-actions[bot] authored Aug 21, 2023
1 parent d1f345e commit a9d4048
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 457 deletions.
3 changes: 3 additions & 0 deletions LittlePaimon/config/config/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class ConfigModel(BaseModel):

command_alias_enable: bool = Field(True, alias='启用命令别名')

# 早报60s
morning_news: str = Field('https://api.vvhan.com/api/60s', alias='早报60s')

github_proxy: str = Field('https://github.cherishmoon.fun/', alias='github资源地址')

@property
Expand Down
6 changes: 4 additions & 2 deletions LittlePaimon/plugins/news60s/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment
from nonebot.plugin import PluginMetadata

from LittlePaimon.config import config
from LittlePaimon.database import GeneralSub
from LittlePaimon.utils import scheduler, logger, DRIVER
from LittlePaimon.utils.message import CommandObjectID, CommandSwitch, CommandTime
Expand All @@ -23,14 +24,15 @@
},
)


news = on_command('早报', aliases={'今日早报', '今日新闻', '60s读世界', '60秒读世界'}, priority=14, block=True)


@news.handle()
async def _(event: MessageEvent, sub_id=CommandObjectID(), switch=CommandSwitch(), sub_time=CommandTime()):
if switch is None:
await news.send('60秒读世界新闻获取中,请稍等...')
await news.finish(MessageSegment.image(file='https://api.emoao.com/api/60s'))
await news.finish(MessageSegment.image(file=config.morning_news))
else:
sub_data = {
'sub_id': sub_id,
Expand Down Expand Up @@ -101,7 +103,7 @@ async def send_news(sub_id: int, sub_type: str, extra_id: Optional[int]):
else:
api = 'send_group_msg'
data = {'group_id': sub_id}
data['message'] = MessageSegment.image(file='https://api.emoao.com/api/60s')
data['message'] = MessageSegment.image(file=config.morning_news)
await get_bot().call_api(api, **data)
logger.info('60秒读世界', '', {sub_type: sub_id}, '推送成功', True)
except Exception as e:
Expand Down
7 changes: 7 additions & 0 deletions LittlePaimon/web/pages/config_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@
suffix='秒',
min=5,
),
InputText(
label='早报60s',
name='早报60s',
value='${早报60s}',
placeholder='请填写早报60s的API地址',
labelRemark=Remark(shape='circle', content='修改早报60s的API地址,不填则使用默认地址')
),
Select(
label='github资源地址',
name='github资源地址',
Expand Down
Loading

0 comments on commit a9d4048

Please sign in to comment.