diff --git a/index.js b/index.js index 1ad65df..9ab2605 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ import 'node-telegram-bot-api'; -import App from './dist/App'; +import App from './dist/server/App'; new App("./config.yml"); \ No newline at end of file diff --git a/src/api/PluginController.ts b/src/api/PluginController.ts new file mode 100644 index 0000000..ddb18e8 --- /dev/null +++ b/src/api/PluginController.ts @@ -0,0 +1,28 @@ +import App from "#ibot/App"; +import { PluginApiBridge } from "#ibot/plugin/PluginApiBridge"; + +export class PluginController> { + 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) { + + } +} \ No newline at end of file diff --git a/src/api/plugin.yaml b/src/api/plugin.yaml new file mode 100644 index 0000000..e69de29 diff --git a/src/plugins/EchoController.ts.bak b/src/plugins/EchoController.ts.bak deleted file mode 100644 index 20fd653..0000000 --- a/src/plugins/EchoController.ts.bak +++ /dev/null @@ -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 { - 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); - } - } - } -} \ No newline at end of file diff --git a/src/plugins/StableDiffusionController.ts b/src/plugins/ai-paint/Controller.ts similarity index 98% rename from src/plugins/StableDiffusionController.ts rename to src/plugins/ai-paint/Controller.ts index ebb728d..8757331 100644 --- a/src/plugins/StableDiffusionController.ts +++ b/src/plugins/ai-paint/Controller.ts @@ -1,6 +1,6 @@ -import App from "../App"; -import { CommonReceivedMessage, ImageMessage } from "../message/Message"; -import { MessagePriority, PluginController, PluginEvent } from "../PluginManager"; +import App from "#ibot/App"; +import { CommonReceivedMessage, ImageMessage } from "#ibot/message/Message"; +import { MessagePriority, PluginController, PluginEvent } from "#ibot/PluginManager"; import got from "got/dist/source"; export type QueueData = { diff --git a/src/plugins/DiceController.ts b/src/plugins/dice/Controller.ts similarity index 100% rename from src/plugins/DiceController.ts rename to src/plugins/dice/Controller.ts diff --git a/src/plugins/IsekaiBBSQuicklyPostController.ts b/src/plugins/isekai-bbs-quickly-post/IsekaiBBSQuicklyPostController.ts similarity index 99% rename from src/plugins/IsekaiBBSQuicklyPostController.ts rename to src/plugins/isekai-bbs-quickly-post/IsekaiBBSQuicklyPostController.ts index ad31493..4b0beef 100644 --- a/src/plugins/IsekaiBBSQuicklyPostController.ts +++ b/src/plugins/isekai-bbs-quickly-post/IsekaiBBSQuicklyPostController.ts @@ -1,6 +1,6 @@ import App from "#ibot/App"; 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 { RandomMessage } from "#ibot/utils/RandomMessage"; import { QQForwardingMessage } from "#ibot/robot/adapter/qq/Message"; diff --git a/src/plugins/IsekaiWikiController.ts b/src/plugins/isekai-wiki/Controller.ts similarity index 92% rename from src/plugins/IsekaiWikiController.ts rename to src/plugins/isekai-wiki/Controller.ts index 2da0955..b1e8b99 100644 --- a/src/plugins/IsekaiWikiController.ts +++ b/src/plugins/isekai-wiki/Controller.ts @@ -1,5 +1,5 @@ -import App from "../App"; -import { PluginController, PluginEvent } from "../PluginManager"; +import App from "#ibot/App"; +import { PluginController, PluginEvent } from "#ibot/PluginManager"; import { WikiMisc } from "./wiki/WikiMisc"; const API_ENDPOINT = 'https://www.isekai.cn/api.php'; diff --git a/src/plugins/ChatGPTController.ts b/src/plugins/openai/Controller.ts similarity index 100% rename from src/plugins/ChatGPTController.ts rename to src/plugins/openai/Controller.ts diff --git a/src/plugins/RWKVRolePlayingController.ts b/src/plugins/rwkv-rp/Controller.ts similarity index 98% rename from src/plugins/RWKVRolePlayingController.ts rename to src/plugins/rwkv-rp/Controller.ts index 2cd059b..40eb171 100644 --- a/src/plugins/RWKVRolePlayingController.ts +++ b/src/plugins/rwkv-rp/Controller.ts @@ -1,12 +1,12 @@ -import App from "../App"; -import { CommonReceivedMessage } from "../message/Message"; -import { CommandInputArgs, MessagePriority, PluginController, PluginEvent } from "../PluginManager"; +import App from "#ibot/App"; +import { CommonReceivedMessage } from "#ibot/message/Message"; +import { CommandInputArgs, MessagePriority, PluginController, PluginEvent } from "#ibot/PluginManager"; import { encode as gptEncode } from 'gpt-3-encoder'; import got, { OptionsOfTextResponseBody } from "got/dist/source"; import { HttpsProxyAgent } from 'hpagent'; -import { RandomMessage } from "../utils/RandomMessage"; -import { ItemLimitedList } from "../utils/ItemLimitedList"; -import { ChatIdentity } from "../message/Sender"; +import { RandomMessage } from "#ibot/utils/RandomMessage"; +import { ItemLimitedList } from "#ibot/utils/ItemLimitedList"; +import { ChatIdentity } from "#ibot/message/Sender"; export type CharacterConfig = { api_id: string, diff --git a/src/plugins/SfsettingsController.ts b/src/plugins/sfsettings-wiki/Controller.ts similarity index 92% rename from src/plugins/SfsettingsController.ts rename to src/plugins/sfsettings-wiki/Controller.ts index f4e5666..bc2ab63 100644 --- a/src/plugins/SfsettingsController.ts +++ b/src/plugins/sfsettings-wiki/Controller.ts @@ -1,5 +1,5 @@ -import App from "../App"; -import { PluginController, PluginEvent } from "../PluginManager"; +import App from "#ibot/App"; +import { PluginController, PluginEvent } from "#ibot/PluginManager"; import { WikiMisc } from "./wiki/WikiMisc"; export default class SfsettingsController implements PluginController { diff --git a/src/plugins/SystemController.ts b/src/plugins/system-commands/SystemController.ts similarity index 92% rename from src/plugins/SystemController.ts rename to src/plugins/system-commands/SystemController.ts index 1a6fdf0..37b0663 100644 --- a/src/plugins/SystemController.ts +++ b/src/plugins/system-commands/SystemController.ts @@ -1,6 +1,6 @@ -import App from "../App"; -import { CommonReceivedMessage, CommonSendMessage } from "../message/Message"; -import { PluginController, PluginEvent } from "../PluginManager"; +import App from "#ibot/App"; +import { CommonReceivedMessage, CommonSendMessage } from "#ibot/message/Message"; +import { PluginController, PluginEvent } from "#ibot/PluginManager"; export default class SystemController implements PluginController { public event!: PluginEvent; diff --git a/src/plugins/WebdavFileBackupController.ts b/src/plugins/webdav-file-backup/WebdavFileBackupController.ts similarity index 96% rename from src/plugins/WebdavFileBackupController.ts rename to src/plugins/webdav-file-backup/WebdavFileBackupController.ts index b5e40fb..bf65731 100644 --- a/src/plugins/WebdavFileBackupController.ts +++ b/src/plugins/webdav-file-backup/WebdavFileBackupController.ts @@ -1,11 +1,11 @@ import { AuthType, createClient } from "webdav"; -import App from "../App"; +import App from "#ibot/App"; import { extname } from "path"; -import { AttachmentMessage } from "../message/Message"; -import { CommonReceivedMessage } from "../message/Message"; -import { MessagePriority, PluginController, PluginEvent } from "../PluginManager"; +import { AttachmentMessage } from "#ibot/message/Message"; +import { CommonReceivedMessage } from "#ibot/message/Message"; +import { MessagePriority, PluginController, PluginEvent } from "#ibot/PluginManager"; import got from "got/dist/source"; -import { RandomMessage } from "../utils/RandomMessage"; +import { RandomMessage } from "#ibot/utils/RandomMessage"; export type WebdavConfig = { url: string, diff --git a/src/plugins/wiki/WikiMisc.ts b/src/plugins/wiki-misc/WikiMisc.ts similarity index 100% rename from src/plugins/wiki/WikiMisc.ts rename to src/plugins/wiki-misc/WikiMisc.ts diff --git a/src/server/plugin/PluginApiBridge.ts b/src/server/plugin/PluginApiBridge.ts new file mode 100644 index 0000000..47e5e95 --- /dev/null +++ b/src/server/plugin/PluginApiBridge.ts @@ -0,0 +1,9 @@ +import App from "#ibot/App"; + +export class PluginApiBridge { + private app!: App; + + constructor(app: App) { + this.app = app; + } +} \ No newline at end of file