Jump to content

LibCurl based Telegram UDF fork


Recommended Posts

 As promised I post the updated UDF when I had the time to finish it.
Please don't hesitate to report issues, i have made a few last minute changes that should not interfere but shit usually happens when you don't expect it.

I was doubting for a long while; Would I create a new topic or would I add it to the existing topic?

Two reasons I have chosen to create a new topic for it:
-The programming has been changed so drastically that you cannot incorporate this UDF into your existing projects that are based on the old WINHTTP UDF.
-Not just the fact that this UDF is curl based, but the given examples are demonstrating on many levels how you can apply the Curl UDF (including the mime adoption for media/file posting)  and something simple but not obvious: how to get the HTTP response code, also when authentication errors like 401/407 occur.

Because of the file-size of the libcurl DLL's, I cannot incorporate them into the zip archive so you have to download the libcurl library yourself from the libcurl.se site.

As said above, the script also has some optimized (script breaking!) changes regarding the update array that Telegram returned.

I know the earlier editions of the older UDF also used the curl executable, this edition uses libcurl instead: I had to test this on hardware and configuration certified environments, some of them are running specific windows environment that do not allow patching or updating/upgrading and won't be for quite a long time.
It is there where WINHTTP was really shortcoming without patching.
With libcurl, at least you can guarantee your production works out-of-the-box on X86 and X64 editions of windows without letting people to go through all kinds of pain by having to install KB updates or fixes and perhaps not getting any further afterall.

This version is now communicating with the security standards libcurl supports out of the box (no more unsecured plain text https queries)
Proxy connections are supported (with or without authentication), i have tested with Synology proxy server, mitm proxy software and a service provider proxy.
_getChatmember() has been added
_getChatAdministrators() has been added
_deleteMessage() has been added/altered to work
$TELEGRAM_DEBUG allows enabling two levels of verbosity and logging to an output file to allow you to get debug data
_UserPoll() routine support added -> You can build GUI components to process. Don't expect to build 60fps games, but at least you can interact with the GUI decently. (See adapted test.au3 how this works).

The _MsgDecode() function now returns a 2D array, rather than a 1D array (script breaking!) -> you need to process $msgData[$Record][$Field] instead of $msgData[$Field]
$msgData[$Record][$MESSAGE_ID] is prefixed with a two or three character type indicator: p_, g_, c_, ep_, eg_, ec_  (private, group, channel) (see relaybot.au3 how filtering works)

Binarycall has been altered: OnAutoit3ExitRegister has been removed. (Caused crash if you added your own onAutoitExitRegister callback function)
__BinaryCall_DoRelease() is called more often to prevent memory hogging and is added to _Telegram_Close() function
The full JSON array is now processed and resulting in this former mentioned 2D array. It saves multiple http queries for the same JSON array buffer if it is large. -> When bot is offline and multiple users were firing all kinds of commands and texts into the chat, group or channel during the bot's absence, Telegram is shoving down the whole history into the bot's throat for processing as soon as it gets online again. The larger the buffered data is, the longer it took to process and redownload before the buffer got released on the telegram server. In some cases I experienced a never-ending loop with the original UDF.


I have added the LGPL license text, however: i did *not* have had any answer from Luca regarding the proposed change so it is not effective currently even though I changed a lot of code.


Link to comment
Share on other sites

  • 2 months later...

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" when running Test.au3. Is there any way I can set the full path for the DLLs 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).

Link to comment
Share on other sites

Hey, so I've been using this, and it seems to work quite well :)

However, I would suggest you rename your global variables, many of them have extremely common names, like $URL, $TOKEN etc which may cause conflicts with scripts that have similarly named globals.
Personally I renamed some of the globals in your UDF,





Other than the cleaning up the Globals, it seems fine so far..thanks!

Link to comment
Share on other sites

  • 3 weeks later...
On 12/22/2022 at 2:32 PM, noellarkin said:

Thanks! I've been having some trouble with the original UDF, thought I'd try this out. Question: where should I put the libcurl.dll?
I'm running 64bit windows, so I downloaded the appropriate files from the libcurl site, but where should i put them?

They need either be somwhere in your %PATH% environment or in the executable's folder.

Link to comment
Share on other sites

  • 8 months later...

I couldn't send files or images using the existing UDF, so I came here to find your UDF.
It works so well and I am so grateful to you.
I hope this updated UDF becomes known to more users.

I have one question:
There is no problem if I use English characters in the _SendMsg function, but if I use Korean characters, it does not work.
  i) Works fine: _SendMsg($ChatID, "Hi!")
  ii) Not working: _SendMsg1($ChatID, "안녕!")

I'm not sure what the problem is. So, a temporary solution was applied by declaring and using the _SendMsg and __HttpPost functions separately in the existing UDF (@LinkOut).

Edited by sungmin0206
Link to comment
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.
  • Create New...