inline.py 2.8 KB

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