Commit 583e90ca authored by nanahira's avatar nanahira

migrate koishi v4.8

parent 26a11d8e
import { App } from 'koishi'; import { App } from 'koishi';
import ConsolePlugin from '@koishijs/plugin-console'; import ConsolePlugin from '@koishijs/plugin-console';
import SandboxPlugin from '@koishijs/plugin-sandbox'; import SandboxPlugin from '@koishijs/plugin-sandbox';
import * as DatabasePlugin from '@koishijs/plugin-database-memory';
import CachePlugin from '@koishijs/plugin-cache-lru';
import ExtrasInDev from './extras'; import ExtrasInDev from './extras';
const app = new App({ const app = new App({
...@@ -17,10 +15,6 @@ app.plugin(ConsolePlugin, { ...@@ -17,10 +15,6 @@ app.plugin(ConsolePlugin, {
open: false, open: false,
}); });
// Some services
app.plugin(CachePlugin);
app.plugin(DatabasePlugin);
// Some extras // Some extras
app.plugin(ExtrasInDev); app.plugin(ExtrasInDev);
......
This diff is collapsed.
...@@ -44,18 +44,16 @@ ...@@ -44,18 +44,16 @@
"testEnvironment": "node" "testEnvironment": "node"
}, },
"dependencies": { "dependencies": {
"koishi-target-def": "^1.1.1", "koishi-target-def": "^2.0.0",
"node-schedule": "^2.1.0" "node-schedule": "^2.1.0"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.7.4", "koishi": "^4.8.1",
"koishi-thirdeye": "^10.2.1" "koishi-thirdeye": "^11.0.5"
}, },
"devDependencies": { "devDependencies": {
"@koishijs/plugin-cache-lru": "^1.0.0-rc.0", "@koishijs/plugin-console": "^4.0.1",
"@koishijs/plugin-console": "^3.3.2", "@koishijs/plugin-sandbox": "^2.0.0",
"@koishijs/plugin-database-memory": "^1.3.0",
"@koishijs/plugin-sandbox": "^1.1.3",
"@types/jest": "^27.5.0", "@types/jest": "^27.5.0",
"@types/node": "^17.0.31", "@types/node": "^17.0.31",
"@types/node-schedule": "^1.3.2", "@types/node-schedule": "^1.3.2",
......
// import 'source-map-support/register'; // import 'source-map-support/register';
import { SchedulePluginConfig } from './config'; import { SchedulePluginConfig } from './config';
import { import {
BasePlugin,
CreatePluginFactory, CreatePluginFactory,
Inject, Inject,
InjectLogger, InjectLogger,
StarterPlugin,
} from 'koishi-thirdeye'; } from 'koishi-thirdeye';
import { Logger } from 'koishi'; import { Logger } from 'koishi';
import { Adapter } from 'koishi';
import { Bot } from 'koishi'; import { Bot } from 'koishi';
export * from './config'; export * from './config';
export class BaseSchedulePlugin extends BasePlugin<SchedulePluginConfig> { export class BaseSchedulePlugin extends StarterPlugin(SchedulePluginConfig) {
@InjectLogger() @InjectLogger()
logger: Logger; logger: Logger;
@Inject(true) @Inject(true)
bots: Adapter.BotList; bots: Bot[];
async send() { async send() {
return ''; return '';
...@@ -38,7 +37,7 @@ export class BaseSchedulePlugin extends BasePlugin<SchedulePluginConfig> { ...@@ -38,7 +37,7 @@ export class BaseSchedulePlugin extends BasePlugin<SchedulePluginConfig> {
await Promise.all( await Promise.all(
this.config.targets.map(async (target) => { this.config.targets.map(async (target) => {
try { try {
const bot = this.bots.get(target.bot); const bot = this.bots.find(bot => bot.sid === target.bot);
this.logger.debug(`Sending message from ${target.bot}.`); this.logger.debug(`Sending message from ${target.bot}.`);
const ids = await target.send(this.bots, message); const ids = await target.send(this.bots, message);
this.logger.debug( this.logger.debug(
......
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