bandwidth test and telegram message

hi there;
my code 's some parts actually working, code does test bandwith but telegram message part is not working,
what am i missing?

thanx for your help




/interface pppoe-client monitor pppoe-out3 once do={

:if ($status != “connected”) do={
/interface pppoe-client remove pppoe-out3;

}


:if ($status = “connected”) do={
{



:local speedtest [/tool bandwidth-test 5.5.5.1 protocol=tcp user=isp@isp password=1234 direction=receive duration=5s as-value ] ;

:local MyFuncDataToMKbps do={
:local DataOriginal $1
:set DataOriginal ($DataOriginal / 1000)
:local Mbps ($DataOriginal / 1000 * 1000)
:local Kbps ($DataOriginal - $Mbps)
:set Mbps ($Mbps / 1000)

:return ($Mbps."M ".$Kbps.“K - bps”)
}

:local Rx [$MyFuncDataToMKbps ($speedtest->“rx-10-second-average”)]
:local Tx [$MyFuncDataToMKbps ($speedtest->“tx-10-second-average”)]
:local Time ([/system clock get date]." ".[/system clock get time])
:put “$Time | Rx: $Rx | Tx: $Tx”


:local DLMb [pick $Rx 0 [:find $Rx “M”]]
:if ($DLMb < 400) do={/tool fetch keep-result=no url="https://api.telegram.org/bot121934534975336:AAHVeHfIB1Z8o6tk6FbQfAT3pR-Ug34534534JdQIMs/sendMessage?chat_id=813083453453613&text=NIZAMIYE-LINK $Rx "}

}
}
}
}

I have not tested it, so it may still be wrong, but since you do not use code tags, or maybe not tab, you do not see when there is a start { and a stop }

Example

:if ($status = "connected") do={
{

This will fail.

Here is a re post wit code tags and tabs. (also without ; at end of line, not needed)

/interface pppoe-client monitor pppoe-out3 once do={

	:if ($status != "connected") do={
		/interface pppoe-client remove pppoe-out3
	}


	:if ($status = "connected") do={

		:local speedtest [/tool bandwidth-test 5.5.5.1 protocol=tcp user=isp@isp password=1234 direction=receive duration=5s as-value ]

		:local MyFuncDataToMKbps do={
			:local DataOriginal $1
			:set DataOriginal ($DataOriginal / 1000)
			:local Mbps ($DataOriginal / 1000 * 1000)
			:local Kbps ($DataOriginal - $Mbps)
			:set Mbps ($Mbps / 1000)

			:return ($Mbps."M ".$Kbps."K - bps")
		}

		:local Rx [$MyFuncDataToMKbps ($speedtest->"rx-10-second-average")]
		:local Tx [$MyFuncDataToMKbps ($speedtest->"tx-10-second-average")]
		:local Time ([/system clock get date]." ".[/system clock get time])
		:put "$Time | Rx: $Rx | Tx: $Tx"

		:local DLMb [pick $Rx 0 [:find $Rx "M"]]
		:if ($DLMb < 400) do={
			/tool fetch keep-result=no url="https://api.telegram.org/bot12193453497 ... AMIYE-LINK $Rx "
		}

	}
}

telegram part is still not working :frowning:


bandwitch test and telegram message

correct the title, please

thanx :slight_smile:

any help?

Only someone with telegram can help you,
sorry.

Why do you actually trying to FETCH, not to POST to API? i don’t see http-method=post in your tool fetch line.

And AFAIK TG API accepts only JSON, and i doubt you try to send JSON…