inline.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import sys
  2. from wbb import app, app2, SUDOERS, USERBOT_USERNAME, BOT_USERNAME
  3. from wbb.utils.errors import capture_err
  4. from pykeyboard import InlineKeyboard
  5. from sys import version as pyver
  6. from motor import version as mongover
  7. from pyrogram import __version__ as pyrover
  8. from pyrogram import filters
  9. from pyrogram.types import (
  10. InlineQueryResultArticle,
  11. InputTextMessageContent,
  12. InlineKeyboardButton
  13. )
  14. """ Inspiration From https://github.com/pokurt/Nana-Remix/blob/master/nana/plugins/assistant/inline_mod/alive.py """
  15. async def alive_function(answers):
  16. buttons = InlineKeyboard(row_width=1)
  17. bot_state = 'Dead' if not await app.get_me() else 'Alive'
  18. ubot_state = 'Dead' if not await app2.get_me() else 'Alive'
  19. buttons.add(InlineKeyboardButton('Stats', callback_data='stats_callback'))
  20. msg = f"""
  21. **[William✨](https://github.com/thehamkercat/WilliamButcherBot):**
  22. **MainBot:** `{bot_state}`
  23. **UserBot:** `{ubot_state}`
  24. **Python:** `{pyver.split()[0]}`
  25. **Pyrogram:** `{pyrover}`
  26. **MongoDB:** `{mongover}`
  27. **Platform:** `{sys.platform}`
  28. **Profiles:** [BOT](t.me/{BOT_USERNAME}) | [UBOT](t.me/{USERBOT_USERNAME})
  29. """
  30. answers.append(
  31. InlineQueryResultArticle(
  32. title='Alive',
  33. description="Check Bot's Stats",
  34. input_message_content=InputTextMessageContent(
  35. msg,
  36. disable_web_page_preview=True
  37. ),
  38. reply_markup=buttons,
  39. )
  40. )
  41. return answers
  42. @app.on_inline_query()
  43. async def inline_query_handler(client, query):
  44. text = query.query.lower()
  45. answers = []
  46. if text == '':
  47. await client.answer_inline_query(
  48. query.id,
  49. results=answers,
  50. switch_pm_text='Commands',
  51. switch_pm_parameter='help',
  52. )
  53. return
  54. elif text == "alive":
  55. answerss = await alive_function(answers)
  56. await client.answer_inline_query(
  57. query.id,
  58. results=answerss,
  59. cache_time=60,
  60. switch_pm_text=f'Hello',
  61. switch_pm_parameter='start',
  62. )