Commit 81c847a2 authored by nanahira's avatar nanahira

bump

parent d0937a9c
......@@ -13,10 +13,11 @@ const app = new Context({
});
// Console and sandbox
app.plugin(SandboxPlugin);
// app.plugin(SandboxPlugin);
app.plugin(ConsolePlugin, {
open: false,
});
app.plugin(SandboxPlugin);
// Some services
// app.plugin(CachePlugin);
......
This diff is collapsed.
......@@ -7,7 +7,7 @@ import {
PutSession,
Selection,
} from 'koishi-thirdeye';
import { Adapter, Bot, Random, Session } from 'koishi';
import { Adapter, Bot, Random, segment, Session } from 'koishi';
import path from 'path';
import * as fs from 'fs';
import moment from 'moment';
......@@ -37,7 +37,7 @@ export class EdgingProfile {
getBot(bots: Bot[]) {
if (this.from) {
return bots.find(bot => bot.sid === this.from);
return bots.find((bot) => bot.sid === this.from);
} else {
return this.session.bot;
}
......@@ -151,6 +151,15 @@ export class EdgingProfile {
this.startTime = moment();
}
private runForEachSegemnt(segments: segment[], action: (s: segment) => void) {
for (const s of segments) {
action(s);
if (s.children?.length) {
this.runForEachSegemnt(s.children, action);
}
}
}
send(content: string) {
const bot = this.bot;
if (
......@@ -158,7 +167,19 @@ export class EdgingProfile {
(bot.platform === 'onebot' ||
(bot.platform === 'qqguild' && bot['parentBot']?.platform === 'onebot'))
) {
content = content.replace(/,url=base64/g, ',file=base64');
const segments = segment.parse(content);
this.runForEachSegemnt(segments, (s) => {
const { attrs } = s;
if (!attrs || s.type !== 'image') {
return;
}
if (attrs.url?.startsWith('base64')) {
const { url } = attrs;
attrs.file = url;
delete attrs.url;
}
});
content = segments.map((s) => s.toString()).join('');
}
return sendPriv(bot, this.getTarget(), content);
}
......
......@@ -173,7 +173,7 @@ export default class EdgingPlugin
if (await this.checkOvertime(profile)) {
return;
}
return profile.send(segment);
return profile.send(segment.toString());
},
'process pic',
profiles,
......
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