Commit d1a62ebb authored by nanahira's avatar nanahira

avoid internal as possible, use string groupId

parent 6a5b5308
Pipeline #6098 passed with stages
in 1 minute and 40 seconds
...@@ -54,10 +54,10 @@ export interface Config { ...@@ -54,10 +54,10 @@ export interface Config {
## 命令 ## 命令
* `act [groupId:number]` 获取公演状态。不带参数获取所有正在公演的群,带参数则获取特定群。 * `act [groupId:string]` 获取公演状态。不带参数获取所有正在公演的群,带参数则获取特定群。
* `act.create <groupId:number> <playbookFilename:string> [...specificCharacters]` 创建公演 * `act.create <groupId:string> <playbookFilename:string> [...specificCharacters]` 创建公演
* `groupId` 目标群。`playbookFilename` 是公演剧本文件,需要在服务器放好。后面的参数可以以 人物名=帐号 的形式指定特定的人物,否则随机分配。 * `groupId` 目标群。`playbookFilename` 是公演剧本文件,需要在服务器放好。后面的参数可以以 人物名=帐号 的形式指定特定的人物,否则随机分配。
* 例: `act.create 11111111 play1 幽幽子=2222222` 在群 11111111 创建一个公演,剧本是 play1,位于 `/path/to/playbookPathPrefix/play1.json`,同时指定人物幽幽子为 2222222 扮演。 * 例: `act.create 11111111 play1 幽幽子=2222222` 在群 11111111 创建一个公演,剧本是 play1,位于 `/path/to/playbookPathPrefix/play1.json`,同时指定人物幽幽子为 2222222 扮演。
* `.delete <groupId:number>` 停止公演。 * `.delete <groupId:string>` 停止公演。
{ {
"name": "koishi-plugin-act", "name": "koishi-plugin-act",
"version": "2.0.1", "version": "2.0.2",
"description": "A plugin playing acts in QQ groups", "description": "A plugin playing acts in QQ groups",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
......
...@@ -16,14 +16,14 @@ export class Show { ...@@ -16,14 +16,14 @@ export class Show {
private step = 0; private step = 0;
private launchTime: Moment; private launchTime: Moment;
constructor( constructor(
public groupId: number, public groupId: string,
private playbook: Playbook, private playbook: Playbook,
private autoChangeName = false, private autoChangeName = false,
) { ) {
for (const character of playbook.characters) { for (const character of playbook.characters) {
character.playFun = async (line, text) => { character.playFun = async (line, text) => {
const bot = this.characterBotMap.get(character.id); const bot = this.characterBotMap.get(character.id);
await bot.internal.sendGroupMsg(this.groupId, text, true); await bot.sendGuildMessage(this.groupId, text);
}; };
} }
} }
...@@ -45,14 +45,13 @@ export class Show { ...@@ -45,14 +45,13 @@ export class Show {
if (bot.adapter.platform !== 'onebot') { if (bot.adapter.platform !== 'onebot') {
continue; continue;
} }
const groups = await bot.internal.getGroupList(); const groups = await bot.getGuildList();
const matchGroup = groups.find((g) => g.group_id === this.groupId); const matchGroup = groups.find((g) => g.guildId === this.groupId);
if (matchGroup) { if (matchGroup) {
availableBots.push(bot); availableBots.push(bot);
botNameMap.set( botNameMap.set(
bot.selfId.toString(), bot.selfId.toString(),
(await bot.internal.getGroupMemberInfo(this.groupId, bot.selfId)) (await bot.getGuildMember(this.groupId, bot.selfId)).nickname,
.nickname,
); );
} }
} }
......
...@@ -37,7 +37,7 @@ export class MyPlugin { ...@@ -37,7 +37,7 @@ export class MyPlugin {
config: Config; config: Config;
ctx: Context; ctx: Context;
adminCtx: Context; adminCtx: Context;
shows = new Map<number, Show>(); shows = new Map<string, Show>();
name = 'act-main'; name = 'act-main';
schema: Schema<Config> = Schema.object({ schema: Schema<Config> = Schema.object({
...@@ -60,7 +60,7 @@ export class MyPlugin { ...@@ -60,7 +60,7 @@ export class MyPlugin {
} }
this.adminCtx = this.ctx.select(this.config.adminContext); this.adminCtx = this.ctx.select(this.config.adminContext);
const showComamnd = this.adminCtx const showComamnd = this.adminCtx
.command('act [groupId:number]', '获取公演状态') .command('act [groupId:string]', '获取公演状态')
.usage('不带参数获取所有正在公演的群,带参数则获取特定群。') .usage('不带参数获取所有正在公演的群,带参数则获取特定群。')
.action((argv, groupId) => { .action((argv, groupId) => {
if (!groupId) { if (!groupId) {
...@@ -77,7 +77,7 @@ export class MyPlugin { ...@@ -77,7 +77,7 @@ export class MyPlugin {
showComamnd showComamnd
.subcommand( .subcommand(
'.create <groupId:number> <playbookFilename:string> [...specificCharacters]', '.create <groupId:string> <playbookFilename:string> [...specificCharacters]',
'创建公演', '创建公演',
) )
.usage( .usage(
...@@ -100,7 +100,7 @@ export class MyPlugin { ...@@ -100,7 +100,7 @@ export class MyPlugin {
}, },
); );
showComamnd showComamnd
.subcommand('.delete <groupId:number>', '停止') .subcommand('.delete <groupId:string>', '停止')
.usage('groupId 目标群。') .usage('groupId 目标群。')
.example('act.delete 11111111 停止群 11111111 的公演。') .example('act.delete 11111111 停止群 11111111 的公演。')
.action((argv, groupId) => { .action((argv, groupId) => {
...@@ -118,7 +118,7 @@ export class MyPlugin { ...@@ -118,7 +118,7 @@ export class MyPlugin {
async createShow( async createShow(
session: Session, session: Session,
groupId: number, groupId: string,
playbookFilename: string, playbookFilename: string,
specificCharacters: string[] = [], specificCharacters: string[] = [],
) { ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment