From 265b4ef7f68c5f09ef87eed026a6a99d27618b00 Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Sun, 2 Aug 2020 11:08:33 +0800 Subject: [Update] Fix Fix can't find keywords in dict --- ATRI/plugins/bilibili.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/ATRI/plugins/bilibili.py b/ATRI/plugins/bilibili.py index 818e6a9..a298784 100644 --- a/ATRI/plugins/bilibili.py +++ b/ATRI/plugins/bilibili.py @@ -1,9 +1,10 @@ +# -*- coding:utf-8 -*- import json import nonebot from orjson import loads from html import unescape -from ATRI.modules import response +from ATRI.modules import response # type: ignore REPORT_FORMAT = """({aid})信息如下: @@ -14,8 +15,7 @@ bid: {bid} 投币: {coin} 转发: {share} 观看链接: {aid_link} -{bid_link} -{img}""" +{bid_link}""" table='fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF' @@ -40,6 +40,15 @@ def enc(x): return ''.join(r) +def check(string, sub_str): + if (string.find(sub_str) == -1): + ch = 0 + return ch + else: + ch = 1 + return ch + + @nonebot.on_natural_language(only_to_me = False) async def fk_tx_app_bilibili(session: nonebot.NLPSession): rich_message = [x for x in session.ctx['message'] if x.get('type') == 'rich'] @@ -49,7 +58,11 @@ async def fk_tx_app_bilibili(session: nonebot.NLPSession): rich_message = rich_message[0]['data'] - if '小程序' or '哔哩哔哩' not in rich_message['title']: + xch = '小程序' + bili = '哔哩哔哩' + if check(rich_message['title'], xch) == 0: + return + if check(rich_message['title'], bili) == 0: return rich_message = rich_message['content'] @@ -67,7 +80,6 @@ async def fk_tx_app_bilibili(session: nonebot.NLPSession): url = f'https://api.imjad.cn/bilibili/v2/?aid={aid}' ad = 'av' + aid - print(ad) dc = json.loads(response.request_api(url)) @@ -85,8 +97,6 @@ async def fk_tx_app_bilibili(session: nonebot.NLPSession): bid_link = dc["data"]["short_link"], aid = ad, - aid_link = f'https://b23.tv/{ad}', - - img = f'[CQ:image,file={pic}]', + aid_link = f'https://b23.tv/{ad}' ) - ) \ No newline at end of file + ) -- cgit v1.2.3