mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-08-14 15:08:39 +02:00
telegram-chat: use $ParseJson for all JSON
This commit is contained in:
parent
c0aab0fead
commit
73194b92cf
1 changed files with 1 additions and 2 deletions
|
@ -52,14 +52,13 @@ $WaitFullyConnected;
|
||||||
:set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
|
:set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
|
||||||
("https://api.telegram.org/bot" . $TelegramTokenId . "/getUpdates?offset=" . \
|
("https://api.telegram.org/bot" . $TelegramTokenId . "/getUpdates?offset=" . \
|
||||||
$TelegramChatOffset->0 . "&allowed_updates=%5B%22message%22%5D") as-value ]->"data");
|
$TelegramChatOffset->0 . "&allowed_updates=%5B%22message%22%5D") as-value ]->"data");
|
||||||
:set Data [ :pick $Data ([ :find $Data "[" ] + 1) ([ :len $Data ] - 2) ];
|
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 debug $0 ("Failed getting updates from Telegram.") true;
|
$LogPrintExit2 debug $0 ("Failed getting updates from Telegram.") true;
|
||||||
}
|
}
|
||||||
|
|
||||||
:local UpdateID 0;
|
:local UpdateID 0;
|
||||||
:local Uptime [ /system/resource/get uptime ];
|
:local Uptime [ /system/resource/get uptime ];
|
||||||
:foreach UpdateArray in=[ :toarray $Data ] do={
|
:foreach UpdateArray in=[ :toarray ([ $ParseJson $Data ]->"result") ] do={
|
||||||
:local Update [ $ParseJson $UpdateArray ];
|
:local Update [ $ParseJson $UpdateArray ];
|
||||||
:set UpdateID ($Update->"update_id");
|
:set UpdateID ($Update->"update_id");
|
||||||
:local Message [ $ParseJson ($Update->"message") ];
|
:local Message [ $ParseJson ($Update->"message") ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue