koishi-plugin-common
Advanced tools
Comparing version 3.0.0-beta.12 to 3.0.0-beta.13
@@ -19,3 +19,3 @@ "use strict"; | ||
} | ||
await session.$bot.sendGroupMessage(groups.map(g => g.id), message); | ||
await session.$bot.broadcast(groups.map(g => g.id), message); | ||
}); | ||
@@ -22,0 +22,0 @@ } |
@@ -6,19 +6,9 @@ "use strict"; | ||
function apply(ctx) { | ||
ctx.command('echo <message...>', '向多个上下文发送广播', { authority: 2 }) | ||
ctx.command('echo <message...>', '向当前上下文发送消息', { authority: 2 }) | ||
.option('anonymous', '-a 匿名发送消息', { authority: 3 }) | ||
.option('forceAnonymous', '-A 匿名发送消息', { authority: 3 }) | ||
.option('unescape', '-e 发送非转义的消息', { authority: 3 }) | ||
.option('user', '-u <id> 指定信息发送的目标 QQ 号', { type: 'string', authority: 4 }) | ||
.option('group', '-g <id> 指定信息发送的目标群号', { type: 'string', authority: 4 }) | ||
.usage('各 id 之间请使用逗号分隔。') | ||
.action(async ({ options, session }, message) => { | ||
// parse channels | ||
const channels = { | ||
private: options.user ? options.user.split(',').map(Number) : [], | ||
group: options.group ? options.group.split(',').map(Number) : [], | ||
}; | ||
// fallback to current context | ||
if (!channels.private.length && !channels.group.length) { | ||
channels[session.messageType].push(session.messageType === 'private' ? session.userId : session[session.messageType + 'Id']); | ||
} | ||
.action(async ({ options }, message) => { | ||
if (!message) | ||
return '请输入要发送的文本。'; | ||
if (options.unescape) { | ||
@@ -33,7 +23,3 @@ message = koishi_utils_1.CQCode.unescape(message); | ||
} | ||
// send messages | ||
await Promise.all([ | ||
session.$bot.sendPrivateMessage(channels.private, message), | ||
session.$bot.sendGroupMessage(channels.group, message), | ||
]); | ||
return message; | ||
}); | ||
@@ -40,0 +26,0 @@ } |
@@ -67,3 +67,3 @@ "use strict"; | ||
const output = typeof welcome === 'string' ? welcome : await welcome(session); | ||
await session.$bot.sendGroupMessage(session.groupId, output); | ||
await session.$bot.sendGroupMsg(session.groupId, output); | ||
}); | ||
@@ -70,0 +70,0 @@ } |
{ | ||
"name": "koishi-plugin-common", | ||
"description": "Common plugins for Koishi", | ||
"version": "3.0.0-beta.12", | ||
"version": "3.0.0-beta.13", | ||
"main": "dist/index.js", | ||
@@ -34,10 +34,10 @@ "typings": "dist/index.d.ts", | ||
"peerDependencies": { | ||
"koishi-core": "^2.0.0-rc.1" | ||
"koishi-core": "^2.0.0-rc.2" | ||
}, | ||
"devDependencies": { | ||
"koishi-test-utils": "^4.0.0-beta.7" | ||
"koishi-test-utils": "^4.0.0-beta.8" | ||
}, | ||
"dependencies": { | ||
"koishi-utils": "^3.0.2" | ||
"koishi-utils": "^3.0.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
58689
765
Updatedkoishi-utils@^3.0.3