telegram-udf-autoit
telegram-udf-autoit copied to clipboard
I get an error when starting the UDF
I have a problem with _Polling
, I tried to fix this error myself, but it didn't work, although when I downloaded your UDF everything worked, but after about 15 minutes, when I wanted to run the Autoit script again, I started getting an error
$OFFSET = $msgData[0] + 1
$OFFSET = $msgData^ ERROR
I tried to take the code that you show for example
While 1 ;Create a While that restart Polling
$msgData = _Polling() ;_Polling function return an array with information about a message
_SendMsg($msgData[2],$msgData[5]) ;Send a message to the same user with the same text
WEnd
but still this error comes out
"C:\Users\staso\Desktop\New folder (7)\src\Telegram.au3" (794) : ==> Subscript used on non-accessible variable.:
$OFFSET = $msgData[0] + 1
$OFFSET = $msgData^ ERROR
>Exit code: 1 Time: 2.255
Maybe I made a error, here is my code:
#include <src/Telegram.au3>
_InitBot('1907...:AAEjer1ifIkv_...')
_SendMsg("...", "Hello")
While 1
$msgData = _Polling()
_SendMsg($msgData[2], $msgData[5])
WEnd
The bot token is correctly specified in the code itself, since _SendMsg
works
I have seen this behavior when the bot is a member of a group or channel.
Hi, I've recently rewritten the library almost from scratch, and fixed this unexpected behavior. This occurred because the old __MsgDecode
function attempted to extract all the significant information from Telegram's response, and stored it in an array. However, not all possible situations were foreseen, hence the error. Now, the _Telegram_Polling
function returns the response as-is, exactly as returned by Telegram (or almost, the body of the result
field is returned). Consequently, it is no longer necessary to distinguish the various cases, but it is up to the programmer to recover the information from the JSON.