Skip to content

Commit

Permalink
💻 Code: test vercel deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
yym68686 committed May 10, 2024
1 parent 5143628 commit 767bb10
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
29 changes: 27 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
from config import WEB_HOOK, PORT, BOT_TOKEN, update_first_buttons_message, buttons

from telegram.constants import ChatAction
from telegram import BotCommand, InlineKeyboardMarkup, InlineQueryResultArticle, InputTextMessageContent
from telegram import BotCommand, InlineKeyboardMarkup, InlineQueryResultArticle, InputTextMessageContent, Update
from telegram.ext import CommandHandler, MessageHandler, ApplicationBuilder, filters, CallbackQueryHandler, Application, AIORateLimiter, InlineQueryHandler


logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
logger = logging.getLogger()

Expand Down Expand Up @@ -578,6 +577,32 @@ async def post_init(application: Application) -> None:
BotCommand('reset', 'Reset the bot'),
])

from http.server import BaseHTTPRequestHandler
import json
class handler(BaseHTTPRequestHandler):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
post_data = self.rfile.read(content_length).decode('utf-8')
update = Update.de_json(json.loads(post_data), application.bot)

async def process_update(update):
await application.process_update(update)

application.run_async(process_update(update))

self.send_response(200)
self.end_headers()
return

# class handler(BaseHTTPRequestHandler):
# def do_POST(self):
# content_length = int(self.headers['Content-Length'])
# post_data = self.rfile.read(content_length).decode('utf-8')
# update = Update.de_json(json.loads(post_data), application.bot)
# application.process_update(update)
# self.send_response(200)
# self.end_headers()
# return
if __name__ == '__main__':
time_out = 600
application = (
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ pytz
python-dotenv
md2tgmd==0.1.9
fake_useragent
ModelMerge==0.2.9
ModelMerge==0.3.0
oauth2client==3.0.0
python-telegram-bot[webhooks,rate-limiter]==21.0.1

0 comments on commit 767bb10

Please sign in to comment.