Update bot.py
Browse files
bot.py
CHANGED
|
@@ -494,10 +494,10 @@ async def cmd_get(update: Update, ctx: ContextTypes.DEFAULT_TYPE):
|
|
| 494 |
# ΨͺΨ΄ΨΊΩΩ Ψ§ΩΨ¨ΩΨͺ
|
| 495 |
# ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 496 |
|
| 497 |
-
def
|
| 498 |
-
|
|
|
|
| 499 |
|
| 500 |
-
# conversation handler ΩΩΨ¨ΨΨ« Ψ§ΩΨͺΩΨ§ΨΉΩΩ
|
| 501 |
conv = ConversationHandler(
|
| 502 |
entry_points=[CommandHandler("search", cmd_search)],
|
| 503 |
states={
|
|
@@ -511,15 +511,30 @@ def main():
|
|
| 511 |
],
|
| 512 |
},
|
| 513 |
fallbacks=[CommandHandler("cancel", cmd_cancel)],
|
|
|
|
| 514 |
)
|
| 515 |
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 521 |
print("β
Ψ§ΩΨ¨ΩΨͺ Ψ΄ΨΊΨ§Ω!")
|
| 522 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 523 |
|
| 524 |
if __name__ == "__main__":
|
| 525 |
main()
|
|
|
|
| 494 |
# ΨͺΨ΄ΨΊΩΩ Ψ§ΩΨ¨ΩΨͺ
|
| 495 |
# ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 496 |
|
| 497 |
+
def build_app():
|
| 498 |
+
"""Ψ¨ΩΨ§Ψ‘ Ψ§ΩΨͺΨ·Ψ¨ΩΩ ΩΩΨ· β Ψ¨Ψ―ΩΩ ΨͺΨ΄ΨΊΩΩ"""
|
| 499 |
+
application = ApplicationBuilder().token(BOT_TOKEN).build()
|
| 500 |
|
|
|
|
| 501 |
conv = ConversationHandler(
|
| 502 |
entry_points=[CommandHandler("search", cmd_search)],
|
| 503 |
states={
|
|
|
|
| 511 |
],
|
| 512 |
},
|
| 513 |
fallbacks=[CommandHandler("cancel", cmd_cancel)],
|
| 514 |
+
per_message=False,
|
| 515 |
)
|
| 516 |
|
| 517 |
+
application.add_handler(CommandHandler("start", cmd_start))
|
| 518 |
+
application.add_handler(CommandHandler("sites", cmd_sites))
|
| 519 |
+
application.add_handler(CommandHandler("get", cmd_get))
|
| 520 |
+
application.add_handler(conv)
|
| 521 |
+
return application
|
| 522 |
+
|
| 523 |
+
async def run_async():
|
| 524 |
+
"""ΨͺΨ΄ΨΊΩΩ Ψ§ΩΨ¨ΩΨͺ Ψ¨Ψ―ΩΩ signal handlers β ΩΨ΄ΨͺΨΊΩ Ω
Ω Ψ£Ω thread"""
|
| 525 |
+
application = build_app()
|
| 526 |
+
await application.initialize()
|
| 527 |
+
await application.start()
|
| 528 |
+
await application.updater.start_polling(
|
| 529 |
+
drop_pending_updates=True,
|
| 530 |
+
allowed_updates=Update.ALL_TYPES,
|
| 531 |
+
)
|
| 532 |
print("β
Ψ§ΩΨ¨ΩΨͺ Ψ΄ΨΊΨ§Ω!")
|
| 533 |
+
# Ψ§ΩΨͺΨΈΨ± Ψ₯ΩΩ Ψ§ΩΨ£Ψ¨Ψ―
|
| 534 |
+
await asyncio.Event().wait()
|
| 535 |
+
|
| 536 |
+
def main():
|
| 537 |
+
asyncio.run(run_async())
|
| 538 |
|
| 539 |
if __name__ == "__main__":
|
| 540 |
main()
|