Commit 7c15bbba authored by nanahira's avatar nanahira

move to onapply

parent b0fcfccf
......@@ -26,7 +26,9 @@ declare module 'koishi' {
}
@KoishiPlugin({ name: 'picsource-heisi', schema: PicsourceHeisiConfig })
export default class PicsourceHeisi extends PicSource implements OnConnect {
export default class PicsourceHeisi
extends PicSource
implements OnApply, OnConnect {
constructor(ctx: Context, config: PicsourceHeisiConfigLike) {
super(ctx);
}
......@@ -45,14 +47,17 @@ export default class PicsourceHeisi extends PicSource implements OnConnect {
@InjectLogger()
private logger: Logger;
async onConnect() {
onApply() {
this.logger.info(`Initializing pic source ${this.config.name}...`);
this.config.applyTo(this);
this.cache.table('heisiList', { maxAge: this.config.ttl });
await this.getRandomUrl();
this.pics.addSource(this, this.ctx);
}
async onConnect() {
await this.getRandomUrl();
}
async randomPic() {
const url = await this.getRandomUrl();
if (!url) return;
......
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