Skip to content

Commit f1e6d56

Browse files
authored
Merge pull request #1 from S75XD/master github:S75XD
programming bot telegram (telegram.py) for send the status & edit ReadmeFile [:
2 parents f6c297b + a371967 commit f1e6d56

File tree

2 files changed

+46
-13
lines changed

2 files changed

+46
-13
lines changed

README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
1-
# **EN**
2-
### **Monitor servers working times**
1+
# EN
2+
### Monitor servers working times
33

4-
#### **Hello, simple Python project. It sends a ping request to the server or site and records the server's state and the date and time of the request was sent in its log file, and you can schedule its operating times using crontap**
5-
#### **Before starting, please do these commands**
4+
#### Hello, simple Python project. It sends a ping request to the server or site and records the server's state and the date and time of the request was sent in its log file or you can add your telegram bot using telegram.py, and you can schedule its operating times using crontap
5+
#### Before starting, please do these commands
66
pip3 install os
77
######
88
pip3 install datetime
9-
10-
#### **To add websites or servers IPs, go to the list.py file and enter the data in the form of an array**
9+
######
10+
pip3 install requests
11+
#### To add websites or servers IPs, go to the list.py file and enter the data in the form of an array
1112

1213
> Example: list = ['google.com1', 'twitter.com', '192.168.1.1']
1314
14-
#### **[Twitter: F14Commander](https://twitter.com/f14commander "Twitter: F14Commander")**
15+
#### [Twitter: F14Commander](https://twitter.com/f14commander "Twitter: F14Commander")
16+
#### [Telegram Bot Programmer: ](https://github.com/S75XD)
1517

16-
# **AR**
18+
# AR
1719

18-
### **مراقبة اوقات عمل الخوادم**
19-
### **يا هلا ، مشروع بايثون بسيط. يرسل ping إلى الخادم أو الموقع ويسجل حالة الخادم وتاريخ ارسال الطلب ووقته في ملف السجل الخاص به ، ويمكنك جدولة أوقات عمله باستخدام crontap**
20-
### **قبل البدء ، يرجى تنفيذ هذه الأوامر**
20+
### مراقبة اوقات عمل الخوادم
21+
### يا هلا ، مشروع بايثون بسيط. يرسل ping إلى الخادم أو الموقع ويسجل حالة الخادم وتاريخ ارسال الطلب ووقته في ملف السجل الخاص به او بإمكانك ربط السكربت مع بوت تيليقرام من خلال الملف الخاص به telegram.py ، ويمكنك جدولة أوقات عمله باستخدام crontap
22+
### قبل البدء ، يرجى تنفيذ هذه الأوامر
2123
pip3 install os
2224
######
2325
pip3 install datetime
24-
#### **لإضافة المواقع أو ايبيات الخوادم ، انتقل إلى ملف list.py وأدخل البيانات في شكل مصفوفة**
26+
######
27+
pip3 install requests
28+
#### لإضافة المواقع أو ايبيات الخوادم ، انتقل إلى ملف list.py وأدخل البيانات في شكل مصفوفة
2529
> مثال: list = ['google.com1', 'twitter.com', '192.168.1.1']
2630
27-
#### **[Twitter: F14Commander](https://twitter.com/f14commander "Twitter: F14Commander")**
31+
#### [Twitter: F14Commander](https://twitter.com/f14commander "Twitter: F14Commander")
32+
#### [مبرمج سكربت بوت التيليقرام:](https://github.com/S75XD)

telegram.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Programming By Sulaiman AL-Mohawis Twitter:f14commander Github:xF14x
2+
from os import system
3+
from list import list
4+
from datetime import datetime
5+
6+
date = datetime.now()
7+
8+
# Programming Bot
9+
# By SaLeH | insta @8_wvu | github @S75XD | Twitter @S75XD
10+
11+
import requests
12+
13+
def send(msg):
14+
ID = '' # [!] Your telegram id
15+
token = '' # [!] Token Your Bot
16+
17+
tl = (f'''https://api.telegram.org/bot{token}/sendMessage?chat_id={ID}&text={msg}''') # [?] Get msg
18+
re = requests.post(tl) # [?] post requests
19+
20+
# Check Server if up or down
21+
22+
for ping in list:
23+
response = system(f'ping -c 1 {ping}')
24+
25+
if response == 0:
26+
send(f'{ping} is up in {date}\n')
27+
else:
28+
send(f'{ping} is down in {date}\n')

0 commit comments

Comments
 (0)