forked from nathanabay/bespo_notifications
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_bot.py
More file actions
27 lines (23 loc) · 985 Bytes
/
check_bot.py
File metadata and controls
27 lines (23 loc) · 985 Bytes
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
import frappe
from bespo_notifications.bespo_notifications.utils import get_bot_info, _get_proxies
import requests
import json
def run():
bots = frappe.get_all("Telegram Bot", pluck="name")
results = []
for b in bots:
info = get_bot_info(b)
if info and info.get("token"):
token = info["token"]
api_url = info.get("api_url") or "https://api.telegram.org/bot"
# Fetch proxy settings for this specific bot
proxies = _get_proxies(b)
try:
# Add timeout and proxy parameters
res = requests.get(f"{api_url}{token}/getWebhookInfo", timeout=10, proxies=proxies).json()
results.append({"bot": b, "info": res})
except Exception as e:
results.append({"bot": b, "error": str(e)})
print("-----DIAGNOSTICS-----")
print(json.dumps(results, indent=2))
print("---------------------")