Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8877c1c

Browse files
Ping_Server_Script added
1 parent e5ae98a commit 8877c1c

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from twilio.rest import Client
2+
from telethon import TelegramClient
3+
import requests
4+
from telethon.tl.types import InputPeerChat
5+
from telethon.tl.functions.messages import ImportChatInviteRequest
6+
7+
# Define your API credentials
8+
api_id = #####
9+
api_hash = '######################'
10+
11+
# Twilio API credentials
12+
account_sid = '###############'
13+
auth_token = '################'
14+
twilio_client = Client(account_sid, auth_token)
15+
16+
# Telegram API client setup
17+
telegram_client = TelegramClient('session_name', api_id, api_hash)
18+
telegram_client.start()
19+
20+
def send_telegram_message(chat_id, message):
21+
chat = InputPeerChat(chat_id)
22+
telegram_client.send_message(chat, message)
23+
24+
def send_twilio_sms(to_phone_number, message):
25+
twilio_client.messages.create(to=to_phone_number, from_='##########', body=message)
26+
27+
def make_twilio_call(to_phone_number):
28+
twilio_client.calls.create(url='http://demo.twilio.com/docs/voice.xml', to=to_phone_number, from_='#############')
29+
30+
def check_sites(site_list, chat_id):
31+
for site in site_list:
32+
print(site)
33+
r = requests.head(site)
34+
if r.status_code == 200:
35+
message = site + " returned 200"
36+
send_telegram_message(chat_id, message)
37+
sms_message = "The " + site + " is not responding now"
38+
send_twilio_sms("#####", sms_message)
39+
make_twilio_call('############')
40+
else:
41+
message = "Oops " + site + " not available at the moment"
42+
send_telegram_message(chat_id, message)
43+
44+
if __name__ == '__main__':
45+
# Define the site list and chat ID here
46+
site_list = ['http://example.com', 'http://example2.com']
47+
chat_id = 123456789 # Replace with the actual chat ID
48+
check_sites(site_list, chat_id)

‎Ping_Server_Script/README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Ping_Server_Script
2+
3+
Short description of package/script
4+
5+
- This Script Was simple to setup
6+
- Need import requests
7+
8+
## Setup instructions
9+
10+
Just Need to Import requests then run the Ping_Server_Script.py file and for running python3 is must be installed!
11+
12+
## Detailed explanation of script, if needed
13+
14+
This Script Is Only for Ping_Server_Script use only!
15+
and for ping the server useful to know server is working are busy likethat!

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /