first commit

This commit is contained in:
2023-10-18 13:41:12 +02:00
commit 70bc043600
5 changed files with 264 additions and 0 deletions

32
init.py Normal file
View File

@@ -0,0 +1,32 @@
import hek
from os.path import exists
import requests
from time import sleep
while True:
# get ip
ip = hek.ipstuff.myip(find="query")
# existe archivo con la antigua ip
file_exists = exists("old_ip.txt")
if not file_exists:
# lo crea
f = open("old_ip.txt", "a")
# escribe la palabra ip
f.write("ip")
f.close()
with open("old_ip.txt", "r") as f:
old_ip = f.readlines()[0].strip()
if ip != old_ip:
# son distintas
f = open("old_ip.txt", "w")
f.write(ip)
f.close()
# publica en telegram
res = requests.get(
"https://api.telegram.org/bot1636534751:AAH_0Mwsv8Dwk9Nd"
"CQhKyt_TA5uoaJhC_XE/sendMessage?chat_id=3058130&text="
"La nueva Ip para su Raspberry es: " + ip
)
sleep(5*60)