Community discussions

MikroTik App
 
User avatar
katem07
just joined
Topic Author
Posts: 17
Joined: Mon Apr 10, 2017 11:35 am
Location: SAR
Contact:

Basic Notifications System with Telegram

Sat Aug 18, 2018 4:15 pm

We are going to make a tiny notifications system using a telegram bot 8)
The point is to get server information be sent to telegram group , so u can be up2time with your server physical updates !

1-Firstly you have to create a telegram bot
2-Create a Telegram group and add your bot to it
3-Get the bot id
4-Get your group chat id
5-Replace values in the code (YourBotid and YourChatid)
6-Copy and Paste The Below code to a new script
7-schedule it as u like
Here is the code :D

Note : Copy it as it is >> Just Replace bot id and chat id <<
# NOTIFICATION SYSTEM JOB START 
#  COUNT HOTSPOT USER 
{
:local hsac [:len [/ip hotspot active find radius]];
/tool fetch "https://api.telegram.org/YourBotid/sendmessage?chat_id=-YourChatid&text=Current Hotspot Users is $hsac" keep-result=no;
};



# WAIT FOR COUTING
:delay 2;


# COUNT BROADBAND USER
{
:local ppac [:len [/ppp active find service=pppoe]];
/tool fetch "https://api.telegram.org/YourBotid/sendmessage?chat_id=-YourChatid&text=Current Broadband Users is $ppac" keep-result=no;
};


# WAIT FOR COUTING


:delay 2;

# SEND CURRENT SERVER  TEMPERATURE
:local systemTemp [:tonum [/system health get temperature]];
/tool fetch "https://api.telegram.org/YourBotid/sendmessage?chat_id=-YourChatid&text=Current Server Temperature is $systemTemp" keep-result=no;


# WAIT FOR SENDING

:delay 2;


# CALCULATE AND SEND CURRENT SERVER VOLTAGE


:global voltage [:tonum [/system health get voltage]];
:local emessage ("Current Server Voltage is  " . [:pick $voltage 0 2] . "." . [:pick $voltage 2 3])
/tool fetch "https://api.telegram.org/YourBotid/sendmessage?chat_id=-YourChatid&text=$emessage" keep-result=no;


# NOTIFICATION SYSTEM JOB END / Ahmed Mouselly
# E-Mail mr.ahmd07@gmail.com
# +90-531-855-34-59
let me know if u have any problem with it 8)
Last edited by katem07 on Sun Sep 08, 2019 7:29 pm, edited 2 times in total.
 
petertosh
Frequent Visitor
Frequent Visitor
Posts: 58
Joined: Wed Mar 21, 2018 9:42 am

Re: Basic Notifications System with Telegram

Wed Sep 19, 2018 12:14 pm

Just what I needed. Thanks a lot.
 
User avatar
katem07
just joined
Topic Author
Posts: 17
Joined: Mon Apr 10, 2017 11:35 am
Location: SAR
Contact:

Re: Basic Notifications System with Telegram

Mon Oct 01, 2018 8:58 pm

Just what I needed. Thanks a lot.
Don't mention it, yo.
 
thunder72
just joined
Posts: 2
Joined: Mon Mar 23, 2015 10:21 am

Re: Basic Notifications System with Telegram

Wed Dec 26, 2018 10:53 pm

Thanks for the great script, but how can I test it as I didn't received any notification in the group
Also for the bot id should I pot the token or the bot name

Sent from my SM-N9500 using Tapatalk

 
thunder72
just joined
Posts: 2
Joined: Mon Mar 23, 2015 10:21 am

Re: Basic Notifications System with Telegram

Thu Dec 27, 2018 12:18 am

Thanks for the great script, but I couldn’t make it work

By pasting the script in the terminal with small modification by adding \ befor ? It works and recived the result in tg group

But didn’t get any result when running the script from the webFig

Any suggestions
 
petertosh
Frequent Visitor
Frequent Visitor
Posts: 58
Joined: Wed Mar 21, 2018 9:42 am

Re: Basic Notifications System with Telegram

Fri Jan 18, 2019 9:00 pm

Hi,

I use this call:
/tool fetch url="https://api.telegram.org/YourBotid/sendmessage\?chat_id=YourChatid&text=MESSAGE" keep-result=no;>


And currently following policies: ftp,reboot,read,write,policy,test,password,sniff,sensitive

Maybe the policies are not set correctly in your case?

Who is online

Users browsing this forum: eldoncito2019 and 17 guests