Commit 81c847a2 authored by nanahira's avatar nanahira

bump

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