inline.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. from wbb import app
  2. from wbb.utils.inlinefuncs import (
  3. google_search_func, urban_func, translate_func,
  4. alive_function, webss, shortify, wall_func,
  5. saavn_func, deezer_func, inline_help_func,
  6. torrent_func
  7. )
  8. from pyrogram import filters
  9. __MODULE__ = "Inline"
  10. __HELP__ = """
  11. **alive** - __Check Bot's Stats.__
  12. **tr [LANGUAGE_CODE] [QUERY]** - __Translate Text.__
  13. **ud [QUERY]** - __Urban Dictionary Query.__
  14. **google [QUERY]** - __Google Search.__
  15. **webss [URL]** - __Take Screenshot Of A Website.__
  16. **bitly [URL]** - __Shorten A Link.__
  17. **wall [Query]** - __Find Wallpapers.__
  18. **saavn [SONG_NAME]** - __Get Songs From Saavn.__
  19. **deezer [SONG_NAME]** - __Get Songs From Deezer.__
  20. **torrent [QUERY] - __Torrent Search.__"""
  21. @app.on_message(filters.command("inline"))
  22. async def inline_help(_, message):
  23. await app.send_message(message.chat.id, text=__HELP__)
  24. @app.on_inline_query()
  25. async def inline_query_handler(client, query):
  26. try:
  27. text = query.query.lower()
  28. answers = []
  29. if text.strip() == '':
  30. answerss = await inline_help_func(__HELP__)
  31. await client.answer_inline_query(
  32. query.id,
  33. results=answerss,
  34. cache_time=10
  35. )
  36. return
  37. elif text.split()[0] == "alive":
  38. answerss = await alive_function(answers)
  39. await client.answer_inline_query(
  40. query.id,
  41. results=answerss,
  42. cache_time=10
  43. )
  44. elif text.split()[0] == "tr":
  45. lang = text.split()[1]
  46. tex = text.split(None, 2)[2]
  47. answerss = await translate_func(answers, lang, tex)
  48. await client.answer_inline_query(
  49. query.id,
  50. results=answerss,
  51. cache_time=10
  52. )
  53. elif text.split()[0] == "ud":
  54. tex = text.split(None, 1)[1]
  55. answerss = await urban_func(answers, tex)
  56. await client.answer_inline_query(
  57. query.id,
  58. results=answerss,
  59. cache_time=10
  60. )
  61. elif text.split()[0] == "google":
  62. tex = text.split(None, 1)[1]
  63. answerss = await google_search_func(answers, tex)
  64. await client.answer_inline_query(
  65. query.id,
  66. results=answerss,
  67. cache_time=10
  68. )
  69. elif text.split()[0] == "webss":
  70. tex = text.split(None, 1)[1]
  71. answerss = await webss(tex)
  72. await client.answer_inline_query(
  73. query.id,
  74. results=answerss,
  75. cache_time=2
  76. )
  77. elif text.split()[0] == "bitly":
  78. tex = text.split(None, 1)[1]
  79. answerss = await shortify(tex)
  80. await client.answer_inline_query(
  81. query.id,
  82. results=answerss,
  83. cache_time=2
  84. )
  85. elif text.split()[0] == "wall":
  86. tex = text.split(None, 1)[1]
  87. answerss = await wall_func(answers, tex)
  88. await client.answer_inline_query(
  89. query.id,
  90. results=answerss
  91. )
  92. elif text.split()[0] == "saavn":
  93. tex = text.split(None, 1)[1]
  94. answerss = await saavn_func(answers, tex)
  95. await client.answer_inline_query(
  96. query.id,
  97. results=answerss
  98. )
  99. elif text.split()[0] == "deezer":
  100. tex = text.split(None, 1)[1]
  101. answerss = await deezer_func(answers, tex)
  102. await client.answer_inline_query(
  103. query.id,
  104. results=answerss
  105. )
  106. elif text.split()[0] == "torrent":
  107. tex = text.split(None, 1)[1]
  108. answerss = await torrent_func(answers, tex)
  109. await client.answer_inline_query(
  110. query.id,
  111. results=answerss,
  112. cache_time=10
  113. )
  114. except (IndexError, TypeError, KeyError, ValueError):
  115. return