Skip to content

Commit 23eb08f

Browse files
committed
🐛 fix telegram entity type
resolve #115
1 parent 42f4e03 commit 23eb08f

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
stages: [pre-commit]
2020

2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.9.9
22+
rev: v0.12.7
2323
hooks:
2424
- id: ruff
2525
args: [--fix, --exit-non-zero-on-fix]

src/nonebot_plugin_alconna/matcher.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ class AlconnaMatcherMeta(MatcherMeta):
113113

114114
def __repr__(self) -> str:
115115
return (
116-
f"{self.__class__.__name__}(type={self.type!r}"
117-
+ f", command={escape_tag(self._command_path)}"
116+
f"{self.__class__.__name__}(type={self.type!r}, command={escape_tag(self._command_path)}"
118117
+ (f", module={self.module_name}" if self.module_name else "")
119118
+ (f", lineno={self._source.lineno}" if self._source and self._source.lineno is not None else "")
120119
+ ")"
@@ -141,8 +140,7 @@ def clean(cls) -> None:
141140

142141
def __repr__(self) -> str:
143142
return (
144-
f"{self.__class__.__name__}(type={self.type!r}"
145-
+ f", command={escape_tag(self._command_path)}"
143+
f"{self.__class__.__name__}(type={self.type!r}, command={escape_tag(self._command_path)}"
146144
+ (f", module={self.module_name}" if self.module_name else "")
147145
+ (f", lineno={self._source.lineno}" if self._source and self._source.lineno is not None else "")
148146
+ ")"

src/nonebot_plugin_alconna/uniseg/adapters/telegram/exporter.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,22 @@
4848
"strikethrough": "strikethrough",
4949
"spl": "spoiler",
5050
"spoiler": "spoiler",
51-
"blockquote": "spoiler",
5251
"code": "code",
52+
"pre": "pre",
53+
"mention": "mention",
54+
"hashtag": "hashtag",
55+
"cashtag": "cashtag",
56+
"bot_command": "bot_command",
57+
"url": "url",
58+
"link": "url",
59+
"email": "email",
60+
"phone_number": "phone_number",
61+
"expandable_blockquote": "expandable_blockquote",
62+
"blockquote": "blockquote",
63+
"text_link": "text_link",
64+
"text_mention": "text_mention",
65+
"emoji": "emoji",
66+
"custom_emoji": "custom_emoji",
5367
}
5468

5569

@@ -88,7 +102,7 @@ async def text(self, seg: Text, bot: Union[Bot, None]):
88102
res = []
89103
for part in seg.style_split():
90104
style = part.extract_most_style()
91-
res.append(Entity(STYLE_TYPE_MAP.get(style, style), {"text": part.text}))
105+
res.append(Entity(STYLE_TYPE_MAP.get(style, "text"), {"text": part.text}))
92106
return res
93107

94108
@export

0 commit comments

Comments
 (0)