Skip to content

Commit

Permalink
add record support
Browse files Browse the repository at this point in the history
  • Loading branch information
XieXiLin2 committed Jan 19, 2024
1 parent 695929c commit 0046a50
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 80 deletions.
10 changes: 10 additions & 0 deletions nonebot_plugin_multincm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
KEY_RESOLVE = "resolve"
KEY_SEND_LINK = "send_link"
KEY_UPLOAD_FILE = "upload_file"
KEY_SEND_RECORD = "send_record"
KEY_IS_AUTO_RESOLVE = "is_auto_resolve"
KEY_ILLEGAL_COUNT = "illegal_count"

Expand Down Expand Up @@ -501,6 +502,11 @@ def reg_one(s: Type[BaseSearcher]):
aliases={"upload"},
state={KEY_UPLOAD_FILE: True},
)
cmd_send_record = on_command(
"发送语音",
aliases={"record"},
state={KEY_SEND_RECORD: True},
)
cmd_auto_resolve = on_regex(
URL_REGEX,
state={KEY_RESOLVE: True, KEY_IS_AUTO_RESOLVE: True},
Expand All @@ -514,6 +520,7 @@ def reg_one(s: Type[BaseSearcher]):
@cmd_resolve.handle()
@cmd_resolve_url.handle()
@cmd_resolve_file.handle()
@cmd_send_record.handle()
@cmd_auto_resolve.handle()
@cmd_auto_resolve_short.handle()
async def _(matcher: Matcher, state: T_State, resolved: ResolvedSongOrPlaylist):
Expand Down Expand Up @@ -546,6 +553,9 @@ async def _(matcher: Matcher, state: T_State, resolved: ResolvedSongOrPlaylist):
)
await matcher.finish(f"上传{resolved.calling}失败,遇到未知错误,请检查后台输出")

elif KEY_SEND_RECORD in state:
await matcher.send(MessageSegment.record(await resolved.get_playable_url()))

await matcher.finish()


Expand Down
84 changes: 4 additions & 80 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0046a50

Please sign in to comment.