mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 15:45:36 +08:00
update to build 389
add various global functions
This commit is contained in:
@@ -1,6 +1,18 @@
|
||||
# 更新日志(v2 版本)
|
||||
|
||||
## 2.3.0
|
||||
## v2.3.2
|
||||
|
||||
> 更新时间:2021.3.18
|
||||
|
||||
- 新增:全局方法(`zm_dump()`,`zm_error()`,`zm_warning()`,`zm_info()`,`zm_success()`,`zm_verbose()`,`zm_debug()`,`zm_config()`,)
|
||||
|
||||
## v2.3.1
|
||||
|
||||
> 更新时间:2021.3.18
|
||||
|
||||
- 规范代码,修复一个小报错的 bug
|
||||
|
||||
## v2.3.0
|
||||
|
||||
> 更新时间:2021.3.16
|
||||
|
||||
@@ -14,7 +26,7 @@
|
||||
|
||||
注:本次升级建议升级后合并全局配置文件,有一些新加的内容。
|
||||
|
||||
## 2.2.11
|
||||
## v2.2.11
|
||||
|
||||
> 更新时间:2021.3.13
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ use ZM\Utils\DataProvider;
|
||||
|
||||
class ConsoleApplication extends Application
|
||||
{
|
||||
const VERSION_ID = 388;
|
||||
const VERSION = "2.3.1";
|
||||
const VERSION_ID = 389;
|
||||
const VERSION = "2.3.2";
|
||||
|
||||
public function __construct(string $name = 'UNKNOWN') {
|
||||
define("ZM_VERSION_ID", self::VERSION_ID);
|
||||
|
||||
@@ -304,6 +304,7 @@ class Framework
|
||||
}
|
||||
}
|
||||
if ($coroutine_mode) Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL);
|
||||
else Runtime::enableCoroutine(false, SWOOLE_HOOK_ALL);
|
||||
}
|
||||
|
||||
private static function writeNoDouble($k, $v, &$line_data, &$line_width, &$current_line, $colorful, $max_border) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use Swoole\Atomic;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\WebSocket\Server;
|
||||
use Symfony\Component\VarDumper\VarDumper;
|
||||
use ZM\API\ZMRobot;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\ConnectionManager\ManagerGM;
|
||||
@@ -243,8 +244,6 @@ function ctx(): ?ContextInterface {
|
||||
}
|
||||
}
|
||||
|
||||
function zm_debug($msg) { Console::debug($msg); }
|
||||
|
||||
function onebot_target_id_name($message_type): string {
|
||||
return ($message_type == "group" ? "group_id" : "user_id");
|
||||
}
|
||||
@@ -255,13 +254,21 @@ function zm_sleep($s = 1): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
function zm_exec($cmd): array { return System::exec($cmd); }
|
||||
function zm_exec($cmd): array {
|
||||
return System::exec($cmd);
|
||||
}
|
||||
|
||||
function zm_cid() { return Co::getCid(); }
|
||||
function zm_cid() {
|
||||
return Co::getCid();
|
||||
}
|
||||
|
||||
function zm_yield() { Co::yield(); }
|
||||
function zm_yield() {
|
||||
Co::yield();
|
||||
}
|
||||
|
||||
function zm_resume(int $cid) { Co::resume($cid); }
|
||||
function zm_resume(int $cid) {
|
||||
Co::resume($cid);
|
||||
}
|
||||
|
||||
function zm_timer_after($ms, callable $callable) {
|
||||
Swoole\Timer::after($ms, function () use ($callable) {
|
||||
@@ -287,10 +294,14 @@ function zm_timer_tick($ms, callable $callable) {
|
||||
if (zm_cid() === -1) {
|
||||
return go(function () use ($ms, $callable) {
|
||||
Console::debug("Adding extra timer tick of " . $ms . " ms");
|
||||
Swoole\Timer::tick($ms, function () use ($callable) {call_with_catch($callable);});
|
||||
Swoole\Timer::tick($ms, function () use ($callable) {
|
||||
call_with_catch($callable);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return Swoole\Timer::tick($ms, function () use ($callable) {call_with_catch($callable);});
|
||||
return Swoole\Timer::tick($ms, function () use ($callable) {
|
||||
call_with_catch($callable);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,3 +365,32 @@ function working_dir() {
|
||||
elseif (LOAD_MODE == 2) return realpath('.');
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @noinspection PhpMissingReturnTypeInspection */
|
||||
function zm_dump($var, ...$moreVars) {
|
||||
VarDumper::dump($var);
|
||||
|
||||
foreach ($moreVars as $v) {
|
||||
VarDumper::dump($v);
|
||||
}
|
||||
|
||||
if (1 < func_num_args()) {
|
||||
return func_get_args();
|
||||
}
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
function zm_info($obj) { Console::info($obj); }
|
||||
|
||||
function zm_warning($obj) { Console::warning($obj); }
|
||||
|
||||
function zm_success($obj) { Console::success($obj); }
|
||||
|
||||
function zm_debug($obj) { Console::debug($obj); }
|
||||
|
||||
function zm_verbose($obj) { Console::verbose($obj); }
|
||||
|
||||
function zm_error($obj) { Console::error($obj); }
|
||||
|
||||
function zm_config($name, $key = null) { return ZMConfig::get($name, $key); }
|
||||
|
||||
Reference in New Issue
Block a user