Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme功能添加 #400

Merged
merged 4 commits into from
Feb 16, 2024
Merged

Theme功能添加 #400

merged 4 commits into from
Feb 16, 2024

Conversation

AzideCupric
Copy link
Collaborator

No description provided.

@netlify
Copy link

netlify bot commented Oct 13, 2023

Deploy Preview for nonebot-bison ready!

Name Link
🔨 Latest commit 17c70a4
🔍 Latest deploy log https://app.netlify.com/sites/nonebot-bison/deploys/65ccf4a79620ae00086d22a4
😎 Deploy Preview https://deploy-preview-400--nonebot-bison.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@codecov
Copy link

codecov bot commented Oct 15, 2023

Codecov Report

Attention: 112 lines in your changes are missing coverage. Please review.

Comparison is base (f6ee4a4) 82.53% compared to head (b944e8d) 82.17%.
Report is 12 commits behind head on main.

❗ Current head b944e8d differs from pull request most recent head 17c70a4. Consider uploading reports for the commit 17c70a4 to get more accurate results

Files Patch % Lines
nonebot_bison/theme/themes/ceobe_canteen/build.py 43.75% 36 Missing ⚠️
nonebot_bison/post/abstract_post.py 42.85% 16 Missing ⚠️
nonebot_bison/utils/image.py 82.35% 15 Missing ⚠️
nonebot_bison/post/post.py 86.20% 8 Missing ⚠️
nonebot_bison/theme/themes/ht2i/build.py 73.33% 8 Missing ⚠️
nonebot_bison/theme/types.py 84.78% 7 Missing ⚠️
nonebot_bison/platform/arknights.py 88.67% 6 Missing ⚠️
nonebot_bison/theme/themes/arknights/build.py 83.33% 6 Missing ⚠️
nonebot_bison/theme/utils.py 50.00% 4 Missing ⚠️
nonebot_bison/theme/__init__.py 87.50% 2 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #400      +/-   ##
==========================================
- Coverage   82.53%   82.17%   -0.37%     
==========================================
  Files          64       78      +14     
  Lines        3246     3545     +299     
==========================================
+ Hits         2679     2913     +234     
- Misses        567      632      +65     
Flag Coverage Δ
smoke-test 82.17% <78.86%> (-0.37%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

nonebot_bison/plugin_config.py Outdated Show resolved Hide resolved
nonebot_bison/post/abstract_post.py Outdated Show resolved Hide resolved
nonebot_bison/theme/themes/arknights/parse.py Outdated Show resolved Hide resolved
from nonebot_bison.post import Post


class Ht2iTheme(AbstractTheme):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

真的不打算写一个全称吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

html-render-text-to-image(?

nonebot_bison/post/abstract_post.py Outdated Show resolved Hide resolved
nonebot_bison/utils/__init__.py Outdated Show resolved Hide resolved
@AzideCupric AzideCupric force-pushed the feat/color-sharp branch 2 times, most recently from eb8d812 to bb9f825 Compare November 5, 2023 15:44
@felinae98 felinae98 requested a review from he0119 November 8, 2023 12:37
Comment on lines +6 to +12
def convert_to_qr(data: str) -> str:
"""Convert data to QR code
Args:
data (str): data to be converted
Returns:
bytes: QR code image
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

怎么签名里返回 str,doc 里是 byte

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

坏了 改到ceobe的pr里了

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

拿过来还是说等着那边合就行

msgs = [reduce(lambda x, y: x.append(y), msg_segments, MessageFactory([]))]
else:
msgs = [MessageFactory([msg_segment]) for msg_segment in msg_segments]
async def message_process(self, msg_segments: list[MessageSegmentFactory]) -> list[MessageFactory]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async def message_process(self, msg_segments: list[MessageSegmentFactory]) -> list[MessageFactory]:
async def merge_message_segments(self, msg_segments: list[MessageSegmentFactory]) -> list[MessageFactory]:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数的命名原本是考虑作为一个 list[MessageFactory] 生成和处理函数,合并message segment只是它其中的一个功能(取名的时候是考虑给子类留个口子)
不过现在看的话 message_process 想和 message_segments_process 对应的话应该是一个 list[MessageFactory] -> list[MessageFactory] 这样的函数
所以generate_messages应该是

msg_segments = await self.generate()
msg_segments = await self.message_segments_process(msg_segments)
msgs = await self.merge_message_segments(msg_segments)
msgs = await self.message_process(msg_segments)
return msgs

这样的?
然后这四个函数的具体实现应该放到具体子类里?(不过留在Abstract里是因为我觉这个流程还算通用
还需要讨论讨论

nonebot_bison/post/post.py Outdated Show resolved Hide resolved
nonebot_bison/post/abstract_post.py Show resolved Hide resolved

@abstractmethod
async def generate_pic_messages(self) -> list[MessageSegmentFactory]:
"Generate MessageFactory list from this instance with `use_pic`"
async def generate(self) -> list[MessageSegmentFactory]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async def generate(self) -> list[MessageSegmentFactory]:
async def generate_message_segments(self) -> list[MessageSegmentFactory]:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前用 generate 命名是考虑到他是最主要的部分不想名字太长(
在加上有 typing 的话也不需要再在函数名里赘述

nonebot_bison/utils/image.py Outdated Show resolved Hide resolved
nonebot_bison/post/abstract_post.py Outdated Show resolved Hide resolved
nonebot_bison/post/post.py Outdated Show resolved Hide resolved
nonebot_bison/post/post.py Outdated Show resolved Hide resolved
theme_module = import_module(f"{__name__}.themes.{theme}")

if not hasattr(theme_module, "__theme_meta__"):
raise ThemeRegistrationError(f"{theme} has no __theme_meta__")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可能不应该 raise,一个坏了后面的都不 register 了不然

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确实是期望有问题就不能注册的

nonebot_bison/plugin_config.py Outdated Show resolved Hide resolved
@felinae98
Copy link
Collaborator

bison_theme_use_browser 这个在 docker 里默认开启吧

@AzideCupric
Copy link
Collaborator Author

bison_theme_use_browser 这个在 docker 里默认开启吧

这个归 #447 管应该

* 🔧 添加theme相关配置

* 👷 取消对docker.env.prod的忽略
* ✨ 优化Post类的__str__

* ✅ 补充转发测试
@felinae98 felinae98 merged commit c8916ba into main Feb 16, 2024
19 checks passed
@felinae98 felinae98 deleted the feat/color-sharp branch February 16, 2024 01:46
@felinae98 felinae98 added the enhancement New feature or request label Feb 26, 2024
@felinae98 felinae98 changed the title ✨ Theme功能添加 Theme功能添加 Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants