|
|
@@ -347,7 +347,12 @@ class TelegramWebHook extends Controller
|
|
|
|
|
|
$returnMsg = $this->processChatMessage($chatId, $messageId, $message, $message['from']);
|
|
|
if ($returnMsg) {
|
|
|
- $this->telegram->sendMessage($returnMsg);
|
|
|
+ if(isset($returnMsg['photo']) && $returnMsg['photo'] != ''){
|
|
|
+ $this->telegram->sendPhoto($returnMsg);
|
|
|
+ }else{
|
|
|
+ $this->telegram->sendMessage($returnMsg);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
DB::commit();
|
|
|
} catch (MessageException $e) {
|
|
|
@@ -502,6 +507,34 @@ class TelegramWebHook extends Controller
|
|
|
];
|
|
|
break;
|
|
|
default:
|
|
|
+ // 关键字回复
|
|
|
+ $keyboardText = KeyboardService::findOne(['button' => $text]);
|
|
|
+ if ($keyboardText) {
|
|
|
+ $keyboard = [];
|
|
|
+ if ($keyboardText['buttons']) {
|
|
|
+ $keyboard = json_decode($keyboardText['buttons'], true);
|
|
|
+ }
|
|
|
+ Util::delCache($chatId);
|
|
|
+ $res = [
|
|
|
+ 'chat_id' => $chatId,
|
|
|
+ 'text' => $keyboardText['reply'],
|
|
|
+ // 'reply_to_message_id' => $messageId
|
|
|
+ ];
|
|
|
+ if ($keyboard) {
|
|
|
+ $res['reply_markup'] = json_encode(['inline_keyboard' => $keyboard]);
|
|
|
+ }
|
|
|
+ if ($keyboardText['image']) {
|
|
|
+ $res['photo'] = InputFile::create(url($keyboardText['image']));
|
|
|
+ unset($res['text']);
|
|
|
+ $res['caption'] = $text;
|
|
|
+ $res['protect_content'] = true; // 防止转发
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return $res;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
$stepStatus = Cache::get(get_step_key($chatId), -1);
|
|
|
$stepStatus = intval($stepStatus);
|
|
|
switch ($stepStatus) {
|