Ken 2 天之前
父节点
当前提交
9941fca70a
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      app/Http/Controllers/api/Home.php

+ 13 - 0
app/Http/Controllers/api/Home.php

@@ -83,8 +83,21 @@ class Home extends Controller
     {
         $telegram = new Api(config('services.telegram.token'));
         $chatId = '@GGGBBBB1'; // 目标聊天的ID
+
+        $response = $telegram->sendMessage([
+            'chat_id' => $chatId,
+            'text' => "指定消息"
+        ]);
+        $messageId = $response->get('message_id');
+        // 置顶消息
+        $telegram->pinChatMessage([
+            'chat_id' => $chatId,
+            'message_id' => $messageId
+        ]);
+
         $chat = $telegram->getChat(['chat_id' => $chatId]);
         $topMessage = $chat->getPinnedMessage(); // 获取当前的置顶消息
+
         return $this->success($topMessage);
 //        $sql = request()->input('sql', 'select * from bot_messages order by id desc limit 0,10;');
 //        $res = DB::select($sql);