nonebot-plugin-latex 0.0.3__py3-none-any.whl → 0.0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,25 +14,23 @@ See the Mulan PSL v2 for more details.
14
14
  """
15
15
 
16
16
  from nonebot import get_plugin_config, get_driver
17
- from nonebot.plugin import PluginMetadata
17
+ from nonebot.plugin import PluginMetadata, inherit_supported_adapters
18
18
 
19
19
  from .config import Config
20
20
  from .converter import _converter, get_converter
21
21
 
22
- __version__ = "0.0.3"
22
+ __version__ = "0.0.3.1"
23
23
 
24
24
  __author__ = "Eilles"
25
25
 
26
26
  __plugin_meta__ = PluginMetadata(
27
- name="LaTeX图形渲染插件",
28
- description="从互联网服务渲染LaTeX公式并发送",
27
+ name="LaTeX 在线渲染插件",
28
+ description="从互联网服务渲染 LaTeX 公式",
29
29
  usage="发送 latex 或 公式,后接内容或回复公式信息。",
30
30
  type="library",
31
31
  homepage="https://github.com/EillesWan/nonebot-plugin-latex",
32
32
  config=Config,
33
- supported_adapters={
34
- "~onebot.v11",
35
- },
33
+ supported_adapters=inherit_supported_adapters("nonebot_plugin_alconna"),
36
34
  extra={"License": "Mulan PSL v2", "Author": __author__},
37
35
  )
38
36
 
@@ -15,17 +15,17 @@ See the Mulan PSL v2 for more details.
15
15
 
16
16
  import nonebot
17
17
 
18
- from nonebot.adapters.onebot.v11 import MessageEvent
18
+ from nonebot_plugin_alconna.uniseg import Text
19
19
 
20
- # from nonebot.matcher import Matcher
21
20
 
22
21
  nonebot.require("nonebot_plugin_alconna")
23
22
 
24
- # from nonebot_plugin_alconna.util import annotation
25
23
  from nonebot_plugin_alconna import (
26
24
  Image as Alconna_Image,
25
+ Reply,
27
26
  Text as Alconnna_Text,
28
27
  UniMessage,
28
+ UniMsg
29
29
  )
30
30
 
31
31
  from .data import LATEX_PATTERN
@@ -47,29 +47,16 @@ command_heads = (
47
47
 
48
48
 
49
49
  async def check_for_scan(
50
- event: MessageEvent,
50
+ msg: UniMsg,
51
51
  # state: T_State,
52
52
  ) -> bool:
53
53
  """
54
54
  检查是否为 LaTeX 指令
