|
|
@@ -193,38 +193,53 @@ class BaseService
|
|
|
* @param {string} $text 通知内容
|
|
|
* @param {array} $keyboard 操作按钮
|
|
|
* @param {*string} $image 图片
|
|
|
- * @return {*}
|
|
|
*/
|
|
|
public static function bettingGroupNotice($text, $keyboard = [], $image = '', $isTop = false): void
|
|
|
{
|
|
|
$bettingGroup = Config::where('field', 'betting_group')->first()->val;
|
|
|
-
|
|
|
- $botMsg = [
|
|
|
- 'chat_id' => "@{$bettingGroup}",
|
|
|
- 'text' => $text
|
|
|
- ];
|
|
|
- if (count($keyboard) > 0) {
|
|
|
- $botMsg['reply_markup'] = json_encode(['inline_keyboard' => $keyboard]);
|
|
|
- }
|
|
|
- if (!empty($image)) {
|
|
|
- $botMsg['photo'] = InputFile::create($image);
|
|
|
- $botMsg['caption'] = $text;
|
|
|
- $botMsg['protect_content'] = true; // 防止转发
|
|
|
- $response = self::telegram()->sendPhoto($botMsg);
|
|
|
- } else {
|
|
|
- $response = self::telegram()->sendMessage($botMsg);
|
|
|
+ $array = explode("\n", $text);
|
|
|
+ $texts = [];
|
|
|
+ foreach ($array as $item) {
|
|
|
+ if (empty($texts) || strlen($texts[count($texts) - 1] . $item) <= 4096) {
|
|
|
+ $texts[count($texts) - 1] .= $item;
|
|
|
+ } else {
|
|
|
+ $texts[] = $item;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if ($isTop == true) {
|
|
|
- // 获取消息ID
|
|
|
- $messageId = $response->get('message_id');
|
|
|
- // 置顶消息
|
|
|
- self::telegram()->pinChatMessage([
|
|
|
+ foreach ($texts as $index => $item) {
|
|
|
+ $botMsg = [
|
|
|
'chat_id' => "@{$bettingGroup}",
|
|
|
- 'message_id' => $messageId
|
|
|
- ]);
|
|
|
+ 'text' => $item
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ if ($index == 0 && count($keyboard) > 0) {
|
|
|
+ $botMsg['reply_markup'] = json_encode(['inline_keyboard' => $keyboard]);
|
|
|
+ }
|
|
|
+ if ($index == 0 && !empty($image)) {
|
|
|
+ $botMsg['photo'] = InputFile::create($image);
|
|
|
+ $botMsg['caption'] = $item;
|
|
|
+ $botMsg['protect_content'] = true; // 防止转发
|
|
|
+ $response = self::telegram()->sendPhoto($botMsg);
|
|
|
+ } else {
|
|
|
+ $response = self::telegram()->sendMessage($botMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($index == 0 && $isTop === true) {
|
|
|
+ // 获取消息ID
|
|
|
+ $messageId = $response->get('message_id');
|
|
|
+ // 置顶消息
|
|
|
+ self::telegram()->pinChatMessage([
|
|
|
+ 'chat_id' => "@{$bettingGroup}",
|
|
|
+ 'message_id' => $messageId
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|