inline.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. )
  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. **yt [Query]** - __Youtube Search.__
  21. **torrent [QUERY]** - __Torrent Search.__
  22. **lyrics [Query]** - __Lyrics Search.__"""
  23. @app.on_message(filters.command("inline"))
  24. async def inline_help(_, message):
  25. await app.send_message(message.chat.id, text=__HELP__)
  26. @app.on_inline_query()
  27. async def inline_query_handler(client, query):
  28. try:
  29. text = query.query.lower()
  30. answers = []
  31. if text.strip() == '':
  32. answerss = await inline_help_func(__HELP__)
  33. await client.answer_inline_query(
  34. query.id,
  35. results=answerss,
  36. cache_time=10
  37. )
  38. return
  39. elif text.split()[0] == "alive":
  40. answerss = await alive_function(answers)
  41. await client.answer_inline_query(
  42. query.id,
  43. results=answerss,
  44. cache_time=10
  45. )
  46. elif text.split()[0] == "tr":
  47. lang = text.split()[1]
  48. tex = text.split(None, 2)[2]
  49. answerss = await translate_func(answers, lang, tex)
  50. await client.answer_inline_query(
  51. query.id,
  52. results=answerss,
  53. )
  54. elif text.split()[0] == "ud":
  55. tex = text.split(None, 1)[1]
  56. answerss = await urban_func(answers, tex)
  57. await client.answer_inline_query(
  58. query.id,
  59. results=answerss,
  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. )
  68. elif text.split()[0] == "webss":
  69. tex = text.split(None, 1)[1]
  70. answerss = await webss(tex)
  71. await client.answer_inline_query(
  72. query.id,
  73. results=answerss,
  74. cache_time=2
  75. )
  76. elif text.split()[0] == "bitly":
  77. tex = text.split(None, 1)[1]
  78. answerss = await shortify(tex)
  79. await client.answer_inline_query(
  80. query.id,
  81. results=answerss,
  82. cache_time=2
  83. )
  84. elif text.split()[0] == "wall":
  85. tex = text.split(None, 1)[1]
  86. answerss = await wall_func(answers, tex)
  87. await client.answer_inline_query(
  88. query.id,
  89. results=answerss
  90. )
  91. elif text.split()[0] == "saavn":
  92. tex = text.split(None, 1)[1]
  93. answerss = await saavn_func(answers, tex)
  94. await client.answer_inline_query(
  95. query.id,
  96. results=answerss
  97. )
  98. elif text.split()[0] == "deezer":
  99. tex = text.split(None, 1)[1]
  100. answerss = await deezer_func(answers, tex)
  101. await client.answer_inline_query(
  102. query.id,
  103. results=answerss
  104. )
  105. elif text.split()[0] == "torrent":
  106. tex = text.split(None, 1)[1]
  107. answerss = await torrent_func(answers, tex)
  108. await client.answer_inline_query(
  109. query.id,
  110. results=answerss,
  111. )
  112. elif text.split()[0] == "yt":
  113. tex = text.split(None, 1)[1]
  114. answerss = await youtube_func(answers, tex)
  115. await client.answer_inline_query(
  116. query.id,
  117. results=answerss
  118. )
  119. elif text.split()[0] == "lyrics":
  120. tex = text.split(None, 1)[1]
  121. answerss = await lyrics_func(answers, tex)
  122. await client.answer_inline_query(
  123. query.id,
  124. results=answerss
  125. )
  126. except (IndexError, TypeError, KeyError, ValueError):
  127. return