Update bot.py
Browse files
bot.py
CHANGED
|
@@ -42,7 +42,7 @@ if not WEBHOOK_DOMAIN:
|
|
| 42 |
# WEBHOOK_PATH = f"/{TOKEN}"
|
| 43 |
# Construct the full webhook URL (must be HTTPS as required by Telegram)
|
| 44 |
WEBHOOK_URL = f"https://{WEBHOOK_DOMAIN}" # {WEBHOOK_PATH}"
|
| 45 |
-
TELEGRAM_WEBHOOK = f"https://api.telegram.org/bot{TOKEN}/setwebhook"
|
| 46 |
|
| 47 |
|
| 48 |
# -------------------------
|
|
@@ -111,8 +111,10 @@ async def set_webhook():
|
|
| 111 |
bot_webhook = await bot.set_webhook(url=WEBHOOK_URL + TOKEN)
|
| 112 |
if bot_webhook:
|
| 113 |
logger.info(f"Webhook set successfully to: {WEBHOOK_URL}")
|
|
|
|
| 114 |
else:
|
| 115 |
logger.error("Failed to set webhook manually.")
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
# -------------------------
|
|
@@ -135,7 +137,7 @@ async def main():
|
|
| 135 |
await application.run_webhook(
|
| 136 |
listen="0.0.0.0", # Listen on all available interfaces
|
| 137 |
port=443, # Port to listen on
|
| 138 |
-
|
| 139 |
webhook_url=WEBHOOK_URL # The full webhook URL that Telegram will use to send updates
|
| 140 |
)
|
| 141 |
|
|
|
|
| 42 |
# WEBHOOK_PATH = f"/{TOKEN}"
|
| 43 |
# Construct the full webhook URL (must be HTTPS as required by Telegram)
|
| 44 |
WEBHOOK_URL = f"https://{WEBHOOK_DOMAIN}" # {WEBHOOK_PATH}"
|
| 45 |
+
TELEGRAM_WEBHOOK = f"https://api.telegram.org/bot{TOKEN}/setwebhook?url=https://{WEBHOOK_URL}"
|
| 46 |
|
| 47 |
|
| 48 |
# -------------------------
|
|
|
|
| 111 |
bot_webhook = await bot.set_webhook(url=WEBHOOK_URL + TOKEN)
|
| 112 |
if bot_webhook:
|
| 113 |
logger.info(f"Webhook set successfully to: {WEBHOOK_URL}")
|
| 114 |
+
print("bot webhook success")
|
| 115 |
else:
|
| 116 |
logger.error("Failed to set webhook manually.")
|
| 117 |
+
print("error setting bot webhook")
|
| 118 |
|
| 119 |
|
| 120 |
# -------------------------
|
|
|
|
| 137 |
await application.run_webhook(
|
| 138 |
listen="0.0.0.0", # Listen on all available interfaces
|
| 139 |
port=443, # Port to listen on
|
| 140 |
+
url_path=TELEGRAM_WEBHOOK, # The webhook path; here, we use the bot token
|
| 141 |
webhook_url=WEBHOOK_URL # The full webhook URL that Telegram will use to send updates
|
| 142 |
)
|
| 143 |
|