add state and ctrl+C support for windows

This commit is contained in:
crazywhalecc
2022-09-26 22:44:41 +08:00
parent cf3f09600b
commit a4f992b9e5
14 changed files with 143 additions and 108 deletions

View File

@@ -2,21 +2,23 @@
declare(strict_types=1);
$plugin = new \ZM\Plugin\InstantPlugin(__DIR__);
/*
return function () {
$plugin = new \ZM\Plugin\InstantPlugin(__DIR__);
* 发送 "测试 123",回复 "你好123"
*/
$cmd1 = BotCommand::make('test', '测试')->withArgument('arg1')->on(fn () => '你好,{{arg1}}');
$cmd = \ZM\Annotation\OneBot\BotCommand::make(name: 'test', match: '测试')->withArgument(name: 'arg1')->withMethod(function () {
ctx()->reply('test ok');
});
$event = BotEvent::make(type: 'message')->withMethod(function () {
});
$plugin->addBotEvent($event);
$plugin->addBotCommand($cmd);
/*
* 浏览器访问 http://ip:port/index233返回内容
*/
$route1 = Route::make('/index233')->on(fn () => '<h1>Hello world</h1>');
$plugin->registerEvent(HttpRequestEvent::getName(), function (HttpRequestEvent $event) {
$event->withResponse(\OneBot\Http\HttpFactory::getInstance()->createResponse(503));
});
return $plugin;
};
*/
$plugin->addBotCommand($cmd1);
$plugin->addHttpRoute($route1);
return [
'plugin-name' => 'pasd',
'version' => '1.0.0',
'plugin' => $plugin,
];