|
15 | 15 | from config import WEB_HOOK, PORT, BOT_TOKEN, update_first_buttons_message, buttons
|
16 | 16 |
|
17 | 17 | from telegram.constants import ChatAction
|
18 |
| -from telegram import BotCommand, InlineKeyboardMarkup, InlineQueryResultArticle, InputTextMessageContent |
| 18 | +from telegram import BotCommand, InlineKeyboardMarkup, InlineQueryResultArticle, InputTextMessageContent, Update |
19 | 19 | from telegram.ext import CommandHandler, MessageHandler, ApplicationBuilder, filters, CallbackQueryHandler, Application, AIORateLimiter, InlineQueryHandler
|
20 | 20 |
|
21 |
| - |
22 | 21 | logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
23 | 22 | logger = logging.getLogger()
|
24 | 23 |
|
@@ -578,6 +577,32 @@ async def post_init(application: Application) -> None:
|
578 | 577 | BotCommand('reset', 'Reset the bot'),
|
579 | 578 | ])
|
580 | 579 |
|
| 580 | +from http.server import BaseHTTPRequestHandler |
| 581 | +import json |
| 582 | +class handler(BaseHTTPRequestHandler): |
| 583 | + def do_POST(self): |
| 584 | + content_length = int(self.headers['Content-Length']) |
| 585 | + post_data = self.rfile.read(content_length).decode('utf-8') |
| 586 | + update = Update.de_json(json.loads(post_data), application.bot) |
| 587 | + |
| 588 | + async def process_update(update): |
| 589 | + await application.process_update(update) |
| 590 | + |
| 591 | + application.run_async(process_update(update)) |
| 592 | + |
| 593 | + self.send_response(200) |
| 594 | + self.end_headers() |
| 595 | + return |
| 596 | + |
| 597 | +# class handler(BaseHTTPRequestHandler): |
| 598 | +# def do_POST(self): |
| 599 | +# content_length = int(self.headers['Content-Length']) |
| 600 | +# post_data = self.rfile.read(content_length).decode('utf-8') |
| 601 | +# update = Update.de_json(json.loads(post_data), application.bot) |
| 602 | +# application.process_update(update) |
| 603 | +# self.send_response(200) |
| 604 | +# self.end_headers() |
| 605 | +# return |
581 | 606 | if __name__ == '__main__':
|
582 | 607 | time_out = 600
|
583 | 608 | application = (
|
|
0 commit comments