Skip to content

Commit

Permalink
Merge pull request #227 from SK-415/dev
Browse files Browse the repository at this point in the history
Release v1.4.1.post2
  • Loading branch information
SK-415 authored Aug 30, 2022
2 parents aaefa24 + da5f6de commit deef0df
Show file tree
Hide file tree
Showing 45 changed files with 29 additions and 45 deletions.
18 changes: 9 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Project ignored
*.sqlite3

data
accounts
go-cqhttp
logs
test
_test
tests
migration
playground
data/
accounts/
go-cqhttp/
logs/
test/
_test/
tests/
migration/
playground/

# Editor config
.vscode
Expand Down
6 changes: 3 additions & 3 deletions package.json → docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"vuepress-vite": "^2.0.0-beta.26"
},
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
"dev": "vuepress dev",
"build": "vuepress build"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import click

from .utils import create_env


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ async def dy_sched():
DynamicType.music: "发布了新音频",
}
message = (
f"{name} "
f"{type_msg.get(dynamic.card_type, type_msg[0])}\n"
f"{MessageSegment.image(image)}\n"
f"{url}"
f"{name} {type_msg.get(dynamic.card_type, type_msg[0])}\n"
+ MessageSegment.image(image)
+ f"\n{url}"
)

push_list = await db.get_push_list(uid, "dynamic")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,17 @@ async def get_dynamic_screenshot_mobile(dynamic_id):
# 动态被删除或者进审核了
if page.url == "https://m.bilibili.com/404":
return None
content = await page.content()
# 去掉关注按钮
content = content.replace(
'<div class="dyn-header__right">'
'<div data-pos="follow" class="dyn-header__following">'
'<span class="dyn-header__following__icon"></span>'
'<span class="dyn-header__following__text">关注</span></div></div>',
"",
await page.add_script_tag(
content=
# 去除打开app按钮
"document.getElementsByClassName('launch-app-btn').forEach(v=>v.remove());"
# 去除关注按钮
"document.getElementsByClassName('dyn-header__following').forEach(v=>v.remove());"
# 修复字体与换行问题
"const dyn=document.getElementsByClassName('dyn-card')[0];"
"dyn.style.fontFamily='Noto Sans CJK SC, sans-serif';"
"dyn.style.overflowWrap='break-word'"
)
# 1. 字体问题:.dyn-class里font-family是PingFangSC-Regular,使用行内CSS覆盖掉它
# 2. 换行问题:遇到太长的内容(长单词、某些长链接等)允许强制换行,防止溢出
content = content.replace(
'<div class="dyn-card">',
'<div class="dyn-card" '
'style="font-family: Noto Sans CJK SC, sans-serif; overflow-wrap: break-word;">',
)
# 去掉打开APP的按钮,防止遮挡较长的动态
content = content.replace(
'<div class="launch-app-btn dynamic-float-openapp dynamic-float-btn">'
'<div class="m-dynamic-float-openapp">'
"<span>打开APP,查看更多精彩内容</span></div> <!----></div>",
"",
)
await page.set_content(content)
card = await page.query_selector(".dyn-card")
assert card
clip = await card.bounding_box()
Expand Down
File renamed without changes.
9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "haruka-bot"
version = "1.4.1.post1"
version = "1.4.1.post2"
description = "Push dynamics and live informations from bilibili to QQ. Based on nonebot2."
authors = ["SK-415 <2967923486@qq.com>"]
license = "AGPL-3.0-or-later"
Expand All @@ -9,9 +9,7 @@ homepage = "https://github.com/SK-415/HarukaBot"
repository = "https://github.com/SK-415/HarukaBot/tree/master/src/plugins/haruka_bot"
documentation = "https://github.com/SK-415/HarukaBot#readme"
keywords = ["nonebot", "nonebot2", "qqbot", "bilibili", "bot"]
packages = [
{ include = "haruka_bot", from = "./src/plugins/"}
]
include = ["haruka_bot/web/build/**/*"]

[tool.poetry.scripts]
hb = 'haruka_bot.__main__:main'
Expand All @@ -36,8 +34,7 @@ flake8 = "^5.0.4"
nonebot-plugin-gocqhttp = "^0.5.6"

[tool.nonebot]
plugins = ["nonebot_plugin_gocqhttp"]
plugin_dirs = ["src/plugins"]
plugins = ["haruka_bot", "nonebot_plugin_gocqhttp"]

[[tool.poetry.source]]
name = "tsinghua"
Expand Down

0 comments on commit deef0df

Please sign in to comment.