inline.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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, youtube_func, lyrics_func,
  7. paste_func, eval_func, github_user_func,
  8. github_repo_func
  9. )
  10. from pyrogram import filters
  11. from pyrogram.errors.exceptions.bad_request_400 import QueryIdInvalid
  12. __MODULE__ = "Inline"
  13. __HELP__ = '''
  14. - alive - Check Bot's Stats.
  15. - tr [LANG] [QUERY] - Translate Text.
  16. - ud [QUERY] - Urban Dictionary Query.
  17. - google [QUERY] - Google Search.
  18. - webss [URL] - Take Screenshot Of A Website.
  19. - bitly [URL] - Shorten A Link.
  20. - wall [QUERY] - Find Wallpapers.
  21. - saavn [SONG_NAME] - Get Songs From Saavn.
  22. - deezer [SONG_NAME] - Get Songs From Deezer.
  23. - yt [Query] - Youtube Search.
  24. - torrent [QUERY] - Torrent Search.
  25. - lyrics [QUERY] - Lyrics Search.
  26. - eval [CODE] - Execute Python Code.
  27. - paste [TEXT] - Paste Text On Pastebin. <=500
  28. - gh_user [USERNAME] - Search A Github User.
  29. - gh_repo [USERNAME/REPO] - Search A Github Repo.
  30. '''
  31. @app.on_message(filters.command("inline"))
  32. async def inline_help(_, message):
  33. await app.send_message(message.chat.id, text=__HELP__)
  34. @app.on_inline_query()
  35. async def inline_query_handler(client, query):
  36. try:
  37. text = query.query.lower()
  38. answers = []
  39. if text.strip() == '':
  40. answerss = await inline_help_func(__HELP__)
  41. await client.answer_inline_query(
  42. query.id,
  43. results=answerss,
  44. cache_time=10
  45. )
  46. return
  47. elif text.split()[0] == "alive":
  48. answerss = await alive_function(answers)
  49. await client.answer_inline_query(
  50. query.id,
  51. results=answerss,
  52. cache_time=10
  53. )
  54. elif text.split()[0] == "tr":
  55. lang = text.split()[1]
  56. tex = text.split(None, 2)[2].strip()
  57. answerss = await translate_func(answers, lang, tex)
  58. await client.answer_inline_query(
  59. query.id,
  60. results=answerss,
  61. )
  62. elif text.split()[0] == "ud":
  63. tex = text.split(None, 1)[1].strip()
  64. answerss = await urban_func(answers, tex)
  65. await client.answer_inline_query(
  66. query.id,
  67. results=answerss,
  68. )
  69. elif text.split()[0] == "google":
  70. tex = text.split(None, 1)[1].strip()
  71. answerss = await google_search_func(answers, tex)
  72. await client.answer_inline_query(
  73. query.id,
  74. results=answerss,
  75. )
  76. elif text.split()[0] == "webss":
  77. tex = text.split(None, 1)[1].strip()
  78. answerss = await webss(tex)
  79. await client.answer_inline_query(
  80. query.id,
  81. results=answerss,
  82. cache_time=2
  83. )
  84. elif text.split()[0] == "bitly":
  85. tex = text.split(None, 1)[1].strip()
  86. answerss = await shortify(tex)
  87. await client.answer_inline_query(
  88. query.id,
  89. results=answerss,
  90. cache_time=2
  91. )
  92. elif text.split()[0] == "wall":
  93. tex = text.split(None, 1)[1].strip()
  94. answerss = await wall_func(answers, tex)
  95. await client.answer_inline_query(
  96. query.id,
  97. results=answerss
  98. )
  99. elif text.split()[0] == "saavn":
  100. tex = text.split(None, 1)[1].strip()
  101. answerss = await saavn_func(answers, tex)
  102. await client.answer_inline_query(
  103. query.id,
  104. results=answerss
  105. )
  106. elif text.split()[0] == "deezer":
  107. tex = text.split(None, 1)[1].strip()
  108. answerss = await deezer_func(answers, tex)
  109. await client.answer_inline_query(
  110. query.id,
  111. results=answerss
  112. )
  113. elif text.split()[0] == "torrent":
  114. tex = text.split(None, 1)[1].strip()
  115. answerss = await torrent_func(answers, tex)
  116. await client.answer_inline_query(
  117. query.id,
  118. results=answerss,
  119. )
  120. elif text.split()[0] == "yt":
  121. tex = text.split(None, 1)[1].strip()
  122. answerss = await youtube_func(answers, tex)
  123. await client.answer_inline_query(
  124. query.id,
  125. results=answerss
  126. )
  127. elif text.split()[0] == "lyrics":
  128. tex = text.split(None, 1)[1].strip()
  129. answerss = await lyrics_func(answers, tex)
  130. await client.answer_inline_query(
  131. query.id,
  132. results=answerss
  133. )
  134. elif text.split()[0] == "paste":
  135. tex = text.split(None, 1)[1].strip()
  136. answerss = await paste_func(answers, tex)
  137. await client.answer_inline_query(
  138. query.id,
  139. results=answerss,
  140. cache_time=2
  141. )
  142. elif text.split()[0] == "eval":
  143. user_id = query.from_user.id
  144. tex = text.split(None, 1)[1].strip()
  145. answerss = await eval_func(answers, tex, user_id)
  146. await client.answer_inline_query(
  147. query.id,
  148. results=answerss,
  149. cache_time=2
  150. )
  151. elif text.split()[0] == "gh_user":
  152. tex = text.split(None, 1)[1].strip()
  153. answerss = await github_user_func(answers, tex)
  154. await client.answer_inline_query(
  155. query.id,
  156. results=answerss,
  157. cache_time=2
  158. )
  159. elif text.split()[0] == "gh_repo":
  160. tex = text.split(None, 1)[1].strip()
  161. answerss = await github_repo_func(answers, tex)
  162. await client.answer_inline_query(
  163. query.id,
  164. results=answerss,
  165. cache_time=2
  166. )
  167. except (IndexError, TypeError, KeyError, ValueError, QueryIdInvalid):
  168. return