mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-09 18:27:56 +08:00
🐛 处理topic_info字段缺失的问题 (#354)
* 🐛 处理topic_info字段缺失的问题 * ✅ 补充测试 * ♻️ dict get 默认为 None Co-authored-by: felinae98 <731499577@qq.com> * ♻️ 原地tp? Co-authored-by: felinae98 <731499577@qq.com> --------- Co-authored-by: felinae98 <731499577@qq.com>
This commit is contained in:
@@ -123,7 +123,11 @@ class Bilibili(NewMessage):
|
||||
return self._do_get_category(post_type)
|
||||
|
||||
def get_tags(self, raw_post: RawPost) -> list[Tag]:
|
||||
return [*(tp["topic_name"] for tp in raw_post["display"]["topic_info"]["topic_details"])]
|
||||
# FIXME: 更深的原因可能是返回格式的变动,需要进一步确认
|
||||
if topic_info := raw_post["display"].get("topic_info"):
|
||||
return [tp["topic_name"] for tp in topic_info["topic_details"]]
|
||||
|
||||
return []
|
||||
|
||||
def _text_process(self, dynamic: str, desc: str, title: str) -> str:
|
||||
similarity = 1.0 if len(dynamic) == 0 or len(desc) == 0 else text_similarity(dynamic, desc)
|
||||
|
||||
Reference in New Issue
Block a user