-
Notifications
You must be signed in to change notification settings - Fork 35
Theme功能添加 #400
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
Conversation
✅ Deploy Preview for nonebot-bison ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
679ee7e
to
0a1ac43
Compare
Codecov ReportAttention:
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
from nonebot_bison.post import Post | ||
|
||
|
||
class Ht2iTheme(AbstractTheme): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
真的不打算写一个全称吗
There was a problem hiding this comment.
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(?
eb8d812
to
bb9f825
Compare
def convert_to_qr(data: str) -> str: | ||
"""Convert data to QR code | ||
Args: | ||
data (str): data to be converted | ||
Returns: | ||
bytes: QR code image | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
怎么签名里返回 str,doc 里是 byte
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
坏了 改到ceobe的pr里了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
拿过来还是说等着那边合就行
0dd1831
to
cc97adc
Compare
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]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async def message_process(self, msg_segments: list[MessageSegmentFactory]) -> list[MessageFactory]: | |
async def merge_message_segments(self, msg_segments: list[MessageSegmentFactory]) -> list[MessageFactory]: |
There was a problem hiding this comment.
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里是因为我觉这个流程还算通用
还需要讨论讨论
|
||
@abstractmethod | ||
async def generate_pic_messages(self) -> list[MessageSegmentFactory]: | ||
"Generate MessageFactory list from this instance with `use_pic`" | ||
async def generate(self) -> list[MessageSegmentFactory]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async def generate(self) -> list[MessageSegmentFactory]: | |
async def generate_message_segments(self) -> list[MessageSegmentFactory]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前用 generate
命名是考虑到他是最主要的部分不想名字太长(
在加上有 typing 的话也不需要再在函数名里赘述
theme_module = import_module(f"{__name__}.themes.{theme}") | ||
|
||
if not hasattr(theme_module, "__theme_meta__"): | ||
raise ThemeRegistrationError(f"{theme} has no __theme_meta__") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里可能不应该 raise,一个坏了后面的都不 register 了不然
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确实是期望有问题就不能注册的
cc97adc
to
b0b8bdd
Compare
b0b8bdd
to
b944e8d
Compare
bison_theme_use_browser 这个在 docker 里默认开启吧 |
这个归 #447 管应该 |
001d9f7
to
1819f3c
Compare
9301647
to
48d3a06
Compare
48d3a06
to
ff9d8dc
Compare
* 🔧 添加theme相关配置 * 👷 取消对docker.env.prod的忽略
* ✨ 优化Post类的__str__ * ✅ 补充转发测试
a6dc247
to
17c70a4
Compare
No description provided.