mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +08:00
add monster-siren
This commit is contained in:
parent
4f82ae2518
commit
83178261d5
35
src/plugins/nonebot_hk_reporter/platform/monster_siren.py
Normal file
35
src/plugins/nonebot_hk_reporter/platform/monster_siren.py
Normal file
@ -0,0 +1,35 @@
|
||||
from typing import Any
|
||||
import httpx
|
||||
import json
|
||||
|
||||
from .platform import PlatformNoTarget
|
||||
from ..utils import Singleton
|
||||
from ..types import RawPost
|
||||
from ..post import Post
|
||||
|
||||
class MonsterSiren(PlatformNoTarget):
|
||||
|
||||
categories = {}
|
||||
platform_name = 'monster-siren'
|
||||
enable_tag = False
|
||||
|
||||
@staticmethod
|
||||
async def get_account_name(_) -> str:
|
||||
return '塞壬唱片新闻'
|
||||
|
||||
async def get_sub_list(self) -> list[RawPost]:
|
||||
async with httpx.AsyncClient() as client:
|
||||
raw_data = await client.get('https://monster-siren.hypergryph.com/api/news')
|
||||
return raw_data.json()['data']['list']
|
||||
|
||||
def get_id(self, post: RawPost) -> Any:
|
||||
return post['cid']
|
||||
|
||||
def get_date(self, _) -> None:
|
||||
return None
|
||||
|
||||
async def parse(self, raw_post: RawPost) -> Post:
|
||||
url = f'https://monster-siren.hypergryph.com/info/{raw_post["cid"]}'
|
||||
return Post('monster-siren', text=raw_post['title'],
|
||||
url=url, target_name="塞壬唱片新闻", compress=True,
|
||||
override_use_pic=False)
|
@ -5,6 +5,7 @@ from typing import Type
|
||||
from .arknights import Arknights
|
||||
from .weibo import Weibo
|
||||
from .bilibili import Bilibili
|
||||
from .monster_siren import MonsterSiren
|
||||
from .rss import Rss
|
||||
from .wechat import Wechat
|
||||
from .platform import PlatformProto
|
||||
@ -20,6 +21,7 @@ platform_manager: dict[str, PlatformProto] = {
|
||||
'weibo': Weibo(),
|
||||
'rss': Rss(),
|
||||
'arknights': Arknights(),
|
||||
'monster-siren': MonsterSiren(),
|
||||
# 'wechat': Wechat(),
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,10 @@ async def rss_check():
|
||||
async def arknights_check():
|
||||
await fetch_and_send('arknights')
|
||||
|
||||
@scheduler.scheduled_job('interval', seconds=30)
|
||||
async def monster_siren_check():
|
||||
await fetch_and_send('monster-siren')
|
||||
|
||||
# @scheduler.scheduled_job('interval', seconds=30)
|
||||
# async def wechat_check():
|
||||
# await fetch_and_send('wechat')
|
||||
|
@ -21,7 +21,7 @@ class Singleton(type):
|
||||
return cls._instances[cls]
|
||||
|
||||
# supported_target_type = ('weibo', 'bilibili', 'rss', 'arknights', 'wechat')
|
||||
supported_target_type = ('weibo', 'bilibili', 'rss', 'arknights')
|
||||
supported_target_type = ('weibo', 'bilibili', 'rss', 'arknights', 'monster-siren')
|
||||
|
||||
if not plugin_config.hk_reporter_use_local and not check_chromium():
|
||||
os.environ['PYPPETEER_DOWNLOAD_HOST'] = 'http://npm.taobao.org/mirrors'
|
||||
|
Loading…
x
Reference in New Issue
Block a user