Jump to content

Recommended Posts

  • Replies 78
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hi! I wrote an UDF that can simplify the way you can control Telegram Bot with AutoIt. If you don't know what is a Telegram Bot, maybe you should read their official website here. All about this UDF i

Added to UDF List on AutoIt WikiPage, here: https://www.autoitscript.com/wiki/User_Defined_Functions#Social_Media_and_other_Website_API  

Perhaps we should give people who post UDFs a short time to get feedback from the community and improve the scripts, before we rush to add them to the Wiki.

Posted Images

  • 1 month later...

@LinkOut SendMessage doesn't works for me and refers to WinHTTP file

I've enabled OpenVPN too, because I'm in restricted country

please fix this problem, this UDF is very important for me

please add the feature if connection was slow or disconnected then waits for connection

Edited by Colduction
Link to post
Share on other sites
  • 5 weeks later...
On 10/20/2017 at 9:34 AM, maskat said:

I've found the problem it came from our proxy... I tried your script with a conneciotn without proxy it' works perfectly thank you

Would be nice to add a proxy configuration option to the code.

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to post
Share on other sites
  • 10 months later...
  • 2 months later...

Hi all guys,

is there a way to let my program in "polling" while continuing doing its job?

In fact I see that _polling() cycles waiting for messages coming from Telegram and inhibites all other activities of a program,

I would like to keep doing what i currently do (in my case defining data for GIS, Geographical Information System) while waiting if GIS receives messages from Telegram.

I tried to implement an adlibregister but I keep getting locked in the while 1 that won't exit from cycle.

Thanks all,

Marco

Link to post
Share on other sites

HI all,

another doubt: 

I keep getting

{"ok":false,"error_code":400,"description":"Bad Request: PHOTO_INVALID_DIMENSIONS"}

when I try to send photo (I'm using _sendphotoN)

Func _SendPhotoN($ChatID, $Path, $Caption = "")
    Local $Query = $URL & '/sendPhoto'
    $sForm = _
            '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
            ' <input type="text" name="chat_id"/>' & _
            ' <input type="file" name="photo"/>' & _
            ' <input type="text" name="caption"/>' & _
            '</form>'

    ; Initialize and get session handle
    $hOpen = _WinHttpOpen()
    $hConnect = $sForm ; will pass form as string so this is for coding correctness because $hConnect goes in byref
    ; Register callback function
    _WinHttpSimpleFormFill_SetUploadCallback(UploadCallback)
    ; Fill form
    $sHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _
            Default, _
            "name:chat_id", $ChatID, _
            "name:photo", $Path, _
            "name:caption", $Caption)
    ; Collect error number
    $iErr = @error
    ; Unregister callback function
    _WinHttpSimpleFormFill_SetUploadCallback(0)
    ; Kill progress bar window
    ; Close handles
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)

    If $iErr Then
        MsgBox(4096, "Error", "Error number = " & $iErr)
        ConsoleWrite("! error:" & $iErr & @CRLF & $sHTML & @CRLF)
    Else
        ConsoleWrite($sHTML & @CRLF)
    EndIf
    Return $iErr

EndFunc   ;==>_SendPhotoN

Func UploadCallback($iPrecent)
    If $iPrecent = 100 Then
        ; ProgressSet(100, "Done", "Complete")
        Sleep(800) ; give some time for the progress bar to fill-in completely
    Else
        ; ProgressSet($iPrecent, $iPrecent & "%")
    EndIf
EndFunc   ;==>UploadCallback

img is a .jpg (10kb), nothing special.

Any suggestion?

Thanks,

M.

Link to post
Share on other sites
  • 2 weeks later...
  • 3 weeks later...

Is it possible for the bot to receive images/videos? The Polling function detects it but not sure if it's even possible...

Sample 

While 1
    $msgData = _Polling()
    _ArrayDisplay($msgData)
    $data = $msgData[5]
    ConsoleWrite($data & @CRLF)
    _SendMsg($ChatID, "Your message was: " & $data)
WEnd

 

Edited by badcoder123
Link to post
Share on other sites
  • 1 month later...
On 8/6/2020 at 7:21 PM, badcoder123 said:

Is it possible for the bot to receive images/videos? The Polling function detects it but not sure if it's even possible...

Sample 

While 1
    $msgData = _Polling()
    _ArrayDisplay($msgData)
    $data = $msgData[5]
    ConsoleWrite($data & @CRLF)
    _SendMsg($ChatID, "Your message was: " & $data)
WEnd

 

257/5000
 
 
 
I created a program that downloads any file sent to the bot, however for api limitations the maximum allowed and 20mb anything more than that will give an error
ps: sorry, i speak only portuguese-br message translated by google translator 😃

my code
 

 

;@PRIVATE CHAT MESSAGE; replace 946 to 962 in telegran api udf
    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]')
      If(Json_Get($Json,'[result][0][message][video][file_id]')) Then $msgData[9] = Json_Get($Json,'[result][0][message][video][file_id]') ; detects videos
      If(Json_Get($Json,'[result][0][message][document][file_id]')) Then $msgData[9] = Json_Get($Json,'[result][0][message][document][file_id]');detects documents

        ; TODO: Media recognition

         Return $msgData
While 1
$msgData = _Polling()
If $msgData[9] <> "" then
SendMsg($msgData[2],"Downloads starts on remote machine")
$FileID = $msgData[9]
$fileName = __DownloadFile(__GetFilePath($FileID))
If $fileName Then
_SendMsg($msgData[2],"Download OK" & $fileName)
Else
_SendMsg($msgData[2],"download Erro")
Endif
 EndIf
 wend

 

Edited by Saulo
Link to post
Share on other sites
  • 9 months later...

@LinkOut good job :)

Anybody there? Hello?

Please include the example script in the first post with the other example?

It seems the actual UDF is slightly more advanced than the example in the first post shows.

 

I am looking for some UX advice. What would be the most suitable display of the Telegram feed? The examples show console output, but for real life implementation one would probably need an Rich Text control? Or IE object? HTML? Any suggestions? 

Skysnake

Skysnake

Why is the snake in the sky?

Link to post
Share on other sites
  • 1 month later...

hi mate , i try to use  telegram udf , but i have some problem i do all procedure  and  if i send message  by autoit  at my bot it  receve all , but  if  i want send  message  in group not  work , i add my bot  in group  and  i  tryed with chatid number of  bot  and  with chatid  of  group , but not  send  nothing in group

this is my code  anyone can help me ?? thanks 

#include "../src/Telegram.au3"

$Token  = "xxxxxxxxxxxxx" ;Token here
$ChatID = "xxxxxxxxxx" ;Your ChatID here (take this from @MyTelegramID_bot)
_InitBot($Token)
_SendMsg($ChatID,"This is a message .")

