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