mirror of https://github.com/dnomd343/tgbot
Dnomd343
3 years ago
6 changed files with 47 additions and 2 deletions
@ -0,0 +1,21 @@ |
|||
<?php |
|||
|
|||
class tgReply { // Telegram消息待回复记录 |
|||
function match() { // 匹配用户回复 |
|||
$redis = new RedisCache('reply'); |
|||
$userId = $GLOBALS['tgEnv']['userId']; |
|||
$reply = $redis->getData($userId); // 查询用户是否有待回复记录 |
|||
if (!$reply) { return null; } // 无记录返回null |
|||
$redis->delData($userId); |
|||
return json_decode($reply, true); // 返回待回复命令 |
|||
} |
|||
|
|||
function add($cmd) { // 添加待回复记录 |
|||
$redis = new RedisCache('reply'); |
|||
$redis->setData($GLOBALS['tgEnv']['userId'], json_encode( // 缓存记录 |
|||
array('cmd' => $cmd) |
|||
)); |
|||
} |
|||
} |
|||
|
|||
?> |
Loading…
Reference in new issue