-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
69 lines (51 loc) · 2.11 KB
/
test.py
File metadata and controls
69 lines (51 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import time
import requests
BOT_TOKEN = "8462330971:AAHZnyVKagOHvKsPlIoNYfk6_F_eptYE8aU"
CHAT_ID = "1857022853"
def send_telegram(message):
print(f"🚀 TELEGRAM GÖNDERİLİYOR: {message}")
try:
url = f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage"
data = {"chat_id": CHAT_ID, "text": message}
requests.post(url, data=data, timeout=5)
print("✅ Mesaj Başarıyla İletildi!")
except Exception as e:
print(f"❌ Mesaj Gönderilemedi: {e}")
print("=================================================")
print("📢 HIZLI TEST MODU (SAYAÇ GÖSTERGELİ)")
print("1 = Sinyal Var (Lock)")
print("0 = Sinyal Yok (Unlock - Hata)")
print("=================================================")
# Başlangıç testi
send_telegram("🛠 TEST START: StreamGuard Alarm System")
last_state_ok = True
fail_counter = 0
# Test için limiti 3 yapıyoruz.
# (Gerçek hayatta bunu 3-5 arası tutmak iyidir)
ALARM_LIMITI = 3
while True:
print("\n-------------------------------------------------")
user_input = input(f"Durum Gir (1 veya 0): ")
# Simüle edilen durum
durum = "1" if user_input == "1" else "0"
if durum == "1":
# --- SİNYAL VAR ---
print("🟢 SİNYAL VAR (LOCKED)")
fail_counter = 0 # Sayacı sıfırla
if not last_state_ok:
print("🎉 Düzelme Tespit Edildi! Mesaj atılıyor...")
send_telegram("✅ DÜZELDİ: Yayın geri geldi.")
last_state_ok = True
else:
# --- SİNYAL YOK ---
fail_counter += 1
print(f"🔴 SİNYAL YOK! (Sayaç: {fail_counter} / {ALARM_LIMITI})")
if fail_counter == ALARM_LIMITI and last_state_ok:
print("🚨 !!! ALARM LİMİTİNE ULAŞILDI !!! 🚨")
send_telegram("🚨 ALERT: StreamGuard Detected Signal Loss!")
last_state_ok = False
elif fail_counter < ALARM_LIMITI:
print(f"⏳ Sabret... {ALARM_LIMITI - fail_counter} kez daha hata gelirse mesaj atacağım.")
else:
print("💤 Zaten mesaj attım, hala sinyal yok. Tekrar atmıyorum.")
time.sleep(0.5)