inline.py 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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, calendar_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. - calendar - Get Current Month Calendar.
  27. - eval [CODE] - Execute Python Code.
  28. - paste [TEXT] - Paste Text On Pastebin. <=500
  29. - gh_user [USERNAME] - Search A Github User.
  30. - gh_repo [USERNAME/REPO] - Search A Github Repo.
  31. ```'''
  32. @app.on_message(filters.command("inline"))
  33. async def inline_help(_, message):
  34. await app.send_message(message.chat.id, text=__HELP__)
  35. @app.on_inline_query()
  36. async def inline_query_handler(client, query):
  37. try:
  38. text = query.query.lower()
  39. answers = []
  40. if text.strip() == '':
  41. answerss = await inline_help_func(__HELP__)
  42. await client.answer_inline_query(
  43. query.id,
  44. results=answerss,
  45. cache_time=10
  46. )
  47. return
  48. elif text.split()[0] == "alive":
  49. answerss = await alive_function(answers)
  50. await client.answer_inline_query(
  51. query.id,
  52. results=answerss,
  53. cache_time=10
  54. )
  55. elif text.split()[0] == "tr":
  56. lang = text.split()[1]
  57. tex = text.split(None, 2)[2].strip()
  58. answerss = await translate_func(answers, lang, tex)
  59. await client.answer_inline_query(
  60. query.id,
  61. results=answerss,
  62. )
  63. elif text.split()[0] == "ud":
  64. tex = text.split(None, 1)[1].strip()
  65. answerss = await urban_func(answers, tex)
  66. await client.answer_inline_query(
  67. query.id,
  68. results=answerss,
  69. )
  70. elif text.split()[0] == "google":
  71. tex = text.split(None, 1)[1].strip()
  72. answerss = await google_search_func(answers, tex)
  73. await client.answer_inline_query(
  74. query.id,
  75. results=answerss,
  76. )
  77. elif text.split()[0] == "webss":
  78. tex = text.split(None, 1)[1].strip()
  79. answerss = await webss(tex)
  80. await client.answer_inline_query(
  81. query.id,
  82. results=answerss,
  83. cache_time=2
  84. )
  85. elif text.split()[0] == "bitly":
  86. tex = text.split(None, 1)[1].strip()
  87. answerss = await shortify(tex)
  88. await client.answer_inline_query(
  89. query.id,
  90. results=answerss,
  91. cache_time=2
  92. )
  93. elif text.split()[0] == "wall":
  94. tex = text.split(None, 1)[1].strip()
  95. answerss = await wall_func(answers, tex)
  96. await client.answer_inline_query(
  97. query.id,
  98. results=answerss
  99. )
  100. elif text.split()[0] == "saavn":
  101. tex = text.split(None, 1)[1].strip()
  102. answerss = await saavn_func(answers, tex)
  103. await client.answer_inline_query(
  104. query.id,
  105. results=answerss
  106. )
  107. elif text.split()[0] == "deezer":
  108. tex = text.split(None, 1)[1].strip()
  109. answerss = await deezer_func(answers, tex)
  110. await client.answer_inline_query(
  111. query.id,
  112. results=answerss
  113. )
  114. elif text.split()[0] == "torrent":
  115. tex = text.split(None, 1)[1].strip()
  116. answerss = await torrent_func(answers, tex)
  117. await client.answer_inline_query(
  118. query.id,
  119. results=answerss,
  120. )
  121. elif text.split()[0] == "yt":
  122. tex = text.split(None, 1)[1].strip()
  123. answerss = await youtube_func(answers, tex)
  124. await client.answer_inline_query(
  125. query.id,
  126. results=answerss
  127. )
  128. elif text.split()[0] == "lyrics":
  129. tex = text.split(None, 1)[1].strip()
  130. answerss = await lyrics_func(answers, tex)
  131. await client.answer_inline_query(
  132. query.id,
  133. results=answerss
  134. )
  135. elif text.split()[0] == "paste":
  136. tex = text.split(None, 1)[1].strip()
  137. answerss = await paste_func(answers, tex)
  138. await client.answer_inline_query(
  139. query.id,
  140. results=answerss,
  141. cache_time=2
  142. )
  143. elif text.split()[0] == "eval":
  144. user_id = query.from_user.id
  145. tex = text.split(None, 1)[1].strip()
  146. answerss = await eval_func(answers, tex, user_id)
  147. await client.answer_inline_query(
  148. query.id,
  149. results=answerss,
  150. cache_time=2
  151. )
  152. elif text.split()[0] == "gh_user":
  153. tex = text.split(None, 1)[1].strip()
  154. answerss = await github_user_func(answers, tex)
  155. await client.answer_inline_query(
  156. query.id,
  157. results=answerss,
  158. cache_time=2
  159. )
  160. elif text.split()[0] == "gh_repo":
  161. tex = text.split(None, 1)[1].strip()
  162. answerss = await github_repo_func(answers, tex)
  163. await client.answer_inline_query(
  164. query.id,
  165. results=answerss,
  166. cache_time=2
  167. )
  168. elif text.split()[0] == "calendar":
  169. answerss = await calendar_func(answers)
  170. await client.answer_inline_query(
  171. query.id,
  172. results=answerss,
  173. cache_time=2
  174. )
  175. except (IndexError, TypeError, KeyError, ValueError, QueryIdInvalid):
  176. return