Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(echo): add escape option #642

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/plugins/common/echo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 级权限)
Expand Down
6 changes: 5 additions & 1 deletion plugins/common/echo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions plugins/common/echo/src/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ commands:
anonymous: 匿名发送消息
forceAnonymous: 强制匿名发送消息
escape: 发送转义消息
unescape: 发送反转义消息
user: 发送到用户
channel: 发送到频道
guild: 指定群组编号
Expand Down