telegram-udf-autoit icon indicating copy to clipboard operation
telegram-udf-autoit copied to clipboard

I get an error when starting the UDF

Open eCxb3 opened this issue 3 years ago • 1 comments

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

eCxb3 avatar Aug 16 '21 13:08 eCxb3

I have seen this behavior when the bot is a member of a group or channel.

Some1OnLine avatar Nov 08 '21 02:11 Some1OnLine

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.

xLinkOut avatar May 15 '24 20:05 xLinkOut