measmonysuon commited on
Commit
8b383f4
·
verified ·
1 Parent(s): c538ed4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -1,25 +1,20 @@
1
- from flask import Flask, request
2
- import telebot
3
  import os
4
- import requests
5
  import google.generativeai as genai
6
- import tempfile
7
  import logging
8
- import re
9
- from telebot.apihelper import ApiTelegramException
10
- import time
11
  from huggingface_hub import webhook_endpoint, WebhookPayload
12
  from gradio import Interface
13
 
14
- # Replace with your actual API keys and bot token
15
  GOOGLE_API_KEY = 'AIzaSyAYXUMnwmR4nUGDCs97FJJsafcQAPAAuzE'
16
  BOT_TOKEN = '7484321656:AAFaswxTqaSHu_s4jd_pk2Q2OJJWYcWHwAM'
17
- WEBHOOK_URL = f"https://measmonysuon-flyingbird.hf.space/webhooks/handle_update"
 
18
 
19
  # Initialize the Telegram bot
20
  bot = telebot.TeleBot(BOT_TOKEN)
21
 
22
-
23
  # Configure logging
24
  logging.basicConfig(
25
  level=logging.DEBUG,
@@ -76,7 +71,7 @@ def set_telegram_webhook():
76
  except requests.exceptions.RequestException as e:
77
  logger.error(f"Request exception: {e}")
78
 
79
- @webhook_endpoint
80
  async def handle_update(payload: WebhookPayload) -> None:
81
  """Handles incoming updates from Telegram."""
82
  if payload.message:
 
 
 
1
  import os
2
+ import telebot
3
  import google.generativeai as genai
 
4
  import logging
5
+ import requests
 
 
6
  from huggingface_hub import webhook_endpoint, WebhookPayload
7
  from gradio import Interface
8
 
9
+ # Configuration
10
  GOOGLE_API_KEY = 'AIzaSyAYXUMnwmR4nUGDCs97FJJsafcQAPAAuzE'
11
  BOT_TOKEN = '7484321656:AAFaswxTqaSHu_s4jd_pk2Q2OJJWYcWHwAM'
12
+ WEBHOOK_URL = f"https://measmonysuon-flyingbird.hf.space/webhooks/handle_update"
13
+ WEBHOOK_SECRET = 'Y@A169' # Define your webhook secret here
14
 
15
  # Initialize the Telegram bot
16
  bot = telebot.TeleBot(BOT_TOKEN)
17
 
 
18
  # Configure logging
19
  logging.basicConfig(
20
  level=logging.DEBUG,
 
71
  except requests.exceptions.RequestException as e:
72
  logger.error(f"Request exception: {e}")
73
 
74
+ @webhook_endpoint(webhook_secret=WEBHOOK_SECRET)
75
  async def handle_update(payload: WebhookPayload) -> None:
76
  """Handles incoming updates from Telegram."""
77
  if payload.message: