57 lines
1.2 KiB
PHP
Raw Normal View History

2020-03-02 16:14:20 +08:00
<?php
namespace Module\Example;
use Framework\Console;
use ZM\Annotation\CQ\CQCommand;
2020-03-08 16:40:04 +08:00
use ZM\Annotation\Http\Controller;
use ZM\Annotation\Http\RequestMapping;
2020-03-02 16:14:20 +08:00
use ZM\Annotation\Swoole\SwooleEventAt;
use ZM\Connection\CQConnection;
use ZM\ModBase;
/**
* Class Hello
* @package Module\Example
2020-03-08 16:40:04 +08:00
* @Controller("/view")
2020-03-02 16:14:20 +08:00
*/
class Hello extends ModBase
{
/**
* @SwooleEventAt("open",rule="connectType:qq")
* @param $conn
*/
public function onConnect(CQConnection $conn){
Console::info("机器人 ".$conn->getQQ()." 已连接!");
}
/**
* @CQCommand("你好")
*/
public function hello(){
return "你好啊,我是由炸毛框架构建的机器人!";
}
2020-03-08 16:40:04 +08:00
/**
* @RequestMapping("/test/{ping}")
*/
public function ping($param){
return "You input id is: ".$param["ping"];
}
/**
* @RequestMapping("/test/pong")
*/
public function pong(){
$this->response->end("ping");
}
2020-03-08 17:05:12 +08:00
/**
* @SwooleEventAt(type="open",rule="connectType:unknown")
*/
public function closeUnknownConn(){
Console::info("Unknown connection , I will close it.");
$this->connection->close();
}
2020-03-02 16:14:20 +08:00
}