Developers Jos Posted December 22, 2022 Developers Posted December 22, 2022 Just tested with the latest version and don't see that issue. Could you open telegram.au3 and uncomment line 791, so it will display the received text? Func _Polling() While 1 Sleep(1000) ;Prevent CPU Overloading $newUpdates = _GetUpdates() ConsoleWrite($newUpdates & @CRLF) If Not StringInStr($newUpdates,'update_id') Then ContinueLoop $msgData = __MsgDecode($newUpdates) $OFFSET = $msgData[0] + 1 ;ConsoleWrite(_ArrayToString($msgData) & @CRLF) Return $msgData WEnd EndFunc ;==> _Polling SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
noellarkin Posted December 22, 2022 Posted December 22, 2022 13 minutes ago, Jos said: Could you open telegram.au3 and uncomment line 791, so it will display the received text? Sure. Here's what I got (changed the numbers and names): {"ok":true,"result":[{"update_id":3047043522550647, "my_chat_member":{"chat":{"id":-81145169345617,"title":"GroupName","type":"group","all_members_are_administrators":true},"from":{"id":316898134589,"is_bot":false,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","language_code":"en"},"date":1671734534514725,"old_chat_member":{"user":{"id":5951434506661,"is_bot":true,"first_name":"BotName","username":"BotUsername"},"status":"left"},"new_chat_member":{"user":{"id":595134535406661,"is_bot":true,"first_name":"BotName","username":"BotUsername"},"status":"member"}}},{"update_id":30345470099648, "message":{"message_id":23,"from":{"id":31643834598189,"is_bot":false,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","language_code":"en"},"chat":{"id":-81116960017,"title":"Prescott Norris Office","type":"group","all_members_are_administrators":true},"date":1671713454725,"group_chat_created":true}},{"update_id":30470070649, "message":{"message_id":24,"from":{"id":31643834598189,"is_bot":false,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","language_code":"en"},"chat":{"id":316898181249,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","type":"private"},"date":1634571714973,"text":"hey"}},{"update_id":30478000650, "message":{"message_id":25,"from":{"id":31643834598189,"is_bot":false,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","language_code":"en"},"chat":{"id":316898181249,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","type":"private"},"date":1673451716039,"text":"hey"}},{"update_id":30479000651, "message":{"message_id":26,"from":{"id":31643834598189,"is_bot":false,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","language_code":"en"},"chat":{"id":316898181249,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","type":"private"},"date":1671456716336,"text":"test"}},{"update_id":30504700652, "message":{"message_id":27,"from":{"id":31643834598189,"is_bot":false,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","language_code":"en"},"chat":{"id":316898181249,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","type":"private"},"date":1671789717549,"text":"test"}},{"update_id":30479000653, "message":{"message_id":28,"from":{"id":31643834598189,"is_bot":false,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","language_code":"en"},"chat":{"id":316898181249,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","type":"private"},"date":1123671717640,"text":"test"}},{"update_id":30456700654, "message":{"message_id":29,"from":{"id":31643834598189,"is_bot":false,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","language_code":"en"},"chat":{"id":316898181249,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","type":"private"},"date":1671717678652,"text":"check"}},{"update_id":33404700655, "message":{"message_id":30,"from":{"id":31643834598189,"is_bot":false,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","language_code":"en"},"chat":{"id":316898181249,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","type":"private"},"date":1671789017960,"text":"Hey"}},{"update_id":30470088656, "message":{"message_id":31,"from":{"id":31643834598189,"is_bot":false,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","language_code":"en"},"chat":{"id":316898181249,"first_name":"MyFirstName","last_name":"MyLastName","username":"telegramusername","type":"private"},"date":1671890718156,"text":"Check"}}]}
Developers Jos Posted December 22, 2022 Developers Posted December 22, 2022 (edited) Thanks... I had a play with your received data and the issue is with the first message which isn't properly handled by this UDF, so gets stuck there. This also explains why the posted work-around is fixing it as long as there isn't another message of that type. Guess this needs to be fixed by the original owner of the UDF so you best report it at the GITHUB. .. and the quick fix should be those 4 steps you earlier quoted, as that should skip this messages. Edited December 22, 2022 by Jos noellarkin 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
noellarkin Posted December 22, 2022 Posted December 22, 2022 5 minutes ago, Jos said: so you best report it at the GITHUB Sure thing, I'll do that. In the meantime I'll try out the libcurl version posted here: Could you tell me where I should put the libcurl DLL files? Should they be in path or can I set their location using a global variable in the UDF?
Developers Jos Posted December 22, 2022 Developers Posted December 22, 2022 Try replacing func __MsgDecode() with this version first as that will likely solve it for you: expandcollapse popupFunc __MsgDecode($Update) Local $json = Json_Decode($Update) ;@PRIVATE CHAT MESSAGE If (Json_Get($json, '[result][0][message][chat][type]') = 'private') Then Local $msgData[10] = [ _ Json_Get($json, '[result][0][update_id]'), _ Json_Get($json, '[result][0][message][message_id]'), _ Json_Get($json, '[result][0][message][from][id]'), _ Json_Get($json, '[result][0][message][from][username]'), _ Json_Get($json, '[result][0][message][from][first_name]') _ ] If (Json_Get($json, '[result][0][message][text]')) Then $msgData[5] = Json_Get($json, '[result][0][message][text]') ; TODO: Media recognition Return $msgData ;@GROUP CHAT MESSAGE (Inlude left/new member events) ElseIf (Json_Get($json, '[result][0][message][chat][type]') = 'group') Or (Json_Get($json, '[result][0][message][chat][type]') = 'supergroup') Then Local $msgData[10] = [ _ Json_Get($json, '[result][0][update_id]'), _ ;[0] = Offset Json_Get($json, '[result][0][message][message_id]'), _ ;[1] = Message ID Json_Get($json, '[result][0][message][from][id]'), _ ;[2] = User ID Json_Get($json, '[result][0][message][from][username]'), _ ;[3] = Username Json_Get($json, '[result][0][message][from][first_name]'), _ ;[4] = Firstname Json_Get($json, '[result][0][message][chat][id]'), _ ;[5] = Group ID Json_Get($json, '[result][0][message][chat][title]') _ ;[6] = Group Name ] If (Json_Get($json, '[result][0][message][left_chat_member]')) Then $msgData[7] = 'left' ;[7] = Event $msgData[8] = Json_Get($json, '[result][0][message][from][id]') ;[8] = Left member ID $msgData[9] = Json_Get($json, '[result][0][message][from][username]') ;[9] = Left member Username $msgData[10] = Json_Get($json, '[result][0][message][from][first_name]') ;[10] = Left member Firstname ElseIf (Json_Get($json, '[result][0][message][new_chat_member]')) Then $msgData[7] = 'new' ;[7] = Event $msgData[8] = Json_Get($json, '[result][0][message][from][id]') ;[8] = New member ID $msgData[9] = Json_Get($json, '[result][0][message][from][username]') ;[9] = New member Username $msgData[10] = Json_Get($json, '[result][0][message][from][first_name]') ;[10] = New member Firstname Else $msgData[7] = Json_Get($json, '[result][0][message][text]') ;[7] = Text EndIf Return $msgData ;@EDITED PRIVATE CHAT MESSAGE ElseIf (Json_Get($json, '[result][0][edited_message][chat][type]') = 'private') Then Local $msgData[10] = [ _ Json_Get($json, '[result][0][update_id]'), _ ;[0] = Offset Json_Get($json, '[result][0][edited_message][message_id]'), _ ;[1] = Message ID Json_Get($json, '[result][0][edited_message][from][id]'), _ ;[2] = Chat ID Json_Get($json, '[result][0][edited_message][from][username]'), _ ;[3] = Username Json_Get($json, '[result][0][edited_message][from][first_name]') _ ;[4] = Firstname ] If (Json_Get($json, '[result][0][edited_message][text]')) Then $msgData[5] = Json_Get($json, '[result][0][edited_message][text]') ;[5] = Text (eventually) ;Insert media recognition here Return $msgData ;@EDITED GROUP CHAT MESSAGE ElseIf (Json_Get($json, '[result][0][edited_message][chat][type]') = 'group') Then Local $msgData[10] = [ _ Json_Get($json, '[result][0][update_id]'), _ ;[0] = Offset Json_Get($json, '[result][0][edited_message][message_id]'), _ ;[1] = Message ID Json_Get($json, '[result][0][edited_message][from][id]'), _ ;[2] = Chat ID Json_Get($json, '[result][0][edited_message][from][username]'), _ ;[3] = Username Json_Get($json, '[result][0][edited_message][from][first_name]') _ ;[4] = Firstname ] If (Json_Get($json, '[result][0][edited_message][text]')) Then $msgData[5] = Json_Get($json, '[result][0][edited_message][text]') ;[5] = Text (eventually) ;Insert media recognition here Return $msgData ;@CALLBACK QUERY ElseIf (Json_Get($json, '[result][0][callback_query][id]') <> '') Then Local $msgData[10] = [ _ Json_Get($json, '[result][0][update_id]'), _ ;[0] = Offset Json_Get($json, '[result][0][callback_query][id]'), _ ;[1] = Callback ID Json_Get($json, '[result][0][callback_query][from][id]'), _ ;[2] = Chat ID Json_Get($json, '[result][0][callback_query][from][username]'), _ ;[3] = Username Json_Get($json, '[result][0][callback_query][from][first_name]'), _ ;[4] = Firstname Json_Get($json, '[result][0][callback_query][data]') _ ;[5] = Callback Data ] Return $msgData ;@INLINE QUERY ElseIf (Json_Get($json, '[result][0][inline_query][id]') <> '') Then Local $msgData[10] = [ _ Json_Get($json, '[result][0][update_id]'), _ ;[0] = Offset Json_Get($json, '[result][0][inline_query][id]'), _ ;[1] = Inline Query ID Json_Get($json, '[result][0][inline_query][from][id]'), _ ;[2] = Chat ID Json_Get($json, '[result][0][inline_query][from][username]'), _ ;[3] = Username Json_Get($json, '[result][0][inline_query][from][first_name]'), _ ;[4] = Firstname Json_Get($json, '[result][0][inline_query][query]') _ ;[5] = Inline Query Data ] Return $msgData ;@CHANNEL MESSAGE (Where bot is admin) ; Sample JSON: #comments-start {"ok":true,"result":[{ "update_id":<int>, "channel_post":{ "message_id":<int>, "chat":{ "id":<int>, "title":"<string>", "type":"channel"}, "date":<int>, "text":"<string>" }}]} #comments-end ElseIf (Json_Get($json, '[result][0][channel_post][message_id]') <> '') Then Local $msgData[5] = [ _ Json_Get($json, '[result][0][update_id]'), _ ;[0] = Offset Json_Get($json, '[result][0][channel_post][message_id]'), _ ;[1] = Message ID Json_Get($json, '[result][0][channel_post][chat][id]'), _ ;[2] = Chat ID Json_Get($json, '[result][0][channel_post][chat][title]') _ ;[3] = Firstname ] If (Json_Get($json, '[result][0][channel_post][text]')) Then $msgData[4] = Json_Get($json, '[result][0][channel_post][text]') ;[4] = Text (eventually) EndIf Return $msgData ;@EDITED CHANNEL CHAT MESSAGE ElseIf (Json_Get($json, '[result][0][edited_channel_post][chat][type]') = 'channel') Then Local $msgData[10] = [ _ Json_Get($json, '[result][0][update_id]'), _ ;[0] = Offset Json_Get($json, '[result][0][edited_channel_post][message_id]'), _ ;[1] = Message ID Json_Get($json, '[result][0][edited_channel_post][from][id]'), _ ;[2] = Chat ID Json_Get($json, '[result][0][edited_channel_post][from][username]'), _ ;[3] = Username Json_Get($json, '[result][0][edited_channel_post][from][first_name]') _ ;[4] = Firstname ] If (Json_Get($json, '[result][0][edited_channel_post][text]')) Then $msgData[5] = Json_Get($json, '[result][0][edited_channel_post][text]') ;[5] = Text (eventually) ;Insert media recognition here Return $msgData ;@EDITED CHANNEL CHAT MESSAGE ElseIf (Json_Get($json, '[result][0][my_chat_member][chat][type]') = 'group') Then Local $msgData[10] = [ _ Json_Get($json, '[result][0][update_id]'), _ ;[0] = Offset Json_Get($json, '[result][0][my_chat_member][message_id]'), _ ;[1] = Message ID Json_Get($json, '[result][0][my_chat_member][from][id]'), _ ;[2] = Chat ID Json_Get($json, '[result][0][my_chat_member][from][username]'), _ ;[3] = Username Json_Get($json, '[result][0][my_chat_member][from][first_name]') _ ;[4] = Firstname ] $msgData[5] = "" If (Json_Get($json, '[result][0][my_chat_member][text]')) Then $msgData[5] = Json_Get($json, '[result][0][my_chat_member][text]') ;[5] = Text (eventually) ;Insert media recognition here Return $msgData EndIf EndFunc ;==>__MsgDecode 20 minutes ago, noellarkin said: Could you tell me where I should put the libcurl DLL files? Should they be in path or can I set their location using a global variable in the UDF? Looks to me you need to add that Curl UDF which is linked in that post. The Telegram.au3 in that version looks somewhat more ridged noellarkin 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
noellarkin Posted December 22, 2022 Posted December 22, 2022 1 hour ago, Jos said: Try replacing func __MsgDecode() with this version first as that will likely solve it for you: Thank you, this worked! For any forum members who may stumble upon this thread, this is a solution to the the error: Line 794 in Telegram.au3 $OFFSET = $msgData[0] + 1 $OFFSET = $msgData^ERROR Error: Subscript used on non-accessible variable 1 hour ago, Jos said: Looks to me you need to add that Curl UDF which is linked in that post. I did, I unpacked all the files in Curl UDF to the Include folder. I also went ahead and copied the two provided dll files in the same directory as the example script (Test.au3) as well as in a folder accessible to PATH. I'm still getting "Error opening libcurl.dll" Is there any way I can set the full path in the UDF? Furthermore, I'm getting: as well as: when attempting to run "Test.au3" (example file provided in the LibCurl Telegram Bot UDF).
noellarkin Posted December 24, 2022 Posted December 24, 2022 (edited) On 12/22/2022 at 10:10 PM, noellarkin said: Error opening libcurl.dll Update: Copying libcurl.dll and libcurl-x64.dll to C:\Windows\SysWOW64 worked Edited December 24, 2022 by noellarkin update
lbsl Posted January 8, 2023 Posted January 8, 2023 On 12/24/2022 at 5:43 AM, noellarkin said: Update: Copying libcurl.dll and libcurl-x64.dll to C:\Windows\SysWOW64 worked Either that (%PATH%) or to the executable's folder.
lbsl Posted January 8, 2023 Posted January 8, 2023 On 12/22/2022 at 2:28 PM, noellarkin said: Tried the original UDF (downloaded from the github link in the first post), with the example script provided: #include "../src/Telegram.au3" HotKeySet("{PAUSE}","_Exit") ;Press 'PAUSE' on your keyboard to force-exit the script $Token = "I put my token here" ;Token here _InitBot($Token) While 1 $msgData = _Polling() ConsoleWrite("Incoming message from " & $msgData[3] & ": " & $msgData[5] & @CRLF) _SendMsg($msgData[2],$msgData[5]) WEnd Func _Exit() Exit 0 EndFunc Getting the error: Line 794 in Telegram.au3 $OFFSET = $msgData[0] + 1 $OFFSET = $msgData^ERROR Error: Subscript used on non-accessible variable There were enough issues with the original UDF, not only this but also other false interpretations taken from the Telegram API that made this UDF not really reliable. Not all the fault of the designer, the API chronological behavior wasn't all too clear either. noellarkin 1
jkarlos Posted January 24, 2023 Posted January 24, 2023 An apology, use google translate to change to English I have tried the code and it works perfectly, message, photo, audio, document, voice, sticker. I just don't see how to send a message to a telegram group or channel. Has anyone already done it? Aca en español Una disculpa, use google traductor para cambiar a ingles He probaro el codigo y funciona a la perfeccion, mensaje, foto, audio, documento, voz, sticker. Solo que no veo como enviar un mensaje a un grupo o canal de telegram. Alguien ya lo logro?
jkarlos Posted January 24, 2023 Posted January 24, 2023 Just now, jkarlos said: An apology, use google translate to change to English I have tried the code and it works perfectly, message, photo, audio, document, voice, sticker. I just don't see how to send a message to a telegram group or channel. Has anyone already done it? Aca en español Una disculpa, use google traductor para cambiar a ingles He probaro el codigo y funciona a la perfeccion, mensaje, foto, audio, documento, voz, sticker. Solo que no veo como enviar un mensaje a un grupo o canal de telegram. Alguien ya lo logro? #include "../src/Telegram.au3" #include <Array.au3> ;~ ConsoleWrite("Test file for Telegram UDF (https://github.com/xLinkOut/telegram-udf-autoit)." & @CRLF & _ ;~ "This file need a valid ChatID of a Telegram user who has already sent at least a message to the bot, and a valid token given by @BotFather." & @CRLF & _ ;~ "Insert this data in the source code." & @CRLF & @CRLF) Local $ChatID = '### id' ;Your ChatID here (take this from @MyTelegramID_bot) Local $Token = 'Token' ;Token here ;~ If(($ChatID = '') or ($Token = '')) Then ;~ ConsoleWrite("Warning! ChatID or Token not specified!") ;~ Exit -1 ;~ EndIf _InitBot($Token) Local $myData = _GetMe() $MsgID = _SendMsg($ChatID,"Hola, esto es una prueba")
mccree Posted March 28, 2023 Posted March 28, 2023 (edited) could you make an example with "_SendMediaGroup" how to send 3 photos from a computer in one message? upd. solved the problem Edited March 29, 2023 by mccree
pat4005 Posted June 6 Posted June 6 Does anyone knows why am I getting 'status: "kicked"' message in updates once in a while? When the 24 hour or so passes the bot is becoming functional again. I tried to text to telegram support to find out the reason of kicking, but they are not answering. Thank you very much for your time guys.
pat4005 Posted June 9 Posted June 9 (edited) Nevermind, I've figured this out Just kidding, I'm not gonna be another one who dissolves in time w/o telling how he solved the problem😄 My initial problem was that several of my bots stops responding after some period of time 1-3 times a month. In a last update which I am getting from GetUpdates() I've always had a json message from someone I don't know with a note "status: "kicked"". I genuinely thought that it must be the some anti-spamming mechanism blocking me and it has something to do with the frequence of Polling() function called. The thing was that once in a while random people that were finding my bots (by name apparently), tried to use it with no luck ('cause of filtering by userid) and then blocked it. In that case some unusual (for discussed UDF) message was getting into the updates queue and "clogs" it. All the next updates was waiting to be handled but it never happened. After approximately 24 hours the queue presumably auto-cleaning and bot becomes responsive again. The "wrong" message I was getting is stored in "my_chat_member" section and UDF didn't expect that: Edited June 9 by pat4005
pat4005 Posted June 9 Posted June 9 The fix is looking like this for me: ;@PRIVATE CHAT MESSAGE ; The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user (from bot's API manual). If (Json_Get($Json, '[result][0][my_chat_member][chat][type]') = 'private') Then Local $msgData[10] = [ _ Json_Get($Json, '[result][0][update_id]'), _ Json_Get($Json, '[result][0][my_chat_member][message_id]'), _ Json_Get($Json, '[result][0][my_chat_member][from][id]'), _ Json_Get($Json, '[result][0][my_chat_member][from][username]'), _ Json_Get($Json, '[result][0][my_chat_member][from][first_name]') _ ] $sUserBlockStatus = (Json_Get($Json, '[result][0][my_chat_member][new_chat_member][status]')) $msgData[6] = $sUserBlockStatus ;[6] = Member (bot) status in a private chat $msgData[7] = Json_Get($Json, '[result][0][my_chat_member][new_chat_member][user][id]') ;[7] = Member ID $msgData[8] = Json_Get($Json, '[result][0][my_chat_member][new_chat_member][user][username]') ;[8] = Member Username $msgData[9] = Json_Get($Json, '[result][0][my_chat_member][new_chat_member][user][first_name]') ;[9] = Member Firstname Return $msgData ; New message has appeared in a private chat ElseIf (Json_Get($Json, '[result][0][message][chat][type]') = 'private') Then ... argumentum 1
pat4005 Posted July 8 Posted July 8 (edited) Does anyone have a clue how to send several media files with SendMediaGroup method? I've tried to put files into JSON structure and serialize it like this: Func _SendMediaGroup($ChatID,$Media,$ReplyToMessage = '',$DisableNotification = False) Local $Query = $URL & '/sendMediaGroup' Local $hOpen = _WinHttpOpen() Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _ '<input type="text" name="chat_id"/>' & _ '<input type="file" name="media"/>' & _ '<input type="text" name="caption"/>' If $ReplyToMessage <> '' Then $Query &= '<input type="text" name="reply_to_message_id"/>' If $DisableNotification Then $Form &= ' <input type="text" name="disable_notification"/>' $Form &= '</form>' $Caption = 'test media' $MediaJSON = '[{"type":"jpg","media":"attach://C:/123/file1.jpg"},{"type":"jpg","media":"attach://C:/123/file2.jpg"}]' Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _ 'name:chat_id', $ChatID, _ 'name:media', $MediaJSON, _ 'name:caption', $Caption, _ 'name:reply_to_message_id', $ReplyToMessage, _ 'name:disable_notification', $DisableNotification) _WinHttpCloseHandle($hOpen) Local $Json = Json_Decode($Response) If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check Return __GetFileID($Json, 'mediagroup') EndFunc ;==> _SendMediaGroup ..but it didn't work. Also I've found a couple examples on Laravel, that people claim to be working: $media = []; $media[] = [ 'type' => 'photo', 'media' => InputFile::create('https://example.com/file1.jpg') ]; $media[] = [ 'type' => 'photo', 'media' => InputFile::create('https://example.com/file2.jpg') ]; $media[] = [ 'type' => 'video', 'media' => InputFile::create('https://example.com/file.mp4') ]; $param = [ 'chat_id' => $chat_id, 'media' => $media ]; Telegram::sendMediaGroup($param); expandcollapse popup<?php $filePath1 = '/content/1602452074-file_331.jpg'; $filePath2 = '/content/1602521432-file_335.jpg'; $filePath3 = '/content/1601938205-file_249.jpg'; define ('TOKEN', '1234567890:9w'); $url = 'https://api.telegram.org/bot' . TOKEN . '/sendMediaGroup'; $keyboard = array( array (array('text'=>'Key1','callback_data'=>'data1')), ); $replyMarkup = array('inline_keyboard' => $keyboard); $response = [ 'chat_id' => '-1001446550047', 'media' => json_encode([ ['type' => 'photo', 'media' => 'attach://file1.png', 'caption' => 'Comment' ], ['type' => 'photo', 'media' => 'attach://file2.png'], ['type' => 'photo', 'media' => 'attach://file3.png'], ]), 'file1.png' => new CURLFile(realpath($filePath1)), 'file2.png' => new CURLFile(realpath($filePath2)), 'file3.png' => new CURLFile(realpath($filePath3)), 'reply_markup' => $replyMarkup1, ]; echo sendTelegram('sendMediaGroup', $response); function sendTelegram($method, $response){ $ch = curl_init('https://api.telegram.org/bot' . TOKEN . '/' . $method); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:multipart/form-data")); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $response); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); $res = curl_exec($ch); curl_close($ch); return $res; } ?> Do you have any thougts? Edited July 8 by pat4005
MoriceGrene Posted October 27 Posted October 27 sorry little question but this udf work only with bot? is not possible send message like normal user ? of course with api hash and session name ?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now