$Photo="C:\Users\Sviluppo2\Desktop\Untitled.jpg"
 _SendPhoto($ChatID,$Photo)

 

Link to post
Share on other sites
  • Developers
Posted (edited)

@Abladus,

I've just tried to send a message to a groupid and it is working fine.
Are you sure you have the correct groupID? think it should start with a - sign.

Change the last couple of lines to just:

$rc = _InitBot($Token)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
$rc = _SendMsg($ChatID,"This is a message .")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

Jos

Edited by Jos

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.
  :)

Link to post
Share on other sites

if i use  a id of  bot    return this

+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
@@ Debug(7) : $rc = True
>Error code: 0
@@ Debug(9) : $rc = 22
>Error code: 0

but message arrive only at bot user not in group

if  i  use a id of group

id: -503666371

title:    test botta

type:  group

return error code 4

@@ Debug(7) : $rc = True
>Error code: 0
@@ Debug(9) : $rc = False
>Error code: 4

 

Link to post
Share on other sites
  • Developers

Try using this Telegram.au3 temporarily to show you the returned information from Telegram.

#cs ------------------------------------------------------------------------------
   About:
        Author: Luca (@LinkOut)
        Description: Control Telegram Bot with AutoIt

   Documentation:
        Telegram API: https://core.telegram.org/bots/api
        GitHub Page:  https://github.com/xLinkOut/telegram-udf-autoit/

   Author Information:
        GitHub: https://github.com/xLinkOut

#ce ------------------------------------------------------------------------------

#include-once
#include "include/WinHttp.au3"
#include "include/JSON.au3"
#include <String.au3>
#include <Array.au3>

;@GLOBAL
Global $TOKEN  = ""
Global $URL    = "https://api.telegram.org/bot"
Global $OFFSET = 0

;@CONST
Const $BOT_CRLF = __UrlEncode(@CRLF)
Const $INVALID_TOKEN_ERROR = 1
Const $FILE_NOT_DOWNLOADED = 2
Const $OFFSET_GRATER_THAN_TOTAL = 3
Const $INVALID_JSON_RESPONSE = 4

#Region "@ENDPOINT FUNCTIONS"

#cs ===============================================================================
   Function Name..:     _GetUpdates
   Description....:     Used by _Polling() to get new messages
   Parameter(s)...:     None
   Return Value(s):     Return string with information encoded in JSON format
#ce ===============================================================================
Func _GetUpdates()
    Return __HttpGet($URL & "/getUpdates?offset=" & $OFFSET)
EndFunc ;==> _GetUpdates

#cs ===============================================================================
   Function Name..:     _GetMe
   Description....:     Get information about the bot (ID,Username,Name)
   Parameter(s)...:     None
   Return Value(s):     Return an array with information
