Spaces:
Runtime error
Runtime error
| from datetime import datetime | |
| from threading import Timer | |
| import time | |
| import requests | |
| import os | |
| # ๆฏ้4ๅ้ๅ้ping | |
| def sendPingTask(): | |
| Timer(240, sendPing, ()).start() | |
| def sendPing(): | |
| print("sendPing") | |
| url = os.getenv("WEBHOOK_URL") | |
| headers = { | |
| "Content-Type": "application/json" | |
| } | |
| payload = { | |
| "content": "ping" | |
| } | |
| response = requests.post(url, json=payload, headers=headers) | |
| if response.status_code == 200 or response.status_code == 204: | |
| print("Message ping sent successfully") | |
| sendPingTask() | |
| else: | |
| print(f"Failed to send message ping: {response.status_code}") | |
| def run(): | |
| sendPingTask() | |
| sendPing() | |
| def pingpong(): | |
| print("Running pingpong") | |
| run() | |