1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-03-07 15:20:39 +02:00
2024-08-13 15:52:26 +03:00

1.9 KiB

sidebar_position
2

Send file

Sends the file to the chat

Function SendFile(Val Token, Val ChatID, Val File, Val Text = "", Val FileName = "", Val Markup = "MarkdownV2") Export

Parameter CLI option Type Description
Token --token String Bot token
ChatID --chatid String, Number Chat ID for sending
File --file BinaryData, String File for sending
Text --text String File caption
FileName --filename String Displayed file name
Markup --parsemod String Markup type for message text: MarkdownV2 or HTML

Returns: Map Of KeyAndValue - Serialized JSON response from VK Teams


:::tip Method at API documentation: POST /messages/sendFile :::

  Token  = FunctionParameters["VkTeams_Token"];
  ChatID = FunctionParameters["VkTeams_ChatID"];
  Text   = "File caption";
  
  File     = FunctionParameters["Document"]; // URL
  FilePath = GetTempFileName("docx"); // Path
  
  CopyFile(File, FilePath);
  
  FileBD = New BinaryData(FilePath); // Binary
  
  Result = OPI_VKTeams.SendFile(Token, ChatID, File);
  
  OPI_TestDataRetrieval.WriteLog(Result, "SendFile (URL)", "VkTeams");
  
  Result = OPI_VKTeams.SendFile(Token, ChatID, FilePath, Text);
  
  OPI_TestDataRetrieval.WriteLog(Result, "SendFile (Path)", "VkTeams");
  
  Result = OPI_VKTeams.SendFile(Token, ChatID, File, Text, "ImportantDocument.docx");
    
  oint vkteams SendFile --token "001.3501506236.091..." --chatid "AoLI0egLWBSLR1Ngn2w" --file "https://openintegrations.dev/test_data/document.docx // URL" --text "File caption" --filename %filename% --parsemod %parsemod%