File tree Expand file tree Collapse file tree 4 files changed +48
-7
lines changed Expand file tree Collapse file tree 4 files changed +48
-7
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,36 @@ protected function grid()
41
41
$ username = $ this ->userData ['username ' ] ?? '' ;
42
42
return "<div style='padding:10px 10px'><p>UID: $ uid</p><p>first name: $ first_name</p><p>last name: $ last_name</p><p>用户名: $ username</p></div> " ;
43
43
});
44
+
45
+ $ grid ->column ('text ' )->display (function () {
46
+ if (!empty ($ this ->data ['text ' ])){
47
+ return $ this ->data ['text ' ];
48
+ }
49
+ if (!empty ($ this ->data ['caption ' ])){
50
+ return $ this ->data ['caption ' ];
51
+ }
52
+ return '暂无信息 ' ;
53
+ })->expand (function ($ model ) {
54
+ $ text = '暂无信息 ' ;
55
+ if (!empty ($ this ->data ['text ' ])){
56
+ $ text = $ this ->data ['text ' ];
57
+ }
58
+ if (!empty ($ this ->data ['caption ' ])){
59
+ $ text = $ this ->data ['caption ' ];
60
+ }
61
+ $ html ="<div style='padding:10px 10px'><p>内容: {$ text }</p></div> " ;
62
+ //如果有图片
63
+ // if (!empty($this->data['photo'])){
64
+ // $html.="<div style='padding:10px 10px'><p>图片: </p>";
65
+ // $imagesNum = count($this->data['photo'])-1;
66
+ // $imageFileId = $this->data['photo'][$imagesNum]['file_id'];
67
+ // $photo = get_file_url($imageFileId);
68
+ // $html.="<img src='{$photo}' style='max-width: 100%;height: auto;'>";
69
+ // $html.="</div>";
70
+ // }
71
+ return $ html ;
72
+ });
73
+
44
74
$ grid ->column ('created_at ' );
45
75
$ grid ->column ('updated_at ' )->sortable ();
46
76
Original file line number Diff line number Diff line change @@ -99,3 +99,10 @@ function get_text_title($string)
99
99
$ limitedString = Str::limit ($ replaced );
100
100
return Str::before ($ limitedString , PHP_EOL );
101
101
}
102
+
103
+ function get_file_url ($ file_id )
104
+ {
105
+ $ telegram = new \Telegram \Bot \Api (config ('services.telegram.bot_token ' ));
106
+ $ file = $ telegram ->getFile (['file_id ' => $ file_id ]);
107
+ return 'https://api.telegram.org/file/bot ' .config ('services.telegram.bot_token ' ).'/ ' .$ file_id ;
108
+ }
Original file line number Diff line number Diff line change @@ -16,13 +16,16 @@ public function pa()
16
16
{
17
17
$ telegram = new Api (env ('TELEGRAM_BOT_TOKEN ' ));
18
18
19
- $ text ="稿件消息<a href='https://t.me/123'>123</a> " ;
20
-
21
- dd ($ telegram ->sendMessage ([
22
- 'chat_id ' => '6247385123 ' ,
23
- 'text ' => $ text ,
24
- 'parse_mode ' => 'HTML ' ,
25
- ]));
19
+ $ file =$ telegram ->getFile (['file_id ' =>'AgACAgEAAxkBAAIB2GYPabtpIuMVtmNIYreBYbEagoq7AALHqzEbvsSARJrVHae73dkSAQADAgADcwADNAQ ' ]);
20
+ dd ($ file );
21
+
22
+ // $text="稿件消息<a href='https://t.me/123'>123</a>";
23
+ //
24
+ // dd($telegram->sendMessage([
25
+ // 'chat_id' => '6247385123',
26
+ // 'text' => $text,
27
+ // 'parse_mode' => 'HTML',
28
+ // ]));
26
29
}
27
30
28
31
Original file line number Diff line number Diff line change 13
13
'userData ' => '用户信息 ' ,
14
14
'data ' => '消息整体 ' ,
15
15
'user_name ' => '用户名称 ' ,
16
+ 'text ' => '消息内容 ' ,
16
17
],
17
18
'options ' => [
18
19
],
You can’t perform that action at this time.
0 commit comments