update to 1.3.0 version.

This commit is contained in:
whale
2020-05-06 17:26:50 +08:00
parent 086c65af26
commit a1b013ee53
13 changed files with 321 additions and 74 deletions

View File

@@ -11,6 +11,7 @@ use ZM\Annotation\Http\RequestMapping;
use ZM\Annotation\Swoole\SwooleEventAt;
use ZM\Connection\CQConnection;
use ZM\ModBase;
use ZM\Utils\ZMUtil;
/**
* Class Hello
@@ -36,6 +37,30 @@ class Hello extends ModBase
return "你好啊,我是由炸毛框架构建的机器人!";
}
/**
* @CQCommand(".reload")
*/
public function reload() {
context()->reply("reloading...");
ZMUtil::reload();
}
/**
* @CQCommand("随机数")
* @CQCommand(regexMatch="*从*到*的随机数")
* @param $arg
*/
public function randNum($arg) {
// 获取第一个数字类型的参数
$num1 = context()->getArgs($arg, ZM_MATCH_NUMBER, "请输入第一个数字");
// 获取第二个数字类型的参数
$num2 = context()->getArgs($arg, ZM_MATCH_NUMBER, "请输入第二个数字");
$a = min(intval($num1), intval($num2));
$b = max(intval($num1), intval($num2));
// 回复用户结果
context()->reply("随机数是:".mt_rand($a, $b));
}
/**
* 中间件测试的一个示例函数
* @RequestMapping("/httpTimer")
@@ -45,12 +70,21 @@ class Hello extends ModBase
return "This page is used as testing TimerMiddleware! Do not use it in production.";
}
/**
* 默认示例页面
* @RequestMapping("/index")
*/
public function index() {
return "Hello Zhamao!";
}
/**
* 框架会默认关闭未知的WebSocket链接因为这个绑定的事件你可以根据你自己的需求进行修改
* @SwooleEventAt(type="open",rule="connectType:unknown")
*/
public function closeUnknownConn() {
Console::info("Unknown connection , I will close it.");
$this->connection->close();
context()->getConnection()->close();
}
}