Улучшил форматирование
This commit is contained in:
parent
fc72734c40
commit
987caa7f73
10
sms2tg.py
10
sms2tg.py
@ -5,19 +5,19 @@ import sys, requests
|
|||||||
bot_token = "123456789:ABCdefghIJKlmnOPQrstuVWXYz"
|
bot_token = "123456789:ABCdefghIJKlmnOPQrstuVWXYz"
|
||||||
chat_id = "123456789"
|
chat_id = "123456789"
|
||||||
|
|
||||||
message = "Пришла новая SMS:\nОтправитель: " + sys.argv[1] + "\nТекст: " + sys.argv[2]
|
message = "Пришла SMS:\n\nОт: <b>" + sys.argv[1] + "</b>\nТекст: <code>" + sys.argv[2] + "</code>"
|
||||||
|
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
# Save message to log
|
# Save message to log
|
||||||
|
|
||||||
text_file = open("/var/log/sms", "a+")
|
# text_file = open("/var/log/sms", "a+")
|
||||||
text_file.write(message)
|
# text_file.write(message)
|
||||||
text_file.close()
|
# text_file.close()
|
||||||
|
|
||||||
# Send message
|
# Send message
|
||||||
|
|
||||||
req = requests.get("https://api.telegram.org/bot" + bot_token + "/sendMessage?chat_id=" + chat_id + "&text=" + message)
|
req = requests.get("https://api.telegram.org/bot" + bot_token + "/sendMessage?parse_mode=HTML&chat_id=" + chat_id + "&text=" + message)
|
||||||
if (req.status_code != 200):
|
if (req.status_code != 200):
|
||||||
print("Сообщение не отправлено! Статус код: " + str(req.status_code))
|
print("Сообщение не отправлено! Статус код: " + str(req.status_code))
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user