Commit d2787c1a authored by nanahira's avatar nanahira

update fragment handling

parent 050433dc
import { PromptOptions, Random, Session } from 'koishi'; import {
Fragment,
PromptOptions,
Random,
segment,
SendOptions,
Session,
} from 'koishi';
import ApiBot from './index'; import ApiBot from './index';
import { Prompt } from './def/prompt'; import { Prompt } from './def/prompt';
export class ApiSession extends Session { export class ApiSession extends Session {
storedMessages: string[] = []; storedMessages: string[] = [];
private midResolver: () => void; private midResolver: () => void;
...@@ -39,8 +45,13 @@ export class ApiSession extends Session { ...@@ -39,8 +45,13 @@ export class ApiSession extends Session {
} }
} }
async send(content: string) { async send(content: Fragment, options: SendOptions = {}) {
this.storedMessages.push(content); if (!content) return;
options.session = this;
const children = await this.transform(segment.normalize(content));
this.storedMessages.push(
children.map((child) => child.toString()).join(''),
);
return [Random.id()]; return [Random.id()];
} }
......
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