D
D
Dmitry2018-02-09 14:10:55
Mikrotik
Dmitry, 2018-02-09 14:10:55

Who can help me figure out the script for Mikrotik?

I can’t understand why the script doesn’t work like that, I’ve been fighting with it for 2 days already,
an example of a script

spoiler
:local MAC
:set $MAC XX:XX:XX:XX:XX
:local WIFI
:set $WIFI 0
:if ([/caps-man registration-table find mac-address=$MAC] != "" and $WIFI = 0) do={[/tool fetch url="https://api.telegram.org/botbotTOKEN/sendmessage?c..." keep-result=no] and [:set $WIFI 24]};
:if ([/caps-man registration-table find mac-address=$MAC] = "" and $WIFI != 0) do={[:set $WIFI ($WiFi-1)]};
:if ($WIFI=1) do={/tool fetch url="https://api.telegram.org/botTOKEN/sendmessage?chat..."};

I can’t find where I messed up, in theory, the script should check the poppy in the table, if it is there, then send 1 message to telegram, if there is nothing to send, if it appears, then send 1 message and the next should be sent only when it turns off, but now he only spamming about the fact that the poppy is online.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2018-02-09
@Zarom

The local variables in your case exist only while the script is running. In order for the variable not to be destroyed after the script is processed, create a global variable. In your case it should be
:global WIFI

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question