Commit 0feb8753 authored by nanahira's avatar nanahira

migrate

parent c627a968
{
"name": "koishi-plugin-act",
"version": "1.0.3",
"version": "2.0.0",
"description": "A plugin playing acts in QQ groups",
"main": "dist/index.js",
"dependencies": {
......
import 'source-map-support/register';
import type { Context } from 'koishi-core';
import type { Context } from 'koishi';
import { Config, MyPlugin } from './plugin';
export { Config } from './plugin';
export const name = 'act-index';
export const name = 'act';
const plugin = new MyPlugin();
export const schema = plugin.schema;
export function apply(ctx: Context, config: Config) {
......
import { Playbook } from './Playbook';
import type { OneBotBot } from '@koishijs/plugin-onebot';
import type { OneBotBot } from '@koishijs/plugin-onebot/lib/bot';
import moment, { Moment } from 'moment';
export enum ShowStatus {
......@@ -23,7 +23,7 @@ export class Show {
for (const character of playbook.characters) {
character.playFun = async (line, text) => {
const bot = this.characterBotMap.get(character.id);
await bot.$sendGroupMsg(this.groupId, text, true);
await bot.internal.sendGroupMsg(this.groupId, text, true);
};
}
}
......@@ -42,16 +42,17 @@ export class Show {
let availableBots: OneBotBot[] = [];
const botNameMap = new Map<string, string>();
for (const bot of bots) {
if (!(bot.type && bot.type.startsWith('onebot'))) {
if (bot.adapter.platform !== 'onebot') {
continue;
}
const groups = await bot.$getGroupList();
const matchGroup = groups.find((g) => g.groupId === this.groupId);
const groups = await bot.internal.getGroupList();
const matchGroup = groups.find((g) => g.group_id === this.groupId);
if (matchGroup) {
availableBots.push(bot);
botNameMap.set(
bot.selfId.toString(),
(await bot.$getGroupMemberInfo(this.groupId, bot.selfId)).nickname,
(await bot.internal.getGroupMemberInfo(this.groupId, bot.selfId))
.nickname,
);
}
}
......@@ -109,7 +110,11 @@ export class Show {
for (const character of this.playbook.characters) {
const bot = this.characterBotMap.get(character.id);
try {
await bot.$setGroupCard(this.groupId, bot.selfId, character.name);
await bot.internal.setGroupCard(
this.groupId,
bot.selfId,
character.name,
);
} catch (e) {
return `Change name for ${bot.selfId} ${
character.name
......
......@@ -5,6 +5,7 @@ import { Playbook } from './playbook/Playbook';
import { plainToClass } from 'class-transformer';
import loadJsonFile from 'load-json-file';
import { MaybeArray } from 'koishi';
import type { OneBotBot } from '@koishijs/plugin-onebot/lib/bot';
const selectors = [
'user',
......@@ -38,7 +39,7 @@ export class MyPlugin {
adminCtx: Context;
shows = new Map<number, Show>();
name = 'act';
name = 'act-main';
schema: Schema<Config> = Schema.object({
adminContext: Schema.any('管理员接口作用域。'),
autoChangeName: Schema.boolean(
......@@ -135,7 +136,7 @@ export class MyPlugin {
return `无法加载剧本文件 ${playbookPath}: ${e.toString()}`;
}
const bots: OneBotBot[] = this.ctx.bots.filter(
(b) => b.type && b.type.startsWith('onebot'),
(b) => b.adapter.platform === 'onebot',
) as OneBotBot[];
const show = new Show(groupId, playbook, this.config.autoChangeName);
for (const specificCharacter of specificCharacters) {
......
......@@ -25,4 +25,8 @@ module.exports = {
},
path: path.resolve(__dirname, "dist"),
},
externals: {
'koishi': 'koishi',
'@koishijs/plugin-onebot/lib/bot': '@koishijs/plugin-onebot/lib/bot',
}
};
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