mirror of
https://github.com/furaihan/simple-mikrotik-script.git
synced 2025-07-16 09:34:31 +02:00
some additions
This commit is contained in:
parent
4c9d5621eb
commit
381e8cc1ac
2 changed files with 105 additions and 0 deletions
22
keep-bytes-on-reboot
Normal file
22
keep-bytes-on-reboot
Normal file
|
@ -0,0 +1,22 @@
|
|||
#UNFINISHED
|
||||
:local iface [/ip arp get number=[find where address=[/ip route get number=[find where dst-address="0.0.0.0/0" && active=yes ] gateway]] interface]
|
||||
:put $iface;
|
||||
:local tx;
|
||||
:local rx;
|
||||
:set tx [/interface get $iface tx-byte];
|
||||
:set rx [/interface get $iface rx-byte];
|
||||
:put $tx;
|
||||
:put $rx;
|
||||
:local reboot;
|
||||
:local CR [/file get rxdata.txt contents]
|
||||
:local checkerrx [/file get rxreeb.txt contents];
|
||||
:local checkertx [/file get txreeb.txt contents];
|
||||
:if ($CR > $rx) do={ :set reboot true;} else={ set reboot false;};
|
||||
:put $reboot;
|
||||
:if ($reboot = true) do={
|
||||
/file set rxdata.txt contents=($checkerrx + $rx);
|
||||
/file set txdata.txt contents=($checkertx + $tx);
|
||||
} else={
|
||||
/file set rxdata.txt contents=$rx;
|
||||
/file set txdata.txt contents=$tx;
|
||||
}
|
83
telegram-func.rsc
Normal file
83
telegram-func.rsc
Normal file
|
@ -0,0 +1,83 @@
|
|||
global telegram do={
|
||||
:local noParam $1
|
||||
:if ($noParam = "help") do-={
|
||||
|
||||
}
|
||||
:local botToken ("xxxxxxxx:xxxxXXXxxxXxXXXxxxXXxXXxXx")
|
||||
:local chatId 00000000
|
||||
:local url ("https://api.telegram.org/bot$botToken/")
|
||||
:local getid do={
|
||||
:local cur 0
|
||||
:local lkey [:len $key]
|
||||
:local res ""
|
||||
:local p
|
||||
|
||||
:if ([:len $block]>0) do={
|
||||
:set p [:find $text $block $cur]
|
||||
:if ([:type $p]="nil") do={
|
||||
:return $res
|
||||
}
|
||||
:set cur ($p+[:len $block]+2)
|
||||
}
|
||||
|
||||
:set p [:find $text $key $cur]
|
||||
:if ([:type $p] != "nil") do={
|
||||
:set cur ($p+lkey+2)
|
||||
:set p [:find $text "," $cur]
|
||||
:if ([:type $p]!="nil") do={
|
||||
if ([:pick $text $cur]="\"") do={:set res [:pick $text ($cur+1) ($p-1)]} else={:set res [:pick $text $cur $p]}
|
||||
}
|
||||
}
|
||||
:return $res
|
||||
}
|
||||
:local logAndPut do={
|
||||
:if ([:len $msg] > 0) do={
|
||||
:log warning message=$msg
|
||||
:put message=$msg
|
||||
}
|
||||
}
|
||||
:if ([:typeof $chatId] != "str") do={:set chatId ([:tostr $chatId])}
|
||||
:if (($type = "message") or ($type = "audio") or ($type = "editMessage") or (($type = "image") or ($type = "photo") or ($type = "picture")) ) do={
|
||||
:if ($type = "message") do={
|
||||
:set url ($url."sendMessage\?chat_id=$chatId&text=$text")
|
||||
:if ([:len $mode] > 0) do={set url ($url."&parse_mode=$mode")}
|
||||
:put $url
|
||||
/tool fetch url="$url" keep-result=no
|
||||
}
|
||||
:if ($type = "audio") do={
|
||||
:set url ($url."sendAudio\?chat_id=$chatId&audio=$mediaUrl")
|
||||
:if ([:len $text] > 0) do={:set url ($url."&caption=$text")}
|
||||
:if ([:len $mode] > 0) do={:set url ($url."&parse_mode=$mode")}
|
||||
:put $url
|
||||
/tool fetch url="$url" keep-result=no
|
||||
}
|
||||
:if (($type = "image") or ($type = "photo") or ($type = "picture")) do={
|
||||
:set url ($url."sendPhoto\?chat_id=$chatId&photo=$mediaUrl")
|
||||
:if ([:len $text] > 0) do={:set url ($url."&caption=$text")}
|
||||
:if ([:len $mode] > 0) do={:set url ($url."&parse_mode=$mode")}
|
||||
:put $url
|
||||
/tool fetch url="$url" keep-result=no
|
||||
}
|
||||
:if ($type = "editMessage") do={
|
||||
:local toBeEdited [:toarray $edit]
|
||||
:put $toBeEdited
|
||||
:set url ($url."sendMessage\?chat_id=$chatId&text=$text")
|
||||
:put $url
|
||||
:local send ([/tool fetch mode=https http-method=get url=$url as-value output=user ]->"data")
|
||||
:local msgid [$getid key="message_id" text=$send]
|
||||
:if ([:len $delay] > 0) do={:delay $delay;}
|
||||
:foreach index in=$toBeEdited do={
|
||||
:local editurl ("https://api.telegram.org/bot$botToken/editMessageText\?chat_id=$chatId&message_id=$msgid&text=$index")
|
||||
:put $editurl
|
||||
/tool fetch url=$editurl
|
||||
:if ([:len $delay] > 0) do={:delay $delay;}
|
||||
}
|
||||
}
|
||||
}
|
||||
:if (([:len $type] < 1) and ([:len $text] > 0)) do={
|
||||
:set url ($url."sendMessage\?chat_id=$chatId&text=$text")
|
||||
:if ([:len $mode] > 0) do={set url ($url."&parse_mode=$mode")}
|
||||
:put $url
|
||||
/tool fetch url="$url" keep-result=no
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue