Leaderboard
Popular Content
Showing content with the highest reputation on 12/22/2022 in all areas
-
Local $iValFull = 0x12345678 Local $iVal1 = BitShift($iValFull,16) Local $iVal2 = BitAND($iValFull,0xffff) ; Display split in both hex and decimal formats to confirm that we end up with numeric values MsgBox(0, "Split Hex", _ "HEX: 0x" & Hex($iValFull) & " --> 0x" & Hex($iVal1, 4) & " and 0x" & Hex($iVal2, 4) & _ @CRLF & @CRLF & _ "DEC: " & $iValFull & " --> " & $iVal1 & " and " & $iVal2)2 points
-
Telegram Bot UDF
noellarkin reacted to Jos for a topic
Try replacing func __MsgDecode() with this version first as that will likely solve it for you: 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_channel_post][message_id]'), _ ;[1] = Message ID Json_Get($json, '[result][0][edited_channel_post][from][id]'), _ ;[2] = Chat ID Json_Get($json, '[result][0][edited_channel_post][from][username]'), _ ;[3] = Username Json_Get($json, '[result][0][edited_channel_post][from][first_name]') _ ;[4] = Firstname ] If (Json_Get($json, '[result][0][edited_channel_post][text]')) Then $msgData[5] = Json_Get($json, '[result][0][edited_channel_post][text]') ;[5] = Text (eventually) ;Insert media recognition here Return $msgData ;@EDITED CHANNEL CHAT MESSAGE ElseIf (Json_Get($json, '[result][0][my_chat_member][chat][type]') = 'group') Then Local $msgData[10] = [ _ Json_Get($json, '[result][0][update_id]'), _ ;[0] = Offset Json_Get($json, '[result][0][my_chat_member][message_id]'), _ ;[1] = Message ID Json_Get($json, '[result][0][my_chat_member][from][id]'), _ ;[2] = Chat ID Json_Get($json, '[result][0][my_chat_member][from][username]'), _ ;[3] = Username Json_Get($json, '[result][0][my_chat_member][from][first_name]') _ ;[4] = Firstname ] $msgData[5] = "" If (Json_Get($json, '[result][0][my_chat_member][text]')) Then $msgData[5] = Json_Get($json, '[result][0][my_chat_member][text]') ;[5] = Text (eventually) ;Insert media recognition here Return $msgData EndIf EndFunc ;==>__MsgDecode Looks to me you need to add that Curl UDF which is linked in that post. The Telegram.au3 in that version looks somewhat more ridged1 point -
Telegram Bot UDF
noellarkin reacted to Jos for a topic
Thanks... I had a play with your received data and the issue is with the first message which isn't properly handled by this UDF, so gets stuck there. This also explains why the posted work-around is fixing it as long as there isn't another message of that type. Guess this needs to be fixed by the original owner of the UDF so you best report it at the GITHUB. .. and the quick fix should be those 4 steps you earlier quoted, as that should skip this messages.1 point -
Pal, Peter's AutoIt functions Library
ioa747 reacted to PeterVerbeek for a topic
This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.29 contains 231 functions divided into these topics: window, desktop and monitor GUI, mouse and color GUI controls including graphical buttons (jpg, png) GUI numberbox controls for integer, real, binary and hexadecimal input logics and mathematics include constants string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info Change log and files section on the PAL website (SourceForge). A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension which is a user interface for the system-wide audio driver called Equalizer APO.1 point -
I might do something like this: 1) Retrieve file listing in Array 2) Append new column 3) Enumerate array and collect modified times 4) Sort array by modified times column 5) Remove modified times column from array #include <Array.au3> #include <File.au3> $sSourceDir = @ScriptDir ;Collect file list Local $aFileList = _FileListToArray($sSourceDir) ;Get file list count Local $iCount = $aFileList[0] ;Remove file list count from array _ArrayDelete($aFileList,0) ;Insert nw column to hold modified times _ArrayColInsert($aFileList,1) ;Enumerate modified time For $iFile = 0 to $iCount -1 $aFileList[$iFile][1] = FileGetTime($sSourceDir & "\" & $aFileList[$iFile][0],$FT_MODIFIED,$FT_STRING) Next ;Sort array by modified times _ArraySort($aFileList,0,0,0,1) ;Remove modified times column from array _ArrayColDelete($aFileList,1) _ArrayDisplay($aFileList) Of course, you could write a function to parse the folder names and convert them to a date, which you could then sort. But if the modified times are accurate and should always be, this (above) might work.1 point