mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 16:45:35 +08:00
update to 1.5.6 version
add CQCommand filter add ZM_DEFAULT_FETCH_MODE
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
"description": "High performance QQ robot and web server development framework",
|
"description": "High performance QQ robot and web server development framework",
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"version": "1.5.5",
|
"version": "1.5.6",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "whale",
|
"name": "whale",
|
||||||
|
|||||||
@@ -43,11 +43,12 @@ $config['sql_config'] = [
|
|||||||
PDO::ATTR_STRINGIFY_FETCHES => false,
|
PDO::ATTR_STRINGIFY_FETCHES => false,
|
||||||
PDO::ATTR_EMULATE_PREPARES => false
|
PDO::ATTR_EMULATE_PREPARES => false
|
||||||
],
|
],
|
||||||
'sql_no_exception' => false
|
'sql_no_exception' => false,
|
||||||
|
'sql_default_fetch_mode' => PDO::FETCH_BOTH // added in 1.5.6
|
||||||
];
|
];
|
||||||
|
|
||||||
/** CQHTTP连接约定的token */
|
/** CQHTTP连接约定的token */
|
||||||
$config["access_token"] = "";
|
$config["access_token"] = "0ACA097E-AA82-4577-8B17-4A8D454D171B";
|
||||||
|
|
||||||
/** HTTP服务器固定请求头的返回 */
|
/** HTTP服务器固定请求头的返回 */
|
||||||
$config['http_header'] = [
|
$config['http_header'] = [
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ class FrameworkLoader
|
|||||||
define("ZM_MATCH_NUMBER", 2);
|
define("ZM_MATCH_NUMBER", 2);
|
||||||
define("ZM_MATCH_SECOND", 3);
|
define("ZM_MATCH_SECOND", 3);
|
||||||
define("ZM_BREAKPOINT", 'if(in_array("--debug-mode", \Framework\FrameworkLoader::$argv)) extract(\Psy\debug(get_defined_vars(), isset($this) ? $this : @get_called_class()));');
|
define("ZM_BREAKPOINT", 'if(in_array("--debug-mode", \Framework\FrameworkLoader::$argv)) extract(\Psy\debug(get_defined_vars(), isset($this) ? $this : @get_called_class()));');
|
||||||
|
define("ZM_DEFAULT_FETCH_MODE", self::$settings->get("sql_config")["sql_default_fetch_mode"] ?? 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function selfCheck() {
|
private function selfCheck() {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class AnnotationParser
|
|||||||
foreach ($method_annotations as $vss) {
|
foreach ($method_annotations as $vss) {
|
||||||
if ($vss instanceof Rule) $vss = self::registerRuleEvent($vss, $vs, $reflection_class);
|
if ($vss instanceof Rule) $vss = self::registerRuleEvent($vss, $vs, $reflection_class);
|
||||||
else $vss = self::registerMethod($vss, $vs, $reflection_class);
|
else $vss = self::registerMethod($vss, $vs, $reflection_class);
|
||||||
|
Console::debug("寻找 ".$vs->getName() ." -> ".get_class($vss));
|
||||||
if ($vss instanceof SwooleEventAt) ZMBuf::$events[SwooleEventAt::class][] = $vss;
|
if ($vss instanceof SwooleEventAt) ZMBuf::$events[SwooleEventAt::class][] = $vss;
|
||||||
elseif ($vss instanceof SwooleEventAfter) ZMBuf::$events[SwooleEventAfter::class][] = $vss;
|
elseif ($vss instanceof SwooleEventAfter) ZMBuf::$events[SwooleEventAfter::class][] = $vss;
|
||||||
elseif ($vss instanceof CQMessage) ZMBuf::$events[CQMessage::class][] = $vss;
|
elseif ($vss instanceof CQMessage) ZMBuf::$events[CQMessage::class][] = $vss;
|
||||||
@@ -326,6 +326,7 @@ class AnnotationParser
|
|||||||
$class = getAllClasses(DataProvider::getWorkingDir() . "/src/Custom/Annotation/", "Custom\\Annotation");
|
$class = getAllClasses(DataProvider::getWorkingDir() . "/src/Custom/Annotation/", "Custom\\Annotation");
|
||||||
foreach ($class as $v) {
|
foreach ($class as $v) {
|
||||||
$s = DataProvider::getWorkingDir() . '/src/' . str_replace("\\", "/", $v) . ".php";
|
$s = DataProvider::getWorkingDir() . '/src/' . str_replace("\\", "/", $v) . ".php";
|
||||||
|
Console::debug("Requiring custom annotation ".$s);
|
||||||
require_once $s;
|
require_once $s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,14 @@ class CQCommand extends AnnotationBase implements Level
|
|||||||
public $regexMatch = "";
|
public $regexMatch = "";
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
public $alias = [];
|
public $alias = [];
|
||||||
|
/** @var string */
|
||||||
|
public $message_type = "";
|
||||||
|
/** @var int */
|
||||||
|
public $user_id = 0;
|
||||||
|
/** @var int */
|
||||||
|
public $group_id = 0;
|
||||||
|
/** @var int */
|
||||||
|
public $discuss_id = 0;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
public $level = 20;
|
public $level = 20;
|
||||||
|
|
||||||
|
|||||||
@@ -90,10 +90,11 @@ class DB
|
|||||||
/**
|
/**
|
||||||
* @param string $line
|
* @param string $line
|
||||||
* @param array $params
|
* @param array $params
|
||||||
|
* @param int $fetch_mode
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws DbException
|
* @throws DbException
|
||||||
*/
|
*/
|
||||||
public static function rawQuery(string $line, $params = []) {
|
public static function rawQuery(string $line, $params = [], $fetch_mode = ZM_DEFAULT_FETCH_MODE) {
|
||||||
if (ZMBuf::get("sql_log") === true) {
|
if (ZMBuf::get("sql_log") === true) {
|
||||||
$starttime = microtime(true);
|
$starttime = microtime(true);
|
||||||
}
|
}
|
||||||
@@ -131,7 +132,7 @@ class DB
|
|||||||
"] " . $line . " " . json_encode($params, JSON_UNESCAPED_UNICODE) . "\n";
|
"] " . $line . " " . json_encode($params, JSON_UNESCAPED_UNICODE) . "\n";
|
||||||
Coroutine::writeFile(CRASH_DIR . "sql.log", $log, FILE_APPEND);
|
Coroutine::writeFile(CRASH_DIR . "sql.log", $log, FILE_APPEND);
|
||||||
}
|
}
|
||||||
return $ps->fetchAll();
|
return $ps->fetchAll($fetch_mode);
|
||||||
}
|
}
|
||||||
} catch (DbException $e) {
|
} catch (DbException $e) {
|
||||||
if (ZMBuf::get("sql_log") === true) {
|
if (ZMBuf::get("sql_log") === true) {
|
||||||
|
|||||||
@@ -41,10 +41,11 @@ class SelectBody
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param int $fetch_mode
|
||||||
* @return null
|
* @return null
|
||||||
* @throws DbException
|
* @throws DbException
|
||||||
*/
|
*/
|
||||||
public function fetchAll() {
|
public function fetchAll($fetch_mode = ZM_DEFAULT_FETCH_MODE) {
|
||||||
if ($this->table->isCacheEnabled()) {
|
if ($this->table->isCacheEnabled()) {
|
||||||
$rr = md5(implode(",", $this->select_thing) . serialize($this->where_thing));
|
$rr = md5(implode(",", $this->select_thing) . serialize($this->where_thing));
|
||||||
if (array_key_exists($rr, $this->table->cache)) {
|
if (array_key_exists($rr, $this->table->cache)) {
|
||||||
@@ -52,7 +53,7 @@ class SelectBody
|
|||||||
return $this->table->cache[$rr]->getResult();
|
return $this->table->cache[$rr]->getResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->execute();
|
$this->execute($fetch_mode);
|
||||||
if ($this->table->isCacheEnabled() && !in_array($rr, $this->table->cache)) {
|
if ($this->table->isCacheEnabled() && !in_array($rr, $this->table->cache)) {
|
||||||
$this->table->cache[$rr] = $this;
|
$this->table->cache[$rr] = $this;
|
||||||
}
|
}
|
||||||
@@ -81,11 +82,12 @@ class SelectBody
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param int $fetch_mode
|
||||||
* @throws DbException
|
* @throws DbException
|
||||||
*/
|
*/
|
||||||
public function execute() {
|
public function execute($fetch_mode = ZM_DEFAULT_FETCH_MODE) {
|
||||||
$str = $this->queryPrepare();
|
$str = $this->queryPrepare();
|
||||||
$this->result = DB::rawQuery($str[0], $str[1]);
|
$this->result = DB::rawQuery($str[0], $str[1], $fetch_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResult() { return $this->result; }
|
public function getResult() { return $this->result; }
|
||||||
|
|||||||
@@ -101,7 +101,11 @@ class MessageEvent
|
|||||||
foreach (ZMBuf::$events[CQCommand::class] ?? [] as $v) {
|
foreach (ZMBuf::$events[CQCommand::class] ?? [] as $v) {
|
||||||
/** @var CQCommand $v */
|
/** @var CQCommand $v */
|
||||||
if ($v->match == "" && $v->regexMatch == "") continue;
|
if ($v->match == "" && $v->regexMatch == "") continue;
|
||||||
else {
|
elseif (($v->user_id == 0 || ($v->user_id != 0 && $v->user_id == context()->getData()["user_id"])) &&
|
||||||
|
($v->group_id == 0 || ($v->group_id != 0 && $v->group_id == (context()->getData()["group_id"] ?? 0))) &&
|
||||||
|
($v->discuss_id == 0 || ($v->discuss_id != 0 && $v->discuss_id == (context()->getData()["discuss_id"] ?? 0))) &&
|
||||||
|
($v->message_type == '' || ($v->message_type != '' && $v->message_type == context()->getData()["message_type"]))
|
||||||
|
) {
|
||||||
$c = $v->class;
|
$c = $v->class;
|
||||||
$class_construct = [
|
$class_construct = [
|
||||||
"data" => context()->getData(),
|
"data" => context()->getData(),
|
||||||
|
|||||||
Reference in New Issue
Block a user