mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 23:55:35 +08:00
update to 2.0.0-b5 version
set modules config to array add subdir index.html update Example of Hello.php add Exception tester for TimerMiddleware.php add keyword for @CQCommand rename OnWorkerStart.php to OnStart.php remove SwooleEventAfter.php rename HandleEvent.php to SwooleHandler.php set ZMRobot callback mode default to true add getNextArg() and getFullArg() add EventDispatcher.php logger set Exception all based from ZMException fix recursive bug for Response.php add single_bot_mode add SingletonTrait.php add bot() function
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Swoole\Coroutine;
|
||||
use ZM\API\ZMRobot;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\ConnectionManager\ManagerGM;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Context\Context;
|
||||
use ZM\Event\EventManager;
|
||||
use ZM\Exception\RobotNotFoundException;
|
||||
use ZM\Exception\ZMException;
|
||||
use ZM\Framework;
|
||||
use ZM\Store\LightCacheInside;
|
||||
use ZM\Store\ZMBuf;
|
||||
use ZM\Utils\DataProvider;
|
||||
use Swoole\Coroutine\System;
|
||||
use ZM\Context\ContextInterface;
|
||||
use ZM\Utils\ZMUtil;
|
||||
|
||||
|
||||
function phar_classloader($p) {
|
||||
@@ -181,11 +185,11 @@ function getAnnotations() {
|
||||
$s = debug_backtrace()[1];
|
||||
//echo json_encode($s, 128|256);
|
||||
$list = [];
|
||||
foreach(EventManager::$events as $event => $v) {
|
||||
foreach($v as $ks => $vs) {
|
||||
foreach (EventManager::$events as $event => $v) {
|
||||
foreach ($v as $ks => $vs) {
|
||||
//echo get_class($vs).": ".$vs->class." => ".$vs->method.PHP_EOL;
|
||||
if($vs->class == $s["class"] && $vs->method == $s["function"]) {
|
||||
$list[get_class($vs)][]=$vs;
|
||||
if ($vs->class == $s["class"] && $vs->method == $s["function"]) {
|
||||
$list[get_class($vs)][] = $vs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,7 +231,7 @@ function ctx() {
|
||||
}
|
||||
}
|
||||
|
||||
function debug($msg) { Console::debug($msg); }
|
||||
function zm_debug($msg) { Console::debug($msg); }
|
||||
|
||||
function onebot_target_id_name($message_type) {
|
||||
return ($message_type == "group" ? "group_id" : "user_id");
|
||||
@@ -268,6 +272,22 @@ function server() {
|
||||
return Framework::$server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ZMRobot
|
||||
* @throws RobotNotFoundException
|
||||
* @throws ZMException
|
||||
*/
|
||||
function bot() {
|
||||
if (($conn = LightCacheInside::get("connect", "conn_fd")) == -2) {
|
||||
return ZMRobot::getRandom();
|
||||
} elseif ($conn != -1) {
|
||||
if (($obj = ManagerGM::get($conn)) !== null) return new ZMRobot($obj);
|
||||
else throw new RobotNotFoundException("单机器人连接模式可能连接了多个机器人!");
|
||||
} else {
|
||||
throw new RobotNotFoundException("没有任何机器人连接到框架!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user