mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 16:45:35 +08:00
fix ZMRobot function name and deprecate CQAPI
This commit is contained in:
@@ -10,6 +10,7 @@ use Framework\ZMBuf;
|
|||||||
use ZM\Connection\ConnectionManager;
|
use ZM\Connection\ConnectionManager;
|
||||||
use ZM\Connection\CQConnection;
|
use ZM\Connection\CQConnection;
|
||||||
use ZM\Connection\WSConnection;
|
use ZM\Connection\WSConnection;
|
||||||
|
use ZM\Utils\ZMRobot;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method static send_private_msg($self_id, $params, $function = null)
|
* @method static send_private_msg($self_id, $params, $function = null)
|
||||||
@@ -68,19 +69,26 @@ use ZM\Connection\WSConnection;
|
|||||||
*/
|
*/
|
||||||
class CQAPI
|
class CQAPI
|
||||||
{
|
{
|
||||||
public static function quick_reply(WSConnection $conn, $data, $msg, $yield = null) {
|
public static function quick_reply(CQConnection $conn, $data, $msg, $yield = null) {
|
||||||
switch ($data["message_type"]) {
|
switch ($data["message_type"]) {
|
||||||
case "group":
|
case "group":
|
||||||
return self::send_group_msg($conn, ["group_id" => $data["group_id"], "message" => $msg], $yield);
|
return (new ZMRobot($conn))->setCallback($yield)->sendGroupMsg($data["group_id"], $msg);
|
||||||
case "private":
|
case "private":
|
||||||
return self::send_private_msg($conn, ["user_id" => $data["user_id"], "message" => $msg], $yield);
|
return (new ZMRobot($conn))->setCallback($yield)->sendPrivateMsg($data["user_id"], $msg);
|
||||||
case "discuss":
|
case "discuss":
|
||||||
return self::send_discuss_msg($conn, ["discuss_id" => $data["discuss_id"], "message" => $msg], $yield);
|
return (new ZMRobot($conn))->setCallback($yield)->sendDiscussMsg($data["discuss_id"], $msg);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param $arg
|
||||||
|
* @return bool
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
public static function __callStatic($name, $arg) {
|
public static function __callStatic($name, $arg) {
|
||||||
|
trigger_error("This dynamic CQAPI calling method will be removed after 2.0 version.", E_USER_DEPRECATED);
|
||||||
$all = self::getSupportedAPIs();
|
$all = self::getSupportedAPIs();
|
||||||
$find = null;
|
$find = null;
|
||||||
if (in_array($name, $all)) $find = $name;
|
if (in_array($name, $all)) $find = $name;
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ class ZMRobot
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCookie($domain = "") {
|
public function getCookies($domain = "") {
|
||||||
return CQAPI::processAPI($this->connection, [
|
return CQAPI::processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName(__FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
|
|||||||
Reference in New Issue
Block a user