#ce ===============================================================================
Func _GetMe()
    Local $json = Json_Decode(__HttpGet($URL & "/getMe"))
    If Not (Json_IsObject($json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ;Check if json is valid
    Local $data[3] = [Json_Get($json,'[result][id]'), _
                      Json_Get($json,'[result][username]'), _
                      Json_Get($json,'[result][first_name]')]
    Return $data
EndFunc ;==>_GetMe

#cs ===============================================================================
   Function Name..:     _SendMsg
   Description....:     Send a text message
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Text: Text of the message
                        $ParseMode (optional): Markdown/HTML (optional)- https://core.telegram.org/bots/api#sendmessage
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableWebPreview (optional): Disables link previews for links in this message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return the Message ID if no error encountered, False otherwise
#ce ===============================================================================
Func _SendMsg($ChatID,$Text,$ParseMode = Default,$ReplyMarkup = Default,$ReplyToMessage = '',$DisableWebPreview = False,$DisableNotification = False)
    Local $Query = $URL & "/sendMessage?chat_id=" & $ChatID & "&text=" & $Text
    If StringLower($ParseMode) = "markdown" Then $Query &= "&parse_mode=markdown"
    If StringLower($ParseMode) = "html" Then $Query &= "&parse_mode=html"
    If $DisableWebPreview = True Then $Query &= "&disable_web_page_preview=True"
    If $DisableNotification = True Then $Query &= "&disable_notification=True"
    If $ReplyToMessage <> '' Then $Query &= "&reply_to_message_id=" & $ReplyToMessage
    If $ReplyMarkup <> Default Then $Query &= "&reply_markup=" & $ReplyMarkup
    Local $Result = __HttpPost($Query)
    Local $Json = Json_Decode($Result)
    If Not (Json_IsObject($Json)) Then
        ConsoleWrite('! $Query = ' & $Query & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
        ConsoleWrite('! $result = ' & $Result & @CRLF )
        Return SetError($INVALID_JSON_RESPONSE,0,False) ;Check if json is valid
    EndIf
    If Not (Json_Get($Json,'[ok]') = 'true') Then
        ConsoleWrite('! $Query = ' & $Query & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
        ConsoleWrite('! $Result = ' & $Result & @CRLF )
        ConsoleWrite('! Description = ' & Json_Get($Json,'[description]') & @CRLF )
        Return SetError(2,0,False) ;Return false if send message faild
    EndIf
    Return Json_Get($Json,'[result][message_id]') ;Return message_id instead
EndFunc ;==> _SendMsg

#cs ===============================================================================
   Function Name..:     _ForwardMessage
   Description....:     Forward a message from a chat to another
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $OriginalChatID: Unique identifier for the chat where the original message was sent
                        $MsgID: Message identifier in the chat specified in from_chat_id
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return the new Message ID if no error encountered, False otherwise
#ce ===============================================================================
Func _ForwardMessage($ChatID,$OriginalChatID,$MsgID,$DisableNotification = False)
    Local $Query = $URL & "/forwardMessage?chat_id=" & $ChatID & "&from_chat_id=" & $OriginalChatID & "&message_id=" & $MsgID
    If $DisableNotification Then $Query &= "&disable_notification=True"
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ;Check if json is valid
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return Json_Get($Json,'[result][message_id]') ;Return message_id instead
EndFunc ;==> _ForwardMessage

#cs ===============================================================================
   Function Name..:     _SendPhoto
   Description....:     Send a photo
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Photo: Path to a local file, a File ID as string or an HTTP URL
                        $Caption (optional): Caption to send with photo
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return the File ID of the photo as string
#ce ===============================================================================
Func _SendPhoto($ChatID,$Photo,$Caption = '',$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & '/sendPhoto'
    Local $hOpen = _WinHttpOpen()
    Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
                  '<input type="text" name="chat_id"/>' & _
                  '<input type="file" name="photo"/>'   & _
                  '<input type="text" name="caption"/>'
    If $ReplyMarkup <> Default Then $Form &= '<input type="text" name="reply_markup"/>'
    If $ReplyToMessage <> '' Then $Query &= '<input type="text" name="reply_to_message_id"/>'
    If $DisableNotification Then $Form &= '<input type="text" name="disable_notification"/>'
    $Form &= '</form>'
    Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id", $ChatID, _
                       "name:photo"  , $Photo,   _
                       "name:caption", $Caption, _
                       "name:reply_markup", $ReplyMarkup, _
                       "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,'photo')
EndFunc ;==> _SendPhoto

#cs ===============================================================================
   Function Name..:     _SendAudio
   Description....:     Send an audio
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Audio: Path to a local file, a File ID as string or an HTTP URL
                        $Caption (optional): Caption to send with audio
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return the File ID of the audio as string
#ce ===============================================================================
Func _SendAudio($ChatID,$Audio,$Caption = '',$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & '/sendAudio'
    Local $hOpen = _WinHttpOpen()
    Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
                  '<input type="text" name="chat_id"/>' & _
                  '<input type="file" name="audio"/>'   & _
                  '<input type="text" name="caption"/>'
    If $ReplyMarkup <> Default Then $Form &= ' <input type="text" name="reply_markup"/>'
    If $ReplyToMessage <> '' Then $Query &= '<input type="text" name="reply_to_message_id"/>'
    If $DisableNotification Then $Form &= ' <input type="text" name="disable_notification"/>'
    $Form &= '</form>'
    Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id", $ChatID, _
                       "name:audio"  , $Audio,   _
                       "name:caption", $Caption, _
                       "name:reply_markup", $ReplyMarkup, _
                       "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,'audio')
EndFunc ;==> _SendAudio

#cs ===============================================================================
   Function Name..:     _SendDocument
   Description....:     Send a document
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Document: Path to a local file, a File ID as string or an HTTP URL
                        $Caption (optional): Caption to send with document
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return the File ID of the document as string
#ce ===============================================================================
Func _SendDocument($ChatID,$Document,$Caption = '',$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & '/sendDocument'
    Local $hOpen = _WinHttpOpen()
    Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
                  '<input type="text" name="chat_id"/>'  & _
                  '<input type="file" name="document"/>' & _
                  '<input type="text" name="caption"/>'
    If $ReplyMarkup <> Default Then $Form &= ' <input type="text" name="reply_markup"/>'
    If $ReplyToMessage <> '' Then $Query &= '<input type="text" name="reply_to_message_id"/>'
    If $DisableNotification Then $Form &= ' <input type="text" name="disable_notification"/>'
    $Form &= '</form>'
    Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id",  $ChatID, _
                       "name:document", $Document,   _
                       "name:caption",  $Caption, _
                       "name:reply_markup", $ReplyMarkup, _
                       "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,'document')
EndFunc ;==> _SendDocument

#cs ===============================================================================
   Function Name..:     _SendVideo
   Description....:     Send a video
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Video: Path to a local file, a File ID as string or an HTTP URL
                        $Caption (optional): Caption to send with video
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return the File ID of the video as string
#ce ===============================================================================
Func _SendVideo($ChatID,$Video,$Caption = '',$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & '/sendVideo'
    Local $hOpen = _WinHttpOpen()
    Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
                  '<input type="text" name="chat_id"/>' & _
                  '<input type="file" name="video"/>'   & _
                  '<input type="text" name="caption"/>'
    If $ReplyMarkup <> Default Then $Form &= ' <input type="text" name="reply_markup"/>'
    If $ReplyToMessage <> '' Then $Query &= '<input type="text" name="reply_to_message_id"/>'
    If $DisableNotification Then $Form &= ' <input type="text" name="disable_notification"/>'
    $Form &= '</form>'
    Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id", $ChatID, _
                       "name:video"  , $Video,   _
                       "name:caption", $Caption, _
                       "name:reply_markup", $ReplyMarkup, _
                       "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,'video')
EndFunc ;==> _SendVideo

#cs ===============================================================================
   Function Name..:     _SendAnimation
   Description....:     Send animation file (GIF or video without sound)
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Animation: Path to a local file, a File ID as string or an HTTP URL
                        $Caption (optional): Caption to send with;
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return the File ID of the video as string
#ce ===============================================================================
Func _SendAnimation($ChatID,$Animation,$Caption = '',$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & '/sendAnimation'
    Local $hOpen = _WinHttpOpen()
    Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
                  '<input type="text" name="chat_id"/>' & _
                  '<input type="file" name="animation"/>'   & _
                  '<input type="text" name="caption"/>'
    If $ReplyMarkup <> Default Then $Form &= ' <input type="text" name="reply_markup"/>'
    If $ReplyToMessage <> '' Then $Query &= '<input type="text" name="reply_to_message_id"/>'
    If $DisableNotification Then $Form &= ' <input type="text" name="disable_notification"/>'
    $Form &= '</form>'
    Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id", $ChatID, _
                       "name:animation", $Animation,   _
                       "name:caption", $Caption, _
                       "name:reply_markup", $ReplyMarkup, _
                       "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,'animation')
EndFunc ;==> _SendAnimation


#cs ===============================================================================
   Function Name..:     _SendVoice
   Description....:     Send a voice file
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Path: Path to a local file (format: .ogg)
                        $Caption (optional): Caption to send with voice
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return the File ID of the voice as string
#ce ===============================================================================
Func _SendVoice($ChatID,$Path,$Caption = '',$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & '/sendVoice'
    Local $hOpen = _WinHttpOpen()
    Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
                  '<input type="text" name="chat_id"/>' & _
                  '<input type="file" name="voice"/>'   & _
                  '<input type="text" name="caption"/>'
    If $ReplyMarkup <> Default Then $Form &= ' <input type="text" name="reply_markup"/>'
    If $ReplyToMessage <> '' Then $Query &= '<input type="text" name="reply_to_message_id"/>'
    If $DisableNotification Then $Form &= ' <input type="text" name="disable_notification"/>'
    $Form &= '</form>'
    Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id", $ChatID, _
                       "name:voice"  , $Path,   _
                       "name:caption", $Caption, _
                       "name:reply_markup", $ReplyMarkup, _
                       "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,'voice')
EndFunc ;==> _SendVoice

#cs ===============================================================================
   Function Name..:     _SendVideoNote
   Description....:     Send a voice file
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $VideoNote: Path to a local file, a File ID as string or an HTTP URL
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return the File ID of the videonote as string
#ce ===============================================================================
Func _SendVideoNote($ChatID,$VideoNote,$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & '/sendVideoNote'
    Local $hOpen = _WinHttpOpen()
    Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
                  '<input type="text" name="chat_id"/>' & _
                  '<input type="file" name="video_note"/>'
    If $ReplyMarkup <> Default Then $Form &= ' <input type="text" name="reply_markup"/>'
    If $ReplyToMessage <> '' Then $Query &= '<input type="text" name="reply_to_message_id"/>'
    If $DisableNotification Then $Form &= ' <input type="text" name="disable_notification"/>'
    $Form &= '</form>'
    Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id", $ChatID, _
                       "name:video_note"  , $VideoNote,   _
                       "name:reply_markup", $ReplyMarkup, _
                       "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,'videonote')
EndFunc ;==> _SendVideoNote

#cs ===============================================================================
   Function Name..:     _SendMediaGroup
   Description....:     Send a voice file
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Media: JSON-serialized array describing photos and videos to be sent, must include 2–10 items
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return an array with all File IDs of the medias sent
#ce ===============================================================================
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="mediagroup"/>'
    If $ReplyToMessage <> '' Then $Query &= '<input type="text" name="reply_to_message_id"/>'
    If $DisableNotification Then $Form &= ' <input type="text" name="disable_notification"/>'
    $Form &= '</form>'
    Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id", $ChatID, _
                       "name:media", $Media, _
                       "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

#cs ===============================================================================
   ; DEPRECATED?
   Function Name..:     _SendSticker
   Description....:     Send a sticker
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Path: Path to a local file (format: .webp)
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return the File ID of the sticker as string
#ce ===============================================================================
Func _SendSticker($ChatID,$Path,$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & '/sendSticker'
    Local $hOpen = _WinHttpOpen()
    Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
                  '<input type="text" name="chat_id"/>' & _
                  '<input type="file" name="sticker"/>'
    If $ReplyMarkup <> Default Then $Form &= ' <input type="text" name="reply_markup"/>'
    If $ReplyToMessage <> '' Then $Query &= '<input type="text" name="reply_to_message_id"/>'
    If $DisableNotification Then $Form &= ' <input type="text" name="disable_notification"/>'
    $Form &= '</form>'
   Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id", $ChatID, _
                       "name:sticker", $Path, _
                       "name:reply_markup", $ReplyMarkup, _
                       "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,'sticker')
EndFunc ;==> _SendSticker

#cs ===============================================================================
   Function Name..:     _SendLocation
   Description....:     Send a location object
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Latitude: Latitute of the location
                        $Longitude: Longitude of the location
                        $LivePeriod : Period in seconds for which the location will be updated, should be between 60 and 86400
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If the message is a reply, ID of the original message
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return True if no error encountered, False otherwise
#ce ===============================================================================
Func _SendLocation($ChatID,$Latitude,$Longitude,$LivePeriod = '',$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & "/sendLocation?chat_id=" & $ChatID & "&latitude=" & $Latitude & "&longitude=" & $Longitude
    If $LivePeriod <> '' Then $Query &= "&live_period=" & $LivePeriod
    If $ReplyMarkup <> Default Then $Query &= "&reply_markup=" & $ReplyMarkup
    If $ReplyToMessage <> '' Then $Query &= "&reply_to_message_id=" & $ReplyToMessage
    If $DisableNotification Then $Query &= "&disable_notification=true"
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _SendLocation

; TODO: Comments
Func _EditMessageLiveLocation($ChatID,$Latitude,$Longitude,$ReplyMarkup = Default)
    $Query = $URL & "/editMessageLiveLocation?chat_id=" & $ChatID & "&latitude=" & $Latitude & "&longitude=" & $Longitude
    If $ReplyMarkup <> Default Then $Query &= "&reply_markup=" & $ReplyMarkup
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc  ;==> _EditMessageLiveLocation

; TODO: Comments
Func _StopMessageLiveLocation($ChatID,$ReplyMarkup = Default)
    $Query = $URL & "/stopMessageLiveLocation?chat_id=" & $ChatID
    If $ReplyMarkup <> Default Then $Query &= "&reply_markup=" & $ReplyMarkup
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _StopMessageLiveLocation


;@TODO Comment
Func _SendVenue($ChatID,$Latitude,$Longitude,$Title,$Address,$Foursquare = '',$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & "/sendVenue?chat_id=" & $ChatID & "&latitude=" & $Latitude & "&longitude=" & $Longitude & "&title=" & $Title & "&address=" & $Address
    If $Foursquare <> '' Then $Query &= "&foursquare=" & $Foursquare
    If $ReplyMarkup <> Default Then $Query &= "&reply_markup=" & $ReplyMarkup
    If $ReplyToMessage <> '' Then $Query &= "&reply_to_message_id=" & $ReplyToMessage
    If $DisableNotification Then $Query &= "&disable_notification=true"
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _SendVenue

#cs ===============================================================================
   Function Name..:     _SendContact
   Description....:     Send a contact object
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Phone: Phone number of the contact;
                        $FirstName: First name of the contact;
                        $LastName (optional): Last name of the contact;
                        $ReplyMarkup (optional): Custom keyboard markup;
                        $ReplyToMessage (optional): If is a reply to another user's message;
                        $DisableNotification (optional): Sends the message silently. User will receive a notification with no sound
   Return Value(s):     Return True if no error encountered, False otherwise
#ce ===============================================================================
Func _SendContact($ChatID,$Phone,$FirstName,$LastName = '',$ReplyMarkup = Default,$ReplyToMessage = '',$DisableNotification = False)
    Local $Query = $URL & "/sendContact?chat_id=" & $ChatID & "&phone_number=" & $Phone & "&first_name=" & $FirstName
    If $LastName <> '' Then $Query &= "&last_name=" & $LastName
    If $ReplyMarkup <> Default Then $Query &= "&reply_markup=" & $ReplyMarkup
    If $ReplyToMessage <> '' Then $Query &= "&reply_to_message_id=" & $ReplyToMessage
    If $DisableNotification = True Then $Query &= "&disable_notification=True"
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _SendContact

; TODO: sendPoll

#cs ===============================================================================
   Function Name..:     _SendChatAction
   Description....:     tell the user that something is happening on the bot's side (Bot is typing...)
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Action: Type of the action:
                            typing for text messages,
                            upload_photo for photos,
                            record_video or upload_video for videos,
                            record_audio or upload_audio for audio files,
                            upload_document for general files,
                            find_location for location data,
                            record_video_note or upload_video_note for video notes.
   Return Value(s):     Return True if no error encountered, False otherwise
#ce ===============================================================================
Func _SendChatAction($ChatID,$Action)
    Local $Query = $URL & "/sendChatAction?chat_id=" & $ChatID & "&action=" & $Action
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _SendChatAction

#cs ===============================================================================
   Function Name..:     _GetUserProfilePhotos
   Description....:     Get (all) the profile pictures of an user
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
                        $Offset (optional): if you want a specific photo
                        $Limit (optional): if you want only an x number of photos ;@TODO
   Return Value(s):     Return an array with photo's count and File ID of the photos
#ce ===============================================================================
Func _GetUserProfilePhotos($ChatID,$Offset = '',$Limit = '')
    $Query = $URL & "/getUserProfilePhotos?user_id=" & $ChatID
    If $Offset <> '' Then $Query &= "&offset=" & $Offset
    If $Limit <> '' Then $Query &= "&limit=" & $Limit
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError(2,0,False)

    Local $count = Json_Get($Json,'[result][total_count]')

    If $Offset >= $count Then Return SetError($OFFSET_GRATER_THAN_TOTAL,0,False)

    If $Limit <> '' And $Limit < $count Then
        Local $photoArray[$Limit+1]
        $photoArray[0] = $Limit
    Else
        Local $photoArray[$count + 1]
        $photoArray[0] = $count
    EndIf

    For $i=1 to $photoArray[0]
        $photoArray[$i] = Json_Get($Json,'[result][photos]['& $i-1 &'][2][file_id]')
        If $photoArray[$i] == '' Then
            $photoArray[$i] = Json_Get($Json,'[result][photos]['& $i-1 &'][1][file_id]')
            If $photoArray[$i] == '' Then
                $photoArray[$i] = Json_Get($Json,'[result][photos]['& $i-1 &'][0][file_id]')
            EndIf
        EndIf
        ;A way like pythonic len([result][photos]) to know the lenght of this sub-array?
    Next

    Return $photoArray
EndFunc ;==> _GetUserProfilePhotos

; TODO: getFile


; TODO: comment
Func _KickChatMember($ChatID,$UserID,$UntilDate = '')
    $Query = $URL & "/kickChatMember?chat_id=" & $ChatID & "&user_id=" & $UserID
    If $UntilDate <> '' Then $Query &= "&until_date=" & $UntilDate
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _KickChatMember

; TODO: comment
Func _UnbanChatMember($ChatID,$UserID)
    $Query = $URL & "/unbanChatMember?chat_id=" & $ChatID & "&user_id=" & $UserID
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _UnbanChatMember

; TODO: restrictChatMember

; TODO: promoteChatMember

; TODO: setChatPermission

; TODO: comment
Func _ExportChatInviteLink($ChatID)
    $Query = $URL & "/exportChatInviteLink?chat_id=" & $ChatID
    Local $Json = Json_Decode(__HttpGet($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return Json_Get($Json,'[result]')
EndFunc ;==> _ExportChatInviteLink

; TODO: comment
Func _SetChatPhoto($ChatID,$Path)
    Local $Query = $URL & '/setChatPhoto'
    Local $hOpen = _WinHttpOpen()
    Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
                  '<input type="text" name="chat_id"/>' & _
                  '<input type="file" name="photo"/>'   & _
                  '</form>'
    Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id", $ChatID, _
                       "name:photo"  , $Path)
    _WinHttpCloseHandle($hOpen)
    Local $Json = Json_Decode($Response)
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _SetChatPhoto

; TODO: comment
Func _DeleteChatPhoto($ChatID)
    $Query = $URL & "/deleteChatPhoto?chat_id=" & $ChatID
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _DeleteChatPhoto

; TODO: comment
Func _SetChatTitle($ChatID,$Title)
    $Query = $URL & "/setChatTitle?chat_id=" & $ChatID & "&title=" & $Title
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _SetChatTitle

; TODO: comment
Func _SetChatDescription($ChatID,$Description)
    $Query = $URL & "/setChatDescription?chat_id=" & $ChatID & "&description=" & $Description
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _SetChatDescription

; TODO: comment
Func _PinChatMessage($ChatID,$MsgID,$DisableNotification = False)
    $Query = $URL & "/pinChatMessage?chat_id=" & $ChatID & "&message_id=" & $MsgID
    If $DisableNotification Then $Query &= "&disable_notification=true"
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _PinChatMessage

; TODO: comment
Func _UnpinChatMessage($ChatID)
    $Query = $URL & "/unpinChatMessage?chat_id=" & $ChatID
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _UnpinChatMessage

; TODO: comment
Func _LeaveChat($ChatID)
    $Query = $URL & "/leaveChat?chat_id=" & $ChatID
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _LeaveChat

#cs ===============================================================================
   Function Name..:     _GetChat
   Description....:     Get information about the specified chat, like username and id of the user, or group name for group chat
   Parameter(s)...:     $ChatID: Unique identifier for the target chat
   Return Value(s):     Return an array ;@TODO group support
#ce ===============================================================================
Func _GetChat($ChatID)
    Local $Query = $URL & "/getChat?chat_id=" & $ChatID
    Local $Json = Json_Decode(__HttpGet($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Local $chatData[4] = [ Json_Get($Json,'[result][id]'), _
                        Json_Get($Json,'[result][username]'), _
                        Json_Get($Json,'[result][first_name]'), _
                        Json_Get($Json,'[result][photo][big_file_id]')]
    Return $chatData
EndFunc ;==> _GetChat

; TODO: getChatAdministrators
Func _getChatAdministrators($ChatID)
    Local $Query = $URL & "/getChatAdministrators?chat_id=" & $ChatID
    ConsoleWrite(__HttpGet($Query))
EndFunc ;==> _getChatAdministrators

; TODO: getChatMembersCount
Func _getChatMembersCount($ChatID)
    Local $Query = $URL & "/getChatMembersCount?chat_id=" & $ChatID
    ConsoleWrite(__HttpGet($Query))
EndFunc ;==> _getChatMembersCount

; TODO: getchatmember
Func _getChatMember($ChatID)
    Local $Query = $URL & "/getChatMember?chat_id=" & $ChatID
    ConsoleWrite(__HttpGet($Query))
EndFunc ;==> _getChatMember

; TODO: sertchatstrickerset
Func _setChatStickerSet($ChatID)
    Local $Query = $URL & "/setChatStickerSet?chat_id=" & $ChatID
    ConsoleWrite(__HttpGet($Query))
EndFunc ;==> _setChatStickerSet

; TODO: deletechatstrickerset
Func _deleteChatStickerSet($ChatID)
    Local $Query = $URL & "/deleteChatStickerSet?chat_id=" & $ChatID
    ConsoleWrite(__HttpGet($Query))
EndFunc ;==> _deleteChatStickerSet

; TODO: comment
Func _answerCallbackQuery($CallbackID,$Text = '',$cbURL = '',$ShowAlert = False,$CacheTime = '')
    ;In Callback context, there's a URL validation/restriction on the Telegram side
    ;Telegram Docs: https://core.telegram.org/bots/api#answercallbackquery
    ;cbURL can be a Game's URL or something like "t.me/your_bot?start=XXXX"
    ;that open your bot with a parameter.
    Local $Query = $URL & "/answerCallbackQuery?callback_query_id=" & $CallbackID
    If $Text <> '' Then $Query &= "&text=" & $Text
    If $cbURL <> '' Then $Query &= "&url=" & $cbURL
    If $ShowAlert Then $Query &= "&show_alert=true"
    If $CacheTime <> '' Then $Query &= "&cache_time=" & $CacheTime
    Local $Json = Json_Decode(__HttpPost($Query))
    If Not (Json_IsObject($Json)) Then Return SetError($INVALID_JSON_RESPONSE,0,False) ; JSON Check
    If Not (Json_Get($Json,'[ok]') = 'true') Then Return SetError(2,0,False)
    Return True
EndFunc ;==> _answerCallbackQuery

; TODO: deletemessage
Func _deleteMessage($ChatID, $MsgID)
    Local $Query = $URL & "/deleteMessage?chat_id=" & $ChatID & "&message_id=" & $MsgID
    ConsoleWrite(__HttpGet($Query))
EndFunc ;==> _deleteMessage



; TODO: editmessagetext
; TODO: editmessagecaption
; TODO: editmessagemedia
; TODO: editmessagereplymarkup
; TODO: stoppoll
; TODO: sendsticker
; TODO: getsticketset
; TODO: uploadstickerfile
; TODO: createnewstickerset
; TODO: addstickertoset
; TODO: setstickerpositioninset
; TODO: deletestickerfromset
; TODO: Inline mode
; TODO: Payments mode
; TODO: Game mode
; TODO: Passport

#EndRegion

#Region "@EXTRA FUNCTIONS"

#cs ===============================================================================
   Function Name..:     _InitBot
   Description....:     Initialize the bot
   Parameter(s)...:     $Token: Bot's token (123456789:AbCdEf...)
   Return Value(s):     Return True if success, False otherwise
#ce ===============================================================================
Func _InitBot($Token)
    $TOKEN = $Token
    $URL  &= $TOKEN

    If IsArray(_GetMe()) Then
        Return True
    Else
        ;ConsoleWrite("Ops! Error: reason may be invalid token, webhook active, internet connection..." & @CRLF)
        Return SetError($INVALID_TOKEN_ERROR,0,False)
    EndIf

EndFunc ;==> _InitBot

#cs ===============================================================================
   Function Name..:     _Polling
   Description....:     Wait for incoming messages
   Parameter(s)...:     None
   Return Value(s):     Return an array with information about the messages
#ce ===============================================================================
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


#cs ===============================================================================
   Function Name..:     _CreateKeyboard
   Description....:     Create and return a custom keyboard markup
   Parameter(s)...:     $Keyboard: an array with the keyboard. Use an empty position for line break.
                            Example: Local $Keyboard[4] = ['Top Left','Top Right','','Second Row']
                        $Resize: Set true if you want to resize the buttons of the keyboard
                        $OneTime: Set true if you want to use the keyboard once
   Return Value(s):     Return custom markup as string, encoded in JSON
#ce ===============================================================================
Func _CreateKeyboard(ByRef $Keyboard,$Resize = False,$OneTime = False)
    ;reply_markup={"keyboard":[["Yes","No"],["Maybe"],["1","2","3"]],"one_time_keyboard":true,"resize_keyboard":true}
    Local $jsonKeyboard = '{"keyboard":['
    For $i=0 to UBound($Keyboard)-1
        If($Keyboard[$i] <> '') Then
            If(StringRight($jsonKeyboard,1) = '"') Then
                $jsonKeyboard &= ',"'&$Keyboard[$i]&'"'
            Else
                $jsonKeyboard &= '["'&$Keyboard[$i]&'"'
            EndIf
        Else
            $jsonKeyboard &= '],'
        EndIf
    Next
    $jsonKeyboard &= ']]'
    If $Resize = True Then $jsonKeyboard &= ',"resize_keyboard":true'
    If $OneTime = True Then $jsonKeyboard &= ',"one_time_keyboard":true'
    $jsonKeyboard &= '}'
    Return $jsonKeyboard
EndFunc ;==> _CreateKeyboard

#cs ===============================================================================
   Function Name..:     _CreateInlineKeyboard
   Description....:     Create and return a custom inline keyboard markup
   Parameter(s)...:     $Keyboard: an array with the keyboard. Use an empty position for line break.
                            Example: Local $InlineKeyboard[5] = ['Button1_Text','Button1_Data','','Button2_Text','Button2_Data']
   Return Value(s):     Return custom inline markup as string, encoded in JSON
#ce ===============================================================================
Func _CreateInlineKeyboard(ByRef $Keyboard)
    ;reply_markup={"inline_keyboard":[[['text':'Yes','callback_data':'pressed_yes'],['text':'No','callback_data':'pressed_no']]]}
    Local $jsonKeyboard = '{"inline_keyboard":[['
    For $i=0 to UBound($Keyboard)-1
        If($Keyboard[$i] <> '') Then
            If(StringRight($jsonKeyboard,2) = '[[') Then ;First button
                $jsonKeyboard &= '{"text":"' & $Keyboard[$i] & '",'
            ElseIf(StringRight($jsonKeyboard,2) = '",') Then ;CallbackData of a button
                $jsonKeyboard &= '"callback_data":"' & $Keyboard[$i] & '"}'
            ElseIf(StringRight($jsonKeyboard,2) = '"}') Then
                $jsonKeyboard &= ',{"text":"' & $Keyboard[$i] & '",'
            ElseIf(StringRight($jsonKeyboard,2) = '],') Then
                $jsonKeyboard &= '[{"text":"' & $Keyboard[$i] & '",'
            EndIf

        Else
            $jsonKeyboard &= '],'
        EndIf
    Next
    $jsonKeyboard &= ']]}'
    Return $jsonKeyboard
EndFunc


#EndRegion

#Region "@INTERNAL FUNCTIONS"

#cs ===============================================================================
   Function Name..:     __GetFileID
   Description....:     Get the 'File ID' of the last sent file
   Parameter(s)...:     $Json: JSON response from Telegram Server;
                        $type: File type, like photo, video, document...
   Return Value(s):     Return the File ID as a string
#ce ===============================================================================
Func __GetFileID(ByRef $Json,$type)

    ;If($type = 'photo') Then Return Json_Get($Json,'[result][photo][0][file_id]')
    If($type = 'photo') Then
      If(Json_Get($Json,'[result][photo][3][file_id]')) Then Return Json_Get($Json,'[result][photo][3][file_id]')
      If(Json_Get($Json,'[result][photo][2][file_id]')) Then Return Json_Get($Json,'[result][photo][2][file_id]')
      If(Json_Get($Json,'[result][photo][1][file_id]')) Then Return Json_Get($Json,'[result][photo][1][file_id]')
      If(Json_Get($Json,'[result][photo][0][file_id]')) Then Return Json_Get($Json,'[result][photo][0][file_id]')
    EndIf

    If($type = 'video') Then Return Json_Get($Json,'[result][animation][file_id]')
    If($type = 'audio') Then Return Json_Get($Json,'[result][audio][file_id]')
    If($type = 'document') Then Return Json_Get($Json,'[result][document][file_id]')
    If($type = 'voice') Then Return Json_Get($Json,'[result][voice][file_id]')
    If($type = 'sticker') Then Return Json_Get($Json,'[result][sticker][file_id]')
    If($type = 'videonote') Then Return Json_Get($Json,'[result][document][file_id]')
EndFunc ;==> __GetFileID

#cs ===============================================================================
   Function Name..:     __GetFilePath()
   Description....:     Get the path of a file on Telegram Server by its File ID
   Parameter(s)...:     $FileID: Unique identifier for the file
   Return Value(s):     Return the file path as a string
#ce ===============================================================================
Func __GetFilePath($FileID)
    Local $Query = $URL & "/getFile?file_id=" & $FileID
    Local $Json = Json_Decode(__HttpPost($Query))
    Return Json_Get($Json,'[result][file_path]')
EndFunc ;==> __GetFilePath

#cs ===============================================================================
   Function Name..:     __DownloadFile
   Description....:     Download and save a file from Telegram Server
   Parameter(s)...:     $filePath: Path of the file on Telegram Server (Get this from __GetFilePath)
   Return Value(s):     Return file name if success, False otherwise
#ce ===============================================================================
Func __DownloadFile($filePath)
    Local $fileName = StringSplit($filePath,'/')[2]
    Local $query = "https://api.telegram.org/file/bot" & $TOKEN & "/" & $filePath
    Local $result = InetGet($query,$fileName)
    If $result And Not @error And FileExists($fileName) Then
        Return $fileName
    Else
        Return SetError($FILE_NOT_DOWNLOADED,0,False)
    EndIf
EndFunc ;==> __DownloadFile

#cs ===============================================================================
   Function Name..:     __UrlEncode
   Description....:     Encode text in url format
   Parameter(s)...:     $string: Text to encode
   Return Value(s):     Return the encoded string
#ce ===============================================================================
Func __UrlEncode($string)
    $string = StringSplit($string, "")
    For $i=1 To $string[0]
        If AscW($string[$i]) < 48 Or AscW($string[$i]) > 122 Then
            $string[$i] = "%"&_StringToHex($string[$i])
        EndIf
    Next
    $string = _ArrayToString($string, "", 1)
    Return $string
EndFunc

#cs ===============================================================================
   Function Name..:     __MsgDecode
   Description....:     Decode message information from JSON string to an Array
   Parameter(s)...:     $Update: JSON Response from Telegram Server
   Return Value(s):     Return an array with information about a message (check docs)
#ce ===============================================================================
Func __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_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
    EndIf

EndFunc ;==> __MsgDecode

#EndRegion


#Region "@HTTP Request"
Func __HttpGet($sURL,$sData = '')
    Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
    $oHTTP.Open("GET",$sURL & "?" & $sData,False)
    If (@error) Then Return SetError(1,0,0)
    $oHTTP.Send()
    If (@error) Then Return SetError(2,0,0)
    If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3,0,0)
    Return SetError(0,0,$oHTTP.ResponseText)
EndFunc ;==> __HttpGet

Func __HttpPost($sURL,$sData = '')
    Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
    $oHTTP.Open("POST",$sURL,False)
    If (@error) Then Return SetError(1,0,0)
    $oHTTP.SetRequestHeader("Content-Type","application/x-www-form-urlencoded")
    $oHTTP.Send($sData)
    If (@error) Then Return SetError(2,0,0)
    If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3,0,$oHTTP.ResponseText)
    Return SetError(0,0,$oHTTP.ResponseText)
EndFunc ;==> __HttpPost
#EndRegion

It should give something like this when an error occurs:

@@ Debug(7) : $rc = True
>Error code: 0
! $Query = https://api.telegram.org/bot11111111:aaaaaaaaaaaaaaa/sendMessage?chat_id=-1111111111&text=This is a message .
>Error code: 0
! $Result = {"ok":false,"error_code":403,"description":"Forbidden: bot was kicked from the group chat"}
! Description = Forbidden: bot was kicked from the group chat
@@ Debug(9) : $rc = False
>Error code: 2

Jos

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.
  :)

Link to post
Share on other sites
  • 1 month later...

Sorry buy I cant understand how _CreateKeyboard() works.

Local $normalKeyboard[2] = ['Left','Right']
Local $normalMarkup = _CreateKeyboard($normalKeyboard)
_SendMsg($ChatID,"This is a message with a custom keyboard with one row and two buttons.",Default,$normalMarkup)

I want to do some function when the button Left or Right its pushed, but it only send a text... 

Edited by keteflips
Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By p4sCh
      Hello everyone,
      I've created a UDF for basic communication with SSH servers. I know there is already such a UDF, but I wasn't satisfied with it for my purpose, so I created a new one.
      This UDF also acts as a wrapper for the plink executable. Its essential functions are _SSHConnect, _SSHSend, _SSHRecv and _SSHCloseSocket.
      It does support multiple simultaneous connections and aims to be pretty robust. Feel free to share your opinions
      Two of the included examples use a slightly modified version of Vintage Terminal by @Chimp
      Download
      The download includes ssh.au3 (UDF), plink.exe (necessary), vintage terminal and code examples:
      Version 1.0.1
      - fixed rare _SSHConnect bug where "ssh-host-key prompt" was not answered
      SSH UDF 1.0.1.zip
       
    • By water
      I have started to rewrite the PowerPoint UDF similar to the Word, Excel and Outlook UDF. The new UDF will not be compatible with the existing one.
      I will add examples, documentation, a section in the wiki etc.
      So far the following functions have been coded - more are on the ToDo list.
      _PPT_Open: Open a connection to a running instance of PowerPoint or start a new one _PPT_Close: Close a PowerPoint instance _PPT_CommentAdd: Add a Comment anywhere on a Slide or connected to a Shape (version 1.5.0.0 2021-08-31) _PPT_CommentDelete: Delete a single Comment from a Slide or all Comments from a SlideRange (version 1.5.0.0 2021-08-31) _PPT_CommentList: Get a list of all Comments in a Presentation (version 1.5.0.0 2021-08-31) _PPT_ConvertUnits: Convert units (like centimeters) to other units (like points) (version 1.3.0.0 2021-08-17) _PPT_HeaderFooterList: Returns a list of Headers and Footers for a Presentation (version 1.1.0.0 2021-07-25, removed with version 1.4.0.0 2021-08-25) _PPT_HeaderFooterSet: Sets the Header/Footer for a Slide/Slides or the Slide-/Notes-/Handout-/Title-Master of the Presentation (version 1.2.0.0 2021-08-09) _PPT_PresentationAttach: Attach to an already opened Presentation _PPT_PresentationClose: Close a Presentation _PPT_PresentationExport: Export one/multiple/all Slides as PDF or XPS. _PPT_PresentationExportGraphic: Export one/multiple/all Slides in a graphic format. _PPT_PresentationList: Returns a list of currently open Presentations (version 1.0.0.0 2021-07-20) _PPT_PresentationNew: Create a new Presentation _PPT_PresentationOpen: Open an existing Presentation _PPT_Print: Print one/multiple/all Slides of a Presentation (version 1.0.0.0 2021-07-20) _PPT_PresentationSave: Save a Presentation _PPT_PresentationSaveAs: Save a Presentation to another location or with another type _PPT_ShapeAdd: Add a Shape to a single or multiple Slides (version 1.1.0.0 2021-07-25) _PPT_ShapeAlignDistribute: Aligns and distributes the Shapes in the specified ShapeRange (version 1.6.0.0 - to be released) _PPT_ShapeCopyMove: Copy/move a Shape(s) of a single Slide to a Slide(s) in the same or a different Presentation (version 1.1.0.0 2021-07-25) _PPT_ShapeDelete: Delete a Shape or Shapes from a single or multiple Slides (version 1.1.0.0 2021-07-25) _PPT_SlideAdd: Add slide(s) to a Presentation _PPT_SlideCopyMove: Copy, move, duplicate Slide(s) _PPT_SlideDelete: Delete Slide(s) _PPT_SlideShow: Show a Presentation _PPT_TableGet: Extract data from a PowerPoint Table Shape to an array (version 1.3.0.0 2021-08-17) _PPT_TableSet: Write data to a PowerPoint Table Shape (version 1.3.0.0 2021-08-17) _PPT_TextFindReplace: Find & replace text throughout entire PowerPoint presentation (version 1.0.0.0 2021-07-20) _PPT_TextSet: Sets/modifies the Text of a Shape or Shapes of a single or multiple Slides (version 1.2.0.0 2021-08-09 Which functions do you want me to add to the UDF?
      ToDo list:
      create slide (JLogan3o13) - Done: _PPT_SlideAdd Apply template to slide (JLogan3o13) - Done: _PPT_SlideAdd Apply theme to slide (JLogan3o13) Cut/Copy/Duplicate/Move/Delete slide(s) (JLogan3o13) - Done: _PPT_SlideCopyMove, _PPT_SlideDelete Export slides (JLogan3o13) - Done: _PPT_PresentationExport Cut/Copy/Duplicate/Move/Delete shape(s) (JLogan3o13): Done : _PPT_ShapeCopyMove, _PPT_ShapeDelete (version 1.1.0.0 2021-07-25) ApplyAnimation, Select, SetDefaultProperties, and zOrder for shape(s) (JLogan3o13) Searching and replacing text (pcjunki) - Done: _PPT_TextFindReplace (version 1.0.0.0 2021-07-20) Export slides in a graphic format (JPG, GIF, PNG ...) (UEZ) - Done: _PPT_PresentationExportGraphic The UDF can be downloaded from the download forum.
       
    • By seadoggie01
      This UDF is because I'm tired of trying to use UI Automation and Send to automate Adobe Acrobat. I often need to read the contents of PDFs and Acrobat is not easy to work with as a window.  The functions are based on the API Reference from Adobe located here.
      Acrobat Pro is required for all functions.
      It's very beta right now, but it still seems to work. Currently, the functions are based around page level manipulation of PDF documents: re-arranging, swapping, deleting, and moving pages as this is what I use the most.
      Please feel free to request/suggest features!
       
       
    • By DonChunior
      Introduction 
      In the course of my research for a project involving, among other things, the transfer of large amounts of data, I came across the BITS service and from that the idea for this UDF was born.
      For a brief overview, I'll quote from Microsoft's BITS website (https://docs.microsoft.com/en-us/windows/win32/bits/background-intelligent-transfer-service-portal).
      Availability 🛒
      The BITS UDF can be downloaded from my GitHub repository:
      🔗 https://github.com/DonChunior/BITS-UDF
      Comments 💬
      Currently, only an alpha version of the UDF is available.
      This contains by and large the full functionality of the object interfaces, but still completely lacks error checking and handling.
      I will implement this in the upcoming beta version.
      Therefore I ask you to use the UDF only for testing purposes but not in productive code!
      Acknowledgment 🤝
      Many thanks to @Nine and @Danyfirex.
      You helped me very well in solving some tricky problems.
    • By Hermes
      I have Index.html where it contains a frame with a source "frame1.html". I can select/highlight elements in index.html but unable to select/highlight elements inside the frame with the src "frame1.html", the autoit output is throwing error:
      __WD_Post: URL=HTTP://127.0.0.1:9515/session/2143396006437be4005db3b84acc1496/element/8be1c3c4-5bb1-42b1-8cde-7954765cbc61/element; $sData={"using":"css selector","value":"frameset:nth-of-type(1)"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\... __WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"css selector\",\"selector\":\"frameset:nth-of-type(1)\"}\n (Session info: chrome=90.0.4430.212)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00FCE7D3+124883]\n\tOrdinal0 [0x00FCE7B1+124849]\n\tGetHandleVerifier [0x01218688+193832]\n\tGetHandleVerifier [0x0123C478+340760]\n\tGetHandleVerifier [0x012361F1+315537]\n\tGetHandleVerifier [0x012516BA+427354]\n\tGetHandleVerifier [0x01236176+315414]\n\tGetHandleVerifier [0x0125174A+427498]\n\tGetHandleVerifier [0x0125D6EB+476555]\n\tGetHandleVerifier [0x0125154B+426987]\n\tGetHandleVerifier [0x01234FFD+310941]\n\tGetHandleVerifier [0x01235D8E+314414]\n\tGetHandleVerifier [0x01235D19+314297]\n\tGetHandleVerifier [0x012F31EC+1089676]\n\tGetHandleVerifier [0x012F17C9+1082985]\n\tGetHandleVerifier [0x012F13A3+1081923]\n\tGetHandleVerifier [0x013ED9FD+2115741]\n\tOrdinal0 [0x0111B82E+1488942]\n\tOrdinal0 [0x010B5A7D+1071741]\n\tOrdinal0 [0x010B559B+1070491]\n\tOrdinal0 [0x010B54B1+1070257]\n\tOrdinal0 [0x010EFF53+1310547]\n\tBaseThreadInitThunk [0x770662C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x776B1B69+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x776B1B34+1028]\n"}} Auto IT Script:
      #Include "wd_core.au3" #Include "wd_helper.au3" Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, 'index.html') _WD_LoadWait($sSession) Local $index = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frameset:nth-of-type(1)") Local $index1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frameset:nth-of-type(1)", $index) Local $index2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frame:nth-of-type(1)", $index1) Local $index3 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frameset:nth-of-type(1)", $index2) _WD_HighlightElement($sSession, $index2, 1) _WD_HighlightElement($sSession, $index3, 1) _WD_Shutdown() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome  

      frame1.html index.html
×
×
  • Create New...