更新插件文件结构

main
落雨楓 1 year ago
parent 6336a89b7f
commit 4e5852ba4c

@ -1,4 +1,4 @@
import 'node-telegram-bot-api'; import 'node-telegram-bot-api';
import App from './dist/App'; import App from './dist/server/App';
new App("./config.yml"); new App("./config.yml");

@ -0,0 +1,28 @@
import App from "#ibot/App";
import { PluginApiBridge } from "#ibot/plugin/PluginApiBridge";
export class PluginController<ConfigType = Record<string, string>> {
static id?: string;
static pluginName?: string;
static pluginNameMsg?: string;
static description?: string;
static descriptionMsg?: string;
public _app!: App;
private _config!: ConfigType;
constructor(app: App, pluginApi: PluginApiBridge) {
this._app = app;
}
public get app() {
return this._app;
}
public getLoagger() {
}
public getMessage(msgId: string) {
}
}

@ -1,29 +0,0 @@
import { CommonReceivedMessage } from "../message/Message";
import { PluginController, PluginEvent } from "../PluginManager";
export default class EchoController implements PluginController {
public event!: PluginEvent;
public id = 'echo';
public name = '复读机';
public description = '友好地复读消息';
public async initialize(): Promise<void> {
this.event.autoSubscribe = true;
this.event.on("message/focused", this.handleEcho);
}
private async handleEcho(message: CommonReceivedMessage, resolved: CallableFunction) {
if (message.contentText.match(/^说(|| )/)) {
resolved();
let repliedMessage = message.contentText.replace(/^说(|| )/, "");
if (repliedMessage.match(/我/g)) {
message.sendReply("您说" + repliedMessage.replace(/我/g, "您"), true);
} else {
message.sendReply(repliedMessage, true);
}
}
}
}

@ -1,6 +1,6 @@
import App from "../App"; import App from "#ibot/App";
import { CommonReceivedMessage, ImageMessage } from "../message/Message"; import { CommonReceivedMessage, ImageMessage } from "#ibot/message/Message";
import { MessagePriority, PluginController, PluginEvent } from "../PluginManager"; import { MessagePriority, PluginController, PluginEvent } from "#ibot/PluginManager";
import got from "got/dist/source"; import got from "got/dist/source";
export type QueueData = { export type QueueData = {

@ -1,6 +1,6 @@
import App from "#ibot/App"; import App from "#ibot/App";
import { AddReplyMode, CommonReceivedMessage } from "#ibot/message/Message"; import { AddReplyMode, CommonReceivedMessage } from "#ibot/message/Message";
import { CommandInputArgs, MessagePriority, PluginController, PluginEvent } from "../PluginManager"; import { CommandInputArgs, MessagePriority, PluginController, PluginEvent } from "#ibot/PluginManager";
import got from "got/dist/source"; import got from "got/dist/source";
import { RandomMessage } from "#ibot/utils/RandomMessage"; import { RandomMessage } from "#ibot/utils/RandomMessage";
import { QQForwardingMessage } from "#ibot/robot/adapter/qq/Message"; import { QQForwardingMessage } from "#ibot/robot/adapter/qq/Message";

@ -1,5 +1,5 @@
import App from "../App"; import App from "#ibot/App";
import { PluginController, PluginEvent } from "../PluginManager"; import { PluginController, PluginEvent } from "#ibot/PluginManager";
import { WikiMisc } from "./wiki/WikiMisc"; import { WikiMisc } from "./wiki/WikiMisc";
const API_ENDPOINT = 'https://www.isekai.cn/api.php'; const API_ENDPOINT = 'https://www.isekai.cn/api.php';

@ -1,12 +1,12 @@
import App from "../App"; import App from "#ibot/App";
import { CommonReceivedMessage } from "../message/Message"; import { CommonReceivedMessage } from "#ibot/message/Message";
import { CommandInputArgs, MessagePriority, PluginController, PluginEvent } from "../PluginManager"; import { CommandInputArgs, MessagePriority, PluginController, PluginEvent } from "#ibot/PluginManager";
import { encode as gptEncode } from 'gpt-3-encoder'; import { encode as gptEncode } from 'gpt-3-encoder';
import got, { OptionsOfTextResponseBody } from "got/dist/source"; import got, { OptionsOfTextResponseBody } from "got/dist/source";
import { HttpsProxyAgent } from 'hpagent'; import { HttpsProxyAgent } from 'hpagent';
import { RandomMessage } from "../utils/RandomMessage"; import { RandomMessage } from "#ibot/utils/RandomMessage";
import { ItemLimitedList } from "../utils/ItemLimitedList"; import { ItemLimitedList } from "#ibot/utils/ItemLimitedList";
import { ChatIdentity } from "../message/Sender"; import { ChatIdentity } from "#ibot/message/Sender";
export type CharacterConfig = { export type CharacterConfig = {
api_id: string, api_id: string,

@ -1,5 +1,5 @@
import App from "../App"; import App from "#ibot/App";
import { PluginController, PluginEvent } from "../PluginManager"; import { PluginController, PluginEvent } from "#ibot/PluginManager";
import { WikiMisc } from "./wiki/WikiMisc"; import { WikiMisc } from "./wiki/WikiMisc";
export default class SfsettingsController implements PluginController { export default class SfsettingsController implements PluginController {

@ -1,6 +1,6 @@
import App from "../App"; import App from "#ibot/App";
import { CommonReceivedMessage, CommonSendMessage } from "../message/Message"; import { CommonReceivedMessage, CommonSendMessage } from "#ibot/message/Message";
import { PluginController, PluginEvent } from "../PluginManager"; import { PluginController, PluginEvent } from "#ibot/PluginManager";
export default class SystemController implements PluginController { export default class SystemController implements PluginController {
public event!: PluginEvent; public event!: PluginEvent;

@ -1,11 +1,11 @@
import { AuthType, createClient } from "webdav"; import { AuthType, createClient } from "webdav";
import App from "../App"; import App from "#ibot/App";
import { extname } from "path"; import { extname } from "path";
import { AttachmentMessage } from "../message/Message"; import { AttachmentMessage } from "#ibot/message/Message";
import { CommonReceivedMessage } from "../message/Message"; import { CommonReceivedMessage } from "#ibot/message/Message";
import { MessagePriority, PluginController, PluginEvent } from "../PluginManager"; import { MessagePriority, PluginController, PluginEvent } from "#ibot/PluginManager";
import got from "got/dist/source"; import got from "got/dist/source";
import { RandomMessage } from "../utils/RandomMessage"; import { RandomMessage } from "#ibot/utils/RandomMessage";
export type WebdavConfig = { export type WebdavConfig = {
url: string, url: string,

@ -0,0 +1,9 @@
import App from "#ibot/App";
export class PluginApiBridge {
private app!: App;
constructor(app: App) {
this.app = app;
}
}
Loading…
Cancel
Save