inline.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import sys
  2. from wbb import app
  3. from wbb.utils.inlinefuncs import (
  4. google_search_func, urban_func, translate_func,
  5. alive_function, webss, shortify
  6. )
  7. __MODULE__ = "Inline"
  8. __HELP__ = """
  9. tr [LANGUAGE_CODE] [QUERY] - Translate Text.
  10. ud [QUERY] - Urban Dictionary Query.
  11. google [Query] - Google Search.
  12. alive - Check Bot's Stats.
  13. webss [URL] - Take A Screenshot Of A Website."""
  14. """ Inspiration From https://github.com/pokurt/Nana-Remix/blob/master/nana/plugins/assistant/inline_mod/alive.py """
  15. @app.on_inline_query()
  16. async def inline_query_handler(client, query):
  17. try:
  18. text = query.query.lower()
  19. answers = []
  20. if text == '':
  21. await client.answer_inline_query(
  22. query.id,
  23. results=answers,
  24. switch_pm_text='Click here for help',
  25. switch_pm_parameter='help',
  26. )
  27. return
  28. elif text.split()[0] == "alive":
  29. answerss = await alive_function(answers)
  30. await client.answer_inline_query(
  31. query.id,
  32. results=answerss,
  33. cache_time=10
  34. )
  35. elif text.split()[0] == "tr":
  36. lang = text.split()[1]
  37. tex = text.split(None, 2)[2]
  38. answerss = await translate_func(answers, lang, tex)
  39. await client.answer_inline_query(
  40. query.id,
  41. results=answerss,
  42. cache_time=10
  43. )
  44. elif text.split()[0] == "ud":
  45. tex = text.split(None, 1)[1]
  46. answerss = await urban_func(answers, tex)
  47. await client.answer_inline_query(
  48. query.id,
  49. results=answerss,
  50. cache_time=10
  51. )
  52. elif text.split()[0] == "google":
  53. tex = text.split(None, 1)[1]
  54. answerss = await google_search_func(answers, tex)
  55. await client.answer_inline_query(
  56. query.id,
  57. results=answerss,
  58. cache_time=10
  59. )
  60. elif text.split()[0] == "webss":
  61. tex = text.split(None, 1)[1]
  62. answerss = await webss(tex)
  63. await client.answer_inline_query(
  64. query.id,
  65. results=answerss,
  66. cache_time=2
  67. )
  68. elif text.split()[0] == "bitly":
  69. tex = text.split(None, 1)[1]
  70. answerss = await shortify(tex)
  71. await client.answer_inline_query(
  72. query.id,
  73. results=answerss,
  74. cache_time=2
  75. )
  76. except (IndexError, TypeError) as e:
  77. return