-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from furaihan/modified
- mengeluarkan setiap script ke dalam versi teks agar bisa dibaca langsung tanpa harus melakukan import ke mikrotik - menambah fungsi lowercase `func_lowercase` - modifikasi perintah hotspot, menambahkan fungsi lowercase supaya jika ada parameter yang menggunakan huruf kapital tetap bisa terbaca (misalkan ada user yang mengetikkan `/hotspot SesSion CoUnT` maka akan bisa terbaca dan bot akan mengirimkan balasan) - menghapus `tg_cmd_start` dan `tg_cmd_hi` (penjelasan ada dibawah) - menambah alternative command pada tg_getUpdates, apabila user mengetikkan: `/hi`, `/start`, `/hai`, `/halo`, `/hello`, `/bantuan`. Maka, akan menjalankan script `tg_cmd_help`. Dengan kata lain `tg_cmd_help` juga menangani perintah perintah tersebut - berlaku juga pada `/hotspot`. Apabila user mengetikkan `/hs` maka akan diarahkan ke `tg_cmd_hotspot` - modifikasi tg_cmd_dhcp agar menggunakan fungsi lowercase dan menghapus parameter yang tidak perlu
- Loading branch information
Showing
20 changed files
with
894 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
######################################################### | ||
# Wrapper for /tools fetch | ||
# Input: | ||
# mode | ||
# upload=yes/no | ||
# user | ||
# password | ||
# address | ||
# host | ||
# httpdata | ||
# httpmethod | ||
# check-certificate | ||
# src-path | ||
# dst-path | ||
# ascii=yes/no | ||
# url | ||
# resfile | ||
|
||
:local res "fetchresult.txt" | ||
:if ([:len $resfile]>0) do={:set res $resfile} | ||
#:put $res | ||
|
||
:local cmd "/tool fetch" | ||
:if ([:len $mode]>0) do={:set cmd "$cmd mode=$mode"} | ||
:if ([:len $upload]>0) do={:set cmd "$cmd upload=$upload"} | ||
:if ([:len $user]>0) do={:set cmd "$cmd user=\"$user\""} | ||
:if ([:len $password]>0) do={:set cmd "$cmd password=\"$password\""} | ||
:if ([:len $address]>0) do={:set cmd "$cmd address=\"$address\""} | ||
:if ([:len $host]>0) do={:set cmd "$cmd host=\"$host\""} | ||
:if ([:len $"http-data"]>0) do={:set cmd "$cmd http-data=\"$"http-data"\""} | ||
:if ([:len $"http-method"]>0) do={:set cmd "$cmd http-method=\"$"http-method"\""} | ||
:if ([:len $"check-certificate"]>0) do={:set cmd "$cmd check-certificate=\"$"check-certificate"\""} | ||
:if ([:len $"src-path"]>0) do={:set cmd "$cmd src-path=\"$"src-path"\""} | ||
:if ([:len $"dst-path"]>0) do={:set cmd "$cmd dst-path=\"$"dst-path"\""} | ||
:if ([:len $ascii]>0) do={:set cmd "$cmd ascii=\"$ascii\""} | ||
:if ([:len $url]>0) do={:set cmd "$cmd url=\"$url\""} | ||
|
||
:put ">> $cmd" | ||
|
||
:global FETCHRESULT | ||
:set FETCHRESULT "none" | ||
|
||
:local script "\ | ||
:global FETCHRESULT;\ | ||
:do {\ | ||
$cmd;\ | ||
:set FETCHRESULT \"success\";\ | ||
} on-error={\ | ||
:set FETCHRESULT \"failed\";\ | ||
}\ | ||
" | ||
:execute script=$script file=$res | ||
:local cnt 0 | ||
#:put "$cnt -> $FETCHRESULT" | ||
:while ($cnt<100 and $FETCHRESULT="none") do={ | ||
:delay 1s | ||
:set $cnt ($cnt+1) | ||
#:put "$cnt -> $FETCHRESULT" | ||
} | ||
:local content [/file get [find name=$res] content] | ||
#:put $content | ||
if ($content~"finished") do={:return "success"} | ||
:return $FETCHRESULT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
local alphabet {"A"="a";"B"="b";"C"="c";"D"="d";"E"="e";"F"="f";"G"="g";"H"="h";"I"="i";"J"="j";"K"="k";"L"="l";"M"="m";"N"="n";"O"="o";"P"="p";"Q"="q";"R"="r";"S"="s";"T"="t";"U"="u";"V"="v";"X"="x";"Z"="z";"Y"="y";"W"="w"}; | ||
:local result | ||
:local character | ||
:for strings from=0 to=([:len $1] - 1) do={ | ||
:local single [:pick $1 $strings] | ||
:set character ($alphabet->$single) | ||
:if ([:typeof $character] = "str") do={set single $character} | ||
:set result ($result.$single) | ||
} | ||
:return $result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local reportBody "" | ||
|
||
:local deviceName [/system identity get name] | ||
:local deviceDate [/system clock get date] | ||
:local deviceTime [/system clock get time] | ||
:local hwModel [/system routerboard get model] | ||
:local rosVersion [/system package get system version] | ||
:local currentFirmware [/system routerboard get current-firmware] | ||
:local upgradeFirmware [/system routerboard get upgrade-firmware] | ||
|
||
|
||
:set reportBody ($reportBody . "Router Reboot Report for $deviceName%0A") | ||
:set reportBody ($reportBody . "Report generated on $deviceDate at $deviceTime%0A%0A") | ||
|
||
:set reportBody ($reportBody . "Hardware Model: $hwModel%0A") | ||
:set reportBody ($reportBody . "RouterOS Version: $rosVersion%0A") | ||
:set reportBody ($reportBody . "Current Firmware: $currentFirmware%0A") | ||
:set reportBody ($reportBody . "Upgrade Firmware: $upgradeFirmware") | ||
if ( $currentFirmware < $upgradeFirmware) do={ | ||
:set reportBody ($reportBody . "NOTE: You should upgrade the RouterBOARD firmware!%0A") | ||
} | ||
|
||
:set reportBody ($reportBody . "%0A%0A=== Critical Log Events ===%0A" ) | ||
|
||
:local x | ||
:local ts | ||
:local msg | ||
foreach i in=([/log find where topics~"critical"]) do={ | ||
:set $ts [/log get $i time] | ||
:set $msg [/log get $i message] | ||
:set $reportBody ($reportBody . $ts . " " . $msg . "%0A" ) | ||
} | ||
|
||
:set reportBody ($reportBody . "%0A=== end of report ===%0A") | ||
$send chat=$chatid text=$reportBody mode="Markdown" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:local hotspot [:len [/ip hotspot active find]] | ||
|
||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "Router ID:* $[/system identity get name] * %0A\ | ||
Uptime: _$[/system resource get uptime]_%0A\ | ||
CPU Load: _$[/system resource get cpu-load]%_%0A\ | ||
RAM: _$(([/system resource get total-memory]-[/system resource get free-memory])/(1024*1024))M/$([/system resource get total-memory]/(1024*1024))M_" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
:return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:local tolower [:parse [/system script get func_lowercase source]] | ||
|
||
|
||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local paramsLower [$tolower $params] | ||
:put $paramsLower | ||
|
||
:local getVendor false | ||
:if ($paramsLower = "lease") do={ | ||
local GetMacVendor do={ | ||
:do { | ||
return ([/tool fetch mode=https http-method=get url=("https://api.macvendors.com/".[:pick [:tostr $1] 0 8 ]) as-value output=user ]->"data") | ||
} on-error={ | ||
return "unknown vendor" | ||
} | ||
} | ||
:local text | ||
:local number (0) | ||
:set text ("Router ID: $[/system identity get value-name=name]") | ||
:foreach lease in=[/ip dhcp-server lease find] do={ | ||
:set number ($number + 1) | ||
set text ($text."====== \F0\9F\97\82 DHCP LEASE ($number) \F0\9F\97\82 ======%0A") | ||
:local addr [/ip dhcp-server lease get value-name=address $lease] | ||
:set text ($text."IP Address: $addr%0A") | ||
:local mac [/ip dhcp-server lease get value-name=mac-address $lease] | ||
:set text ($text."Mac Address: $mac%0A") | ||
:if ($getVendor = "true") do={ | ||
:local macvendor [$GetMacVendor $mac] | ||
:set text ($text."Mac Vendor: $macvendor%0A") | ||
} | ||
:local host [/ip dhcp-server lease get value-name=host-name $lease] | ||
:if ([:typeof $host] = "nil") do={set host ("Unknown Hostname")} | ||
:set text ($text."Hostname: $$host%0A") | ||
:local lastseen [/ip dhcp-server lease get value-name=last-seen $lease] | ||
:set text ($text."Uptime: $lastseen%0A") | ||
:local server [/ip dhcp-server lease get value-name=server $lease] | ||
:set text ($text."Server: $server%0A") | ||
} | ||
:set text ($text."=========== END REPORT ===========%0A") | ||
$send chat=$chatid text=("$text") mode="Markdown" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "All hotspots disabled" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
/ip hotspot disable lantai1 | ||
/ip hotspot disable lantai2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "All hotspots enabled" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
/ip hotspot enable lantai1 | ||
/ip hotspot enable lantai2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "Force Update DDNS" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
/ip cloud force-update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
|
||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "Router ID:* $[/system identity get name] * %0A\ | ||
==================%0A\ | ||
MENU TERSEDIA%0A\ | ||
==================%0A\ | ||
/help%0A\ | ||
/start%0A\ | ||
/cpu%0A\ | ||
/interface%0A\ | ||
- show%0A\ | ||
/hotspot%0A\ | ||
- session%0A\ | ||
> count%0A\ | ||
> showall%0A\ | ||
> deauth-by-user <username>%0A\ | ||
> deauth-by-mac <mac address>%0A\ | ||
> deauth-by-ip <ip>%0A\ | ||
- add <username> <password>%0A\ | ||
- delete <username>%0A\ | ||
- disable <username>%0A\ | ||
- enable <username>%0A\ | ||
- setprofile <username> <profile>%0A\ | ||
- change-password <username> <password>%0A\ | ||
/ping to <ip>%0A\ | ||
/public%0A\ | ||
/enablehotspot%0A\ | ||
/disablehotspot%0A\ | ||
/forceupdateddns%0A\ | ||
/reboot" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
:return true |
Oops, something went wrong.