From 4dbe29c9c7460be3d9c2f2d7a79e6d5af4442cb3 Mon Sep 17 00:00:00 2001 From: Anillc Date: Thu, 28 Apr 2022 14:59:28 +0800 Subject: [PATCH] feat(echo): add escape option --- docs/plugins/common/echo.md | 1 + plugins/common/echo/src/index.ts | 6 +++++- plugins/common/echo/src/locales/zh.yml | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/plugins/common/echo.md b/docs/plugins/common/echo.md index 312e162db8..c65ccfdc26 100644 --- a/docs/plugins/common/echo.md +++ b/docs/plugins/common/echo.md @@ -12,6 +12,7 @@ sidebarDepth: 2 - `-a, --anonymous` 匿名发送消息 (需要 3 级权限) - `-A, --force-anonymous` 强制匿名发送消息 (需要 3 级权限) - `-e, --escape` 发送转义消息 (需要 3 级权限) + - `-E, --unescape` 发送反转义消息 (需要 3 级权限) - `-u, --user [user]` 发送到用户 (需要 3 级权限) - `-c, --channel [channel]` 发送到频道 (需要 3 级权限) - `-g, --guild [guild]` 指定群组编号 (需要 3 级权限) diff --git a/plugins/common/echo/src/index.ts b/plugins/common/echo/src/index.ts index 28904618d8..cf86ec2e52 100644 --- a/plugins/common/echo/src/index.ts +++ b/plugins/common/echo/src/index.ts @@ -13,15 +13,19 @@ export function apply(ctx: Context) { .option('anonymous', '-a', { authority: 3 }) .option('forceAnonymous', '-A', { authority: 3 }) .option('escape', '-e', { authority: 3 }) + .option('unescape', '-E', { authority: 3 }) .option('user', '-u [user:user]', { authority: 3 }) .option('channel', '-c [channel:channel]', { authority: 3 }) .option('guild', '-g [guild:string]', { authority: 3 }) .action(async ({ options, session }, message) => { if (!message) return session.text('.expect-text') - if (options.escape) { + if (options.unescape) { message = segment.unescape(message) } + if (options.escape) { + message = segment.escape(message) + } if (options.forceAnonymous) { message = segment('anonymous') + message diff --git a/plugins/common/echo/src/locales/zh.yml b/plugins/common/echo/src/locales/zh.yml index 1625dbf075..996b1b8d11 100644 --- a/plugins/common/echo/src/locales/zh.yml +++ b/plugins/common/echo/src/locales/zh.yml @@ -5,6 +5,7 @@ commands: anonymous: 匿名发送消息 forceAnonymous: 强制匿名发送消息 escape: 发送转义消息 + unescape: 发送反转义消息 user: 发送到用户 channel: 发送到频道 guild: 指定群组编号