Skip to content

Commit 1165b57

Browse files
committed
message.pyi
1 parent 71bf59e commit 1165b57

File tree

18 files changed

+980
-776
lines changed

18 files changed

+980
-776
lines changed

pdm.lock

Lines changed: 116 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = [
55
{name = "RF-Tar-Railt", email = "[email protected]"},
66
]
77
dependencies = [
8-
"tarina<0.7,>=0.6.8",
8+
"tarina<0.8.0,>=0.7.1",
99
"nepattern<1.0,>=0.7.7",
1010
"arclet-alconna<2.0,>=1.8.40",
1111
"arclet-alconna-tools>=0.7.10",
@@ -229,6 +229,7 @@ defineConstant = { PYDANTIC_V2 = true }
229229
typeCheckingMode = "basic"
230230
reportShadowedImports = false
231231
disableBytesTypePromotions = true
232+
reportSelfClsParameterName = false
232233

233234
[tool.pdm.scripts]
234235
test = "pytest -v -W ignore ./tests/"

src/nonebot_plugin_alconna/builtins/plugins/lang.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
__plugin_meta__ = PluginMetadata(
88
name="lang",
9-
description="i18n 指令",
9+
description=Lang.nbp_alc_builtin.lang.help.main.cast(),
1010
usage="/lang list/switch [lang]",
1111
type="application",
1212
homepage="https://github.com/nonebot/plugin-alconna/blob/master/src/nonebot_plugin_alconna/builtins/plugins/lang.py",
@@ -20,9 +20,13 @@
2020
cmd = on_alconna(
2121
Alconna(
2222
"lang",
23-
Option("list", Args["name?", str], help_text="查看支持的语言列表"),
24-
Option("switch", Args["locale?", str, Field(completion=lambda: "比如 zh-CN")], help_text="切换语言"),
25-
meta=CommandMeta("i18n配置相关功能", compact=True),
23+
Option("list", Args["name?", str], help_text=Lang.nbp_alc_builtin.lang.help.list.cast()),
24+
Option(
25+
"switch",
26+
Args["locale?", str, Field(completion=lambda: list(lang.locales))],
27+
help_text=Lang.nbp_alc_builtin.lang.help.switch.cast(),
28+
),
29+
meta=CommandMeta(Lang.nbp_alc_builtin.lang.help.main.cast(), compact=True),
2630
),
2731
use_cmd_start=True,
2832
)

src/nonebot_plugin_alconna/i18n/.lang.schema.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,29 @@
189189
"type": "object",
190190
"additionalProperties": false,
191191
"properties": {
192+
"help": {
193+
"title": "Help",
194+
"description": "Scope 'help' of lang item",
195+
"type": "object",
196+
"additionalProperties": false,
197+
"properties": {
198+
"list": {
199+
"title": "list",
200+
"description": "value of lang item type 'list'",
201+
"type": "string"
202+
},
203+
"switch": {
204+
"title": "switch",
205+
"description": "value of lang item type 'switch'",
206+
"type": "string"
207+
},
208+
"main": {
209+
"title": "main",
210+
"description": "value of lang item type 'main'",
211+
"type": "string"
212+
}
213+
}
214+
},
192215
"list": {
193216
"title": "list",
194217
"description": "value of lang item type 'list'",

src/nonebot_plugin_alconna/i18n/.template.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@
7070
{
7171
"subtype": "lang",
7272
"types": [
73+
{
74+
"subtype": "help",
75+
"types": [
76+
"list",
77+
"switch",
78+
"main"
79+
]
80+
},
7381
"list",
7482
"switch",
7583
"locale_missing",

src/nonebot_plugin_alconna/i18n/en-US.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
},
4141
"nbp-alc/builtin": {
4242
"lang": {
43+
"help": {
44+
"list": "View the list of supported languages",
45+
"switch": "Switch languages",
46+
"main": "Related functions for Internationalization"
47+
},
4348
"list": "Following languages are supported:",
4449
"switch": "Switch to '{locale}' successfully.",
4550
"locale_missing": "{:At(user, $event.get_user_id())}Missing locale argument, please input:",

src/nonebot_plugin_alconna/i18n/model.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ class NbpAlc:
5757
test = NbpAlcTest
5858

5959

60+
class NbpAlcBuiltinLangHelp:
61+
list: LangItem = LangItem("nbp-alc/builtin", "lang.help.list")
62+
switch: LangItem = LangItem("nbp-alc/builtin", "lang.help.switch")
63+
main: LangItem = LangItem("nbp-alc/builtin", "lang.help.main")
64+
65+
6066
class NbpAlcBuiltinLang:
67+
help = NbpAlcBuiltinLangHelp
6168
list: LangItem = LangItem("nbp-alc/builtin", "lang.list")
6269
switch: LangItem = LangItem("nbp-alc/builtin", "lang.switch")
6370
locale_missing: LangItem = LangItem("nbp-alc/builtin", "lang.locale_missing")

src/nonebot_plugin_alconna/i18n/zh-CN.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
},
4141
"nbp-alc/builtin": {
4242
"lang": {
43+
"help": {
44+
"list": "查看支持的语言列表",
45+
"switch": "切换语言",
46+
"main": "国际化配置相关功能"
47+
},
4348
"list": "支持的语言列表:",
4449
"switch": "切换语言成功: '{locale}'。",
4550
"locale_missing": "{:At(user, $event.get_user_id())}缺少语言参数,请输入:",

src/nonebot_plugin_alconna/matcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from nonebot.rule import Rule
1414
from nonebot.params import Depends
1515
from tarina import run_always_await
16+
from tarina.tools import annotation
1617
from nonebot.utils import escape_tag
1718
from tarina.lang.model import LangItem
1819
from nonebot.permission import Permission
@@ -34,7 +35,6 @@
3435

3536
from .i18n import Lang
3637
from .config import Config
37-
from .util import annotation
3838
from .model import CompConfig
3939
from .rule import AlconnaRule
4040
from .uniseg.fallback import FallbackStrategy
@@ -694,7 +694,7 @@ def i18n(
694694
pass
695695
else:
696696
extra["$message_id"] = msg_id
697-
msg._handle_i18n(extra)
697+
msg._handle_i18n(extra) # type: ignore
698698
return msg
699699

700700
@classmethod

src/nonebot_plugin_alconna/rule.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ async def handle(
248248
def _checker(_event: Event):
249249
return session_id == _event.get_session_id()
250250

251-
w = waiter(["message"], Matcher, keep_session=True, block=self.comp_config.get("block", False), rule=Rule(_checker))(self._waiter) # type: ignore
251+
assert self._waiter, "Waiter function is not set, please check the initialization of AlconnaRule."
252+
assert waiter, "Waiter plugin is not installed, please install nonebot_plugin_waiter."
253+
w = waiter(["message"], Matcher, keep_session=True, block=self.comp_config.get("block", False), rule=Rule(_checker))(self._waiter)
252254

253255
while interface.available:
254256

0 commit comments

Comments
 (0)