discordbot / pingpong.py
joytou's picture
Upload 3 files
9cf96c4 verified
raw
history blame
759 Bytes
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()