Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/mcbbs_news/__init__.py

26 lines
820 B
Python
Raw Normal View History

2023-02-05 14:33:33 +00:00
from core.builtins import Bot, Url
2023-03-04 08:51:56 +00:00
from core.component import module
2022-08-04 07:52:42 +00:00
from core.logger import Logger
2022-01-19 14:41:31 +00:00
from .mcbbs_news import news
2023-03-04 08:51:56 +00:00
mcbbs_news = module(
2022-01-19 14:41:31 +00:00
bind_prefix='mcbbs_news',
2022-01-21 12:19:32 +00:00
alias=['mn', 'mcbbsnews'],
developers=['Dianliang233']
2022-01-19 14:41:31 +00:00
)
2023-03-19 03:38:05 +00:00
@mcbbs_news.handle('{{mcbbs_news.help}}')
2023-02-05 14:33:33 +00:00
async def main(msg: Bot.MessageSession):
2023-03-23 15:25:46 +00:00
res = await news(msg)
2022-08-04 07:52:42 +00:00
Logger.debug('res' + str(res))
2022-01-19 14:41:31 +00:00
if res is None:
2023-03-19 03:38:05 +00:00
message = msg.locale.t('mcbbs_news.message.not_found')
2022-01-19 14:41:31 +00:00
else:
lst = []
for i in res:
lst += [f'{i["count"]}. [{i["category"]}] {i["title"]} - {i["author"]} @ {i["time"]}\n{i["url"]}']
2023-03-19 05:00:32 +00:00
message = '\n'.join(lst) + '\n' + msg.locale.t('mcbbs_news.message.more') + \
2022-07-31 08:33:20 +00:00
Url('https://www.mcbbs.net/forum-news-1.html').url
2022-05-21 16:04:29 +00:00
await msg.finish(message)