1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2024-12-18 23:48:56 +02:00
OpenIntegrations/docs/en/md/Telegram/Data-sending/Send-media-group.md
2024-08-13 15:52:26 +03:00

4.3 KiB

sidebar_position
7

Send media group

Sends a set of files to a chat or channel. Media types: audio, document, photo, video

Function SendMediaGroup(Val Token, Val ChatID, Val Text, Val FileMapping, Val Keyboard = "", Val Markup = "Markdown") Export

Parameter CLI option Type Description
Token --token String Bot token
ChatID --chat String, Number Target chat ID or ChatID*TopicID
Text --text String Message text
FileMapping --media Map of String File JSON or path to .json
Keyboard --keyboard String Keyboard JSON or path to .json
Markup --parsemode String Text processing type (HTML, Markdown, MarkdownV2)

Returns: Map Of KeyAndValue - Serialized JSON response from Telegram


:::tip Map: Key - File, Value - media type :::

  Token  = FunctionParameters["Telegram_Token"];
  ChatID = FunctionParameters["Telegram_ChatID"];
  Text   = FunctionParameters["String"];
  Image  = FunctionParameters["Picture"];
  Video  = FunctionParameters["Video"];
  
  ImagePath = GetTempFileName("png");
  CopyFile(Image, ImagePath);
  
  VideoPath = GetTempFileName("mp4");
  CopyFile(Video, VideoPath);
  
  VideoDD = New BinaryData(VideoPath);
  
  MediaGroup = New Map;
  MediaGroup.Insert(ImagePath, "photo");
  MediaGroup.Insert(VideoDD  , "video");
  
  Result = OPI_Telegram.SendMediaGroup(Token, ChatID, Text, MediaGroup);
    
  oint telegram SendMediaGroup --token "111111111:AACccNYOAFbuhAL5GAaaBbbbOjZYFvLZZZZ" --chat %chat% --text %text% --media %media% --keyboard %keyboard% --parsemode %parsemode%

{
  "ok": true,
  "result": [
  {
  "message_id": 4644,
  "from": {
  "id": 6129457865,
  "is_bot": true,
  "first_name": "Vitaly The Bot",
  "username": "sicheebot"
  },
  "chat": {
  "id": 461699897,
  "first_name": "Anton",
  "last_name": "Titowets",
  "username": "JKIee",
  "type": "private"
  },
  "date": 1717072435,
  "media_group_id": "13736579485142714",
  "photo": [
  {
  "file_id": "AgACAgIAAxkDAAISJGZYcjMH_sZQUquUAgQ99ai1gbJJAAKa2TEbvv6xSgxyd39G8AuyAQADAgADcwADNQQ",
  "file_unique_id": "AQADmtkxG77-sUp4",
  "file_size": 1568,
  "width": 90,
  "height": 67
  },
  {
  "file_id": "AgACAgIAAxkDAAISJGZYcjMH_sZQUquUAgQ99ai1gbJJAAKa2TEbvv6xSgxyd39G8AuyAQADAgADbQADNQQ",
  "file_unique_id": "AQADmtkxG77-sUpy",
  "file_size": 21633,
  "width": 320,
  "height": 240
  },
  {
  "file_id": "AgACAgIAAxkDAAISJGZYcjMH_sZQUquUAgQ99ai1gbJJAAKa2TEbvv6xSgxyd39G8AuyAQADAgADeAADNQQ",
  "file_unique_id": "AQADmtkxG77-sUp9",
  "file_size": 99260,
  "width": 800,
  "height": 600
  },
  {
  "file_id": "AgACAgIAAxkDAAISJGZYcjMH_sZQUquUAgQ99ai1gbJJAAKa2TEbvv6xSgxyd39G8AuyAQADAgADeQADNQQ",
  "file_unique_id": "AQADmtkxG77-sUp-",
  "file_size": 218651,
  "width": 1280,
  "height": 960
  },
  {
  "file_id": "AgACAgIAAxkDAAISJGZYcjMH_sZQUquUAgQ99ai1gbJJAAKa2TEbvv6xSgxyd39G8AuyAQADAgADdwADNQQ",
  "file_unique_id": "AQADmtkxG77-sUp8",
  "file_size": 650214,
  "width": 2560,
  "height": 1920
  }
  ],
  "caption": "String value"
  },
  {
  "message_id": 4645,
  "from": {
  "id": 6129457865,
  "is_bot": true,
  "first_name": "Vitaly The Bot",
  "username": "sicheebot"
  },
  "chat": {
  "id": 461699897,
  "first_name": "Anton",
  "last_name": "Titowets",
  "username": "JKIee",
  "type": "private"
  },
  "date": 1717072435,
  "media_group_id": "13736579485142714",
  "video": {
  "duration": 5,
  "width": 640,
  "height": 480,
  "file_name": "video1",
  "mime_type": "video/mp4",
  "thumbnail": {
  "file_id": "AAMCAgADGQMAAhIlZlhyM8blQGUtyAJ_ndJRjfrrHT8AAq9QAAJgKMhK7ZjJRS8XMtIBAAdtAAM1BA",
  "file_unique_id": "AQADr1AAAmAoyEpy",
  "file_size": 20106,
  "width": 320,
  "height": 240
  },
  "thumb": {
  "file_id": "AAMCAgADGQMAAhIlZlhyM8blQGUtyAJ_ndJRjfrrHT8AAq9QAAJgKMhK7ZjJRS8XMtIBAAdtAAM1BA",
  "file_unique_id": "AQADr1AAAmAoyEpy",
  "file_size": 20106,
  "width": 320,
  "height": 240
  },
  "file_id": "BAACAgIAAxkDAAISJWZYcjPG5UBlLcgCf53SUY366x0_AAKvUAACYCjISu2YyUUvFzLSNQQ",
  "file_unique_id": "AgADr1AAAmAoyEo",
  "file_size": 1137878
  }
  }
  ]
  }