refactor all base things

This commit is contained in:
crazywhalecc
2022-08-13 17:00:29 +08:00
committed by Jerry Ma
parent 1c801bb205
commit b2c95d96b1
54 changed files with 3009 additions and 383 deletions

39
mybot.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
use OneBot\Driver\Event\Http\HttpRequestEvent;
require 'vendor/autoload.php';
// 创建框架 App
$app = new ZM\InstantApplication();
// 传入自定义配置文件
$app->patchConfig([
'driver' => 'workerman',
]);
// 改变启动所需的参数
$app->patchArgs([
'--private-mode',
]);
// 如果有 Composer 依赖的插件,使用 enablePlugins 进行开启
$app->enablePlugins([
'a',
'b',
'c',
'd',
]);
// BotCommand 事件构造
$cmd = \ZM\Annotation\OneBot\BotCommand::make('test')->withMethod(function () {
ctx()->reply('test ok');
});
$event = \ZM\Annotation\OneBot\BotEvent::make('message')->withMethod(function () {
});
$app->addBotEvent($event);
$app->addBotCommand($cmd);
$app->registerEvent(HttpRequestEvent::getName(), function (HttpRequestEvent $event) {
$event->withResponse(\OneBot\Http\HttpFactory::getInstance()->createResponse(503));
});
$app->run();