Basic Notifications System with Telegram

We are going to make a tiny notifications system using a telegram bot :sunglasses:
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 :smiley:

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 :sunglasses:

Just what I needed. Thanks a lot.

Don’t mention it, yo.

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

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

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?