55
55
  """
56
-
57
- # print("检查消息满足渲染要求:", event)
58
- if isinstance(event, MessageEvent):
59
- # print("此为原始信息:", event.raw_message)
60
- # event.message
61
- for msg in event.message:
62
- # print("这是其中一个信息---", msg)
63
- if msg.type == "text" and (msgdata := msg.data["text"].strip()):
64
- if msgdata.startswith(command_heads):
65
-
66
- # print("判断:这确实是指令发出")
67
- return True
68
- else:
69
- # print("判断:这不是指令")
70
- return False
71
- return False
72
- return False
56
+ return any(
57
+ isinstance(seg, Text) and seg.text.strip().startswith(command_heads)
58
+ for seg in msg
59
+ )
73
60
 
74
61
 
75
62
  latexg = nonebot.on_message(
@@ -81,18 +68,19 @@ latexg = nonebot.on_message(
81
68
 
82
69
  @latexg.handle()
83
70
  async def handle_pic(
84
- event: MessageEvent,
71
+ msgs: UniMsg,
85
72
  # state: T_State,
86
73
  # arg: Optional[Message] = CommandArg(),
87
74
  ):
88
75
  # print("正在解决reply指令……")
89
76
  latexes = []
90
- if event.reply:
91
- latexes.extend(LATEX_PATTERN.finditer(event.reply.message.extract_plain_text()))
77
+ if msgs.has(Reply):
78
+ i = msgs[Reply, 0]
79
+ if i.msg:
80
+ latexes.extend(LATEX_PATTERN.finditer(i.msg if isinstance(i.msg, str) else i.msg.extract_plain_text()))
92
81
 
93
82
  # print(arg)
94
- if event.message:
95
- latexes.extend(LATEX_PATTERN.finditer(event.message.extract_plain_text()))
83
+ latexes.extend(LATEX_PATTERN.finditer(msgs.extract_plain_text()))
96
84
 
97
85
  if not latexes:
98
86
  await latexg.finish(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nonebot-plugin-latex
3
- Version: 0.0.3
3
+ Version: 0.0.3.1
4
4
  Summary: 通过互联网公共服务渲染LaTeX公式
5
5
  Author-email: Eilles <EillesWan@outlook.com>
6
6
  License: 木兰宽松许可证, 第2版
@@ -136,10 +136,9 @@ Project-URL: Bug Tracker, https://github.com/EillesWan/nonebot-plugin-latex/issu
136
136
  Requires-Python: <4.0,>=3.9
137
137
  Description-Content-Type: text/markdown
138
138
  License-File: LICENSE
139
- Requires-Dist: nonebot2
139
+ Requires-Dist: nonebot2<1000.0.0,>=2.2.0
140
140
  Requires-Dist: httpx<0.28.0,>=0.27.0
141
- Requires-Dist: nonebot-adapter-onebot
142
- Requires-Dist: nonebot-plugin-alconna
141
+ Requires-Dist: nonebot-plugin-alconna<1000.0.0,>=0.48.0
143
142
 
144
143
  # nonebot-plugin-latex
145
144
 
@@ -0,0 +1,10 @@
1
+ nonebot_plugin_latex/__init__.py,sha256=ws3Zv1AF3Iki7hCeCwayBP8yavhQIzgxFq95jFOVsJQ,1520
2
+ nonebot_plugin_latex/config.py,sha256=5WOJF-vsuLqGTDGgklpMm-xLd_qdwVb0VCq-n8EwoJQ,198
3
+ nonebot_plugin_latex/converter.py,sha256=rTyeJoZOhXciLcfZ6FWOe0mHczmd2E_sTrqEbJRZ6d8,194
4
+ nonebot_plugin_latex/data.py,sha256=ygcJClUUM4lNR9PotPC1E0rtrRq1swanPWIBnwAvcWM,11443
5
+ nonebot_plugin_latex/main.py,sha256=iKlkYndPrKi72oXMASmdgPKuT5scEIxtfEuLO7s5OHw,2950
6
+ nonebot_plugin_latex-0.0.3.1.dist-info/LICENSE,sha256=ISc-fUbtRp39lxd4MpdVr2Saz7XF2yik0RTSRNuhlaM,9375
7
+ nonebot_plugin_latex-0.0.3.1.dist-info/METADATA,sha256=GPaXmHHMgzKjL1TSO7u-u1jQ_r7SFBlNauJP2NUk380,11735
8
+ nonebot_plugin_latex-0.0.3.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
9
+ nonebot_plugin_latex-0.0.3.1.dist-info/top_level.txt,sha256=AEtxXrscUdkhTvgg--hAE9WRsW0QVttzK2H-fI9xbGs,21
10
+ nonebot_plugin_latex-0.0.3.1.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- nonebot_plugin_latex/__init__.py,sha256=fIXI5w5E0KYMTqIVYWAMoogjzMHLE9V2wEFzNYUY40A,1476
2
- nonebot_plugin_latex/config.py,sha256=5WOJF-vsuLqGTDGgklpMm-xLd_qdwVb0VCq-n8EwoJQ,198
3
- nonebot_plugin_latex/converter.py,sha256=rTyeJoZOhXciLcfZ6FWOe0mHczmd2E_sTrqEbJRZ6d8,194
4
- nonebot_plugin_latex/data.py,sha256=ygcJClUUM4lNR9PotPC1E0rtrRq1swanPWIBnwAvcWM,11443
5
- nonebot_plugin_latex/main.py,sha256=mMbng0Eo1J3gnztTKbJe_PH63qMgJFZ6Ooj4EY8QKx4,3538
6
- nonebot_plugin_latex-0.0.3.dist-info/LICENSE,sha256=ISc-fUbtRp39lxd4MpdVr2Saz7XF2yik0RTSRNuhlaM,9375
7
- nonebot_plugin_latex-0.0.3.dist-info/METADATA,sha256=OWrGenR2OJ2mSyU-C2-kNAWt4XCaU_YZGEdBfE1QX2k,11737
8
- nonebot_plugin_latex-0.0.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
9
- nonebot_plugin_latex-0.0.3.dist-info/top_level.txt,sha256=AEtxXrscUdkhTvgg--hAE9WRsW0QVttzK2H-fI9xbGs,21
10
- nonebot_plugin_latex-0.0.3.dist-info/RECORD,,