Jump to content

lbsl

Active Members
  • Posts

    46
  • Joined

  • Last visited

Reputation Activity

  1. Like
    lbsl got a reaction from ValentinM in LibCurl based Telegram UDF fork   
    They need either be somwhere in your %PATH% environment or in the executable's folder.
  2. Like
    lbsl got a reaction from noellarkin in LibCurl based Telegram UDF fork   
    They need either be somwhere in your %PATH% environment or in the executable's folder.
  3. Like
    lbsl got a reaction from noellarkin in Telegram Bot UDF   
    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.
  4. Like
    lbsl reacted to noellarkin in LibCurl based Telegram UDF fork   
    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,
    $TOKEN ---> $TELEGRAM_CURRENT_TOKEN
    $URL ---> $TELEGRAM_API_URL
    $OFFSET ---> $TELEGRAM_OFFSET
    $PAUSETIMER ---> $TELEGRAM_PAUSETIMER
    Other than the cleaning up the Globals, it seems fine so far..thanks!
  5. Like
    lbsl got a reaction from Danyfirex in LibCurl based Telegram UDF fork   
    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.

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

    Changed
    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)

    Fixes
    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.
     
    telegram-udf-curl-autoit-master.zip
  6. Thanks
    lbsl got a reaction from argumentum in Curl UDF - libcurl with x64 support   
    I have added your functions into your Curl library and successfully cooked up some examples for Telegram:
    There is enough in that Telegram UDF to steal for your own examples.
     
  7. Like
    lbsl got a reaction from Beege in LibCurl based Telegram UDF fork   
    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.

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

    Changed
    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)

    Fixes
    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.
     
    telegram-udf-curl-autoit-master.zip
  8. Like
    lbsl got a reaction from mLipok in Curl UDF - libcurl with x64 support   
    I have added your functions into your Curl library and successfully cooked up some examples for Telegram:
    There is enough in that Telegram UDF to steal for your own examples.
     
  9. Like
    lbsl reacted to TheXman in A Non-Strict JSON UDF (JSMN)   
    Back when the issue regarding not being able to access keys that have periods in them was posted HERE on 9/18, I took a look at the issue and fixed my local copy.  Then, I saw the post HERE on 9/28 that had the same issue.  After mulling it over a bit, I decided to share my fix (attached below).  Even though there are other JSON UDF's available that do not have this issue, I decided that it was still important to offer a fix since this UDF lib is widely used and very fast when doing simple parsing.
    Of course one can access keys with periods in them by directly accessing the underlying dictionary, where the key/value pairs are actually stored.  However, that doesn't address being able to access & manipulate such keys, using dot-notation and bracket-notation, with the Json_Get() and Json_Put() functions.
    Only 4 lines in the most current version needed to be modified, 2 lines in Json_Get() and 2 lines in Json_Put().  I could go into a detailed analysis of the root cause(s) of the issue and why I chose to fix it the way I did, but I'm sure that most don't care.  All anyone really cares about is that it works.  😉  I left the Json_ObjGet() and Json_ObjExists() helper functions as-is.  Although those 2 helper functions are related to the issue, they are not needed for Json_Get() and Json_Put() to correctly traverse a mutli-level JSON notation that has special characters like slashes, spaces, brackets, and periods.
    The example script below shows keys with periods, spaces, brackets, and slashes, being created, accessed, and modified, using Json_Put() and Json_Get():
    #include <Constants.au3> ;~ #include "Json.au3" #include "Json(2022-09-18)_TheXman.au3" ;<== Modified json.au3 (only 4 lines updated) Const $JSON = _ '{' & _ ' "dual_engine": {' & _ ' "user_list_data_1": {' & _ ' "https://www.yahoo.com/": {' & _ ' "date_added": "13308840098237395",' & _ ' "engine": 2,' & _ ' "visits_after_expiration": 0' & _ ' }' & _ ' }' & _ ' },' & _ ' "VST.magic": "Test",' & _ ' "VST3.uid": [2229853791, 2455052834, 2533024787],' & _ ' "pluginName": "Omnisphere",' & _ ' "pluginVendor": "Spectrasonics"' & _ '}' json_example() Func json_example() Local $oJson ;Decode JSON into a dictionary object $oJson = Json_Decode($JSON) If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "JSON DECODE ERROR", "@error = " & @error) ;Pretty-print the original JSON log_line("=== Pretty-Printed JSON (original) ===") log_line(Json_Encode($oJson, $JSON_PRETTY_PRINT + $JSON_UNESCAPED_SLASHES, " ") & @CRLF) ;Update an existing key / Add some valid keys with spaces, slashes, and periods Json_Put($oJson, '.dual_engine.user_list_data_1."https://www.yahoo.com/".visits_after_expiration', 3) ;Update key's value to 3 Json_Put($oJson, '."//a.b.c//".". [.] ."', "Value of ridiculous but valid key (. [.] .)") ;Add key Json_Put($oJson, '."//a.b.c//"."/ /"' , "Value of another ridiculous but valid key (/ /)") ;Add key Json_Put($oJson, '."key with spaces"' , "Value of key with spaces") ;Add key Json_Put($oJson, '."lvl1.key"."lvl2.key1"."lvl3.key1"' , "Level 3 Key1") ;Add key using dot-notation Json_Put($oJson, '["lvl1.key"]["lvl2.key1"]["lvl3.key2"]', "Level 3 Key2") ;Add key using bracket-notation ;Pretty-print the updated JSON log_line("=== Pretty-Printed JSON (with keys updated/added) ===") log_line(Json_Encode($oJson, $JSON_PRETTY_PRINT + $JSON_UNESCAPED_SLASHES, " ") & @CRLF) ;Display some of the JSON values log_line('=== Display some JSON keys & values ===') log_line('."//a.b.c//".". [.] ." => ' & Json_Get($oJson, '."//a.b.c//".". [.] ."')) log_line('."//a.b.c//"."/ /" => ' & Json_Get($oJson, '."//a.b.c//"."/ /"')) log_line('."key with spaces" => ' & Json_Get($oJson, '."key with spaces"')) log_line() log_line('.dual_engine.user_list_data_1."https://www.yahoo.com/".date_added => ' & _ Json_Get($oJson, '.dual_engine.user_list_data_1."https://www.yahoo.com/".date_added')) log_line('[dual_engine][user_list_data_1]["https://www.yahoo.com/"][engine] => ' & _ Json_Get($oJson, '[dual_engine][user_list_data_1]["https://www.yahoo.com/"][engine]')) log_line('.dual_engine.user_list_data_1."https://www.yahoo.com/".visits_after_expiration => ' & _ Json_Get($oJson, '.dual_engine.user_list_data_1."https://www.yahoo.com/".visits_after_expiration')) log_line() log_line('."VST.magic" => ' & Json_Get($oJson, '."VST.magic"')) log_line('."VST3.uid"[0] => ' & Json_Get($oJson, '."VST3.uid"[0]')) log_line() log_line('."lvl1.key"."lvl2.key1"."lvl3.key1" => ' & Json_Get($oJson, '."lvl1.key"."lvl2.key1"."lvl3.key1"')) log_line('["lvl1.key"]["lvl2.key1"]["lvl3.key1"] => ' & Json_Get($oJson, '["lvl1.key"]["lvl2.key1"]["lvl3.key1"]')) EndFunc Func log_line($sMsg = "") ConsoleWrite($sMsg & @CRLF) EndFunc Console Output:
    === Pretty-Printed JSON (original) === { "dual_engine": { "user_list_data_1": { "https://www.yahoo.com/": { "date_added": "13308840098237395", "engine": 2, "visits_after_expiration": 0 } } }, "VST.magic": "Test", "VST3.uid": [ 2229853791, 2455052834, 2533024787 ], "pluginName": "Omnisphere", "pluginVendor": "Spectrasonics" } === Pretty-Printed JSON (with keys updated/added) === { "VST.magic": "Test", "VST3.uid": [ 2229853791, 2455052834, 2533024787 ], "pluginName": "Omnisphere", "pluginVendor": "Spectrasonics", "dual_engine": { "user_list_data_1": { "https://www.yahoo.com/": { "date_added": "13308840098237395", "engine": 2, "visits_after_expiration": 3 } } }, "//a.b.c//": { ". [.] .": "Value of ridiculous but valid key (. [.] .)", "/ /": "Value of another ridiculous but valid key (/ /)" }, "key with spaces": "Value of key with spaces", "lvl1.key": { "lvl2.key1": { "lvl3.key1": "Level 3 Key1", "lvl3.key2": "Level 3 Key2" } } } === Display some JSON keys & values === ."//a.b.c//".". [.] ." => Value of ridiculous but valid key (. [.] .) ."//a.b.c//"."/ /" => Value of another ridiculous but valid key (/ /) ."key with spaces" => Value of key with spaces .dual_engine.user_list_data_1."https://www.yahoo.com/".date_added => 13308840098237395 [dual_engine][user_list_data_1]["https://www.yahoo.com/"][engine] => 2 .dual_engine.user_list_data_1."https://www.yahoo.com/".visits_after_expiration => 3 ."VST.magic" => Test ."VST3.uid"[0] => 2229853791 ."lvl1.key"."lvl2.key1"."lvl3.key1" => Level 3 Key1 ["lvl1.key"]["lvl2.key1"]["lvl3.key1"] => Level 3 Key1  
     
    Json(2022-09-18)_TheXman.au3
  10. Like
    lbsl reacted to TheXman in A Non-Strict JSON UDF (JSMN)   
    @Mateocedillo
    I took a quick look at your _FakeYouGetVoicesList() function.  I'm not sure how long your functions takes on your test PC's but, I have written a function that creates the voices array in a little over half a second on my PC. My array includes all of the values in each model, just like your function.
    Output: Time to create array: 0.518 seconds Number of rows: 1941 Number of cols: 15 My script uses jq to create the array because I think it is better suited for this particular task.  Since I think discussing alternative solutions in detail, in someone else's topic is rude, I will not go into detail on how I did it here.  If you want to see suggestions on how it could be done using jq, then I would suggest that you create a new topic with any questions that you may have related to using jq.
    If you want to stick with the json.au3 UDF, then there are several ways to speed up your function.  Since none of these suggestions have anything to do with the json.au3 UDF itself, and the fact that your issues have nothing to do with the json.au3 functionality, I'm not sure that this is the right topic for a detailed discussion on how it could be done.  So without going into detail, I will just list a few items/questions for you to think about in  terms of speeding up that function:
    Do you really need an array at all?  Basically you are moving all of the data from one structured format (json/dictionary) that can be queried to another one (variant array), that seems totally unnecessary and time-consuming. Do you really need to have all of those values in your array?  If you don't need or use values like create_at/update_at/etc, why take the time to move them to a separate array? Working with arrays and strings are 2 of the slowest processes you can do in AutoIt.  The fewer execution of array and string functions you need to create your array, the faster that process will be.
  11. Like
    lbsl reacted to TheXman in A Non-Strict JSON UDF (JSMN)   
    Unfortunately, without a compelling reason, I have no intention of doing any pull requests or otherwise doing any of your scripting for you.  You're welcome anyway... 
    If you are interested in learning more about jq and how to use it, I may be willing to help you with that.
     
    If it takes your script 20-30 seconds to build your array using json.au3 functions and it only takes 0.5 seconds to build the same array using jq, then it might be worth taking the time to learn how to use jq.  JSMN (json.au3) is a great JSON parser.  jq is a great JSON processor. 
    Generating a tab-separated-value list of all of the data needed to build the array is done in a single function call to jq, which returns its result in well under 0.5 seconds (it took an additional 0.1 seconds to convert the TSV list to an array which came to a total elapsed time of just over 0.5 seconds).  Your current way is to loop through the 1900+ array objects, with each object containing 15 key/value pairs, doing over 29,000 json_get() calls in order to parse and put each individual value into your array.  I think it is pretty clear why your way takes considerably longer (20-30 seconds) to generate its result.
    This was an excellent example of the difference between JSON parsing and JSON processing.  It was also an excellent example of how using the right tool(s) for the job can make a HUGE difference!
  12. Like
    lbsl got a reaction from Earthshine in BDE database UDF structure   
    I have had a lot of fun using this one in the past to gain some similar C-learning idea:
    http://www.xbasic.org/
    Doesn't cost you a dime either and even allows you to compile DLL's unlike Autoit.
    I even created a compiler for it to incorporate the runtime library into your executable.
     
     
     
  13. Like
    lbsl got a reaction from Earthshine in BDE database UDF structure   
    I have no issue, using low-level reading techniques, it is just understanding the file structure itself.
    Adding ODBC commands also requires time investigation into the SQL language used by BDE and you need to have the BDE distribution kit installed and configured as well. I don' t see much time-difference in going either through that hoop or simply following some binary file structure.
    With the latter solution i'm forever independant of the sluggish BDE distribution kit (which in addition also comes packed with a lot of legal mambo jumbo issues).
     
×
×
  • Create New...