diff --git a/src/plugins/nonebot_hk_reporter/platform/wechat.py b/src/plugins/nonebot_hk_reporter/platform/wechat.py index a3d3d6c..a07e33b 100644 --- a/src/plugins/nonebot_hk_reporter/platform/wechat.py +++ b/src/plugins/nonebot_hk_reporter/platform/wechat.py @@ -45,7 +45,8 @@ class Wechat(Platform): post = { 'title': last_post_dt.find_parent().find('a').text, 'target': target, - 'page_url': self._get_query_url(target) + 'page_url': self._get_query_url(target), + 'name': block.find('p', class_='tit').find('a').text } return [post] else: @@ -67,6 +68,7 @@ class Wechat(Platform): # TODO get content of post return Post(target_type='wechat', text='{}\n详细内容请自行查看公众号'.format(raw_post['title']), + target_name=raw_post['name'], pics=[], url='' ) diff --git a/src/plugins/nonebot_hk_reporter/scheduler.py b/src/plugins/nonebot_hk_reporter/scheduler.py index 0e36534..0267388 100644 --- a/src/plugins/nonebot_hk_reporter/scheduler.py +++ b/src/plugins/nonebot_hk_reporter/scheduler.py @@ -18,6 +18,11 @@ async def bilibili_check(): async def rss_check(): await fetch_and_send('rss') + +@scheduler.scheduled_job('interval', seconds=30) +async def wechat_check(): + await fetch_and_send('wechat') + @scheduler.scheduled_job('interval', seconds=1) async def _(): await do_send_msgs() diff --git a/src/plugins/nonebot_hk_reporter/utils.py b/src/plugins/nonebot_hk_reporter/utils.py index 51bf93e..0e0188f 100644 --- a/src/plugins/nonebot_hk_reporter/utils.py +++ b/src/plugins/nonebot_hk_reporter/utils.py @@ -20,7 +20,7 @@ class Singleton(type): cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) return cls._instances[cls] -supported_target_type = ('weibo', 'bilibili', 'rss') +supported_target_type = ('weibo', 'bilibili', 'rss', 'wechat') if not plugin_config.hk_reporter_use_local and not check_chromium(): os.environ['PYPPETEER_DOWNLOAD_HOST'] = 'http://npm.taobao.org/mirrors'