Spaces:
Sleeping
Sleeping
File size: 1,318 Bytes
108aace 3b89d2d 108aace | 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 |
import asyncio
import httpx
from dotenv import load_dotenv
import os
load_dotenv() # Load from .env
# Token provided by user
TOKEN = "7734361434:AAGGKvlHN6BaND61F1Lr-0TQiBPsRWdmrRo"
APP_URL = "https://microfunnel-production.up.railway.app"
async def register_webhook():
token = TOKEN
if not token:
print("โ Token not found in settings!")
return
# User's Railway domain from webhook.py logic usually
# But here we hardcode the known production domain or ask user?
# Based on verify_webhook_status call in logs: https://microfunnel-production.up.railway.app
# Let's use that.
webhook_url = f"{APP_URL}/api/v1/webhook/telegram/global"
print(f"๐ Registering webhook for token {token[:5]}... to {webhook_url}")
async with httpx.AsyncClient() as client:
# 1. Delete
# await client.get(f"https://api.telegram.org/bot{token}/deleteWebhook")
# 2. Set
res = await client.post(
f"https://api.telegram.org/bot{token}/setWebhook",
json={
"url": webhook_url,
"allowed_updates": ["message", "my_chat_member", "channel_post"]
}
)
print(f"๐ก Response: {res.json()}")
if __name__ == "__main__":
asyncio.run(register_webhook())
|