Skip to content

Commit

Permalink
Merge pull request #268 from NekoAria/2.0
Browse files Browse the repository at this point in the history
发布 `v2.5.3`
  • Loading branch information
Quan666 authored Mar 8, 2022
2 parents 110725e + 9fddb39 commit 61ffaad
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ENVIRONMENT=prod
VERSION='v2.5.2'
VERSION='v2.5.3'
4 changes: 2 additions & 2 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ NICKNAME=["elf", "ELF"] # 配置机器人的昵称
COMMAND_START=["","/"] # 配置命令起始字符
COMMAND_SEP=["."] # 配置命令分割字符

RSS_PROXY="127.0.0.1:7890" # 代理地址
RSS_PROXY="" # 代理地址 示例: "127.0.0.1:7890"
RSSHUB="https://rsshub.app" # rsshub订阅地址
RSSHUB_BACKUP=[] # 备用rsshub地址 填写示例 ["https://rsshub.app","https://rsshub.app"] 务必使用双引号!!!
RSSHUB_BACKUP=[] # 备用rsshub地址 示例: ["https://rsshub.app","https://rsshub.app"] 务必使用双引号!!!
DB_CACHE_EXPIRE=30 # 去重数据库的记录清理限定天数
LIMIT=200 # 缓存rss条数

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ELF_RSS"
version = "2.5.2"
version = "2.5.3"
description = "ELF_RSS"
authors = ["Quan666"]
license = "GPL v3"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name="ELF_RSS",
version="2.5.2",
version="2.5.3",
author="Quan666",
author_email="[email protected]",
description="QQ机器人 RSS订阅 插件,订阅源建议选择 RSSHub",
Expand Down
60 changes: 60 additions & 0 deletions src/plugins/ELF_RSS2/RSS/routes/weibo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from nonebot.log import logger
from pyquery import PyQuery as Pq

from ...config import config
from ..rss_class import Rss
from .Parsing import ParsingBase, get_summary, handle_html_tag
from .Parsing.handle_images import handle_img_combo, handle_img_combo_with_content


# 处理正文 处理网页 tag
Expand All @@ -19,3 +21,61 @@ async def handle_summary(
tmp += await handle_html_tag(html=summary_html)

return tmp


# 处理图片
@ParsingBase.append_handler(parsing_type="picture", rex="weibo")
async def handle_picture(
rss: Rss, state: dict, item: dict, item_msg: str, tmp: str, tmp_state: dict
) -> str:

# 判断是否开启了只推送标题
if rss.only_title:
return ""

res = ""
try:
res += await handle_img(
item=item,
img_proxy=rss.img_proxy,
img_num=rss.max_image_number,
)
except Exception as e:
logger.warning(f"{rss.name} 没有正文内容!{e}")

# 判断是否开启了只推送图片
if rss.only_pic:
return f"{res}\n"

return f"{tmp + res}\n"


# 处理图片、视频
async def handle_img(item: dict, img_proxy: bool, img_num: int) -> str:
if item.get("image_content"):
return await handle_img_combo_with_content(
item.get("gif_url"), item.get("image_content")
)
html = Pq(get_summary(item))
# 移除多余图标
html.remove("span.url-icon")
img_str = ""
# 处理图片
doc_img = list(html("img").items())
# 只发送限定数量的图片,防止刷屏
if 0 < img_num < len(doc_img):
img_str += f"\n因启用图片数量限制,目前只有 {img_num} 张图片:"
doc_img = doc_img[:img_num]
for img in doc_img:
url = img.attr("src")
img_str += await handle_img_combo(url, img_proxy)

# 处理视频
doc_video = html("video")
if doc_video:
img_str += "\n视频封面:"
for video in doc_video.items():
url = video.attr("poster")
img_str += await handle_img_combo(url, img_proxy)

return img_str

0 comments on commit 61ffaad

Please sign in to comment.