searcher.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # ______ ______ ______ ______ ______ __ ______ ______
  2. # /\ ___\ /\ == \ /\ ___\ /\ __ \ /\__ _\ /\ \ /\___ \ /\ ___\
  3. # \ \ \____ \ \ __< \ \ __\ \ \ __ \ \/_/\ \/ \ \ \ \/_/ /__ \ \ __\
  4. # \ \_____\ \ \_\ \_\ \ \_____\ \ \_\ \_\ \ \_\ \ \_\ /\_____\ \ \_____\
  5. # \/_____/ \/_/ /_/ \/_____/ \/_/\/_/ \/_/ \/_/ \/_____/ \/_____/
  6. # Code is licensed under CC-BY-NC-ND 4.0 unless otherwise specified.
  7. # https://creativecommons.org/licenses/by-nc-nd/4.0/
  8. # You CANNOT edit this file without direct permission from the author.
  9. # You can redistribute this file without any changes.
  10. # meta developer: @creaz_mods
  11. # scope: hikka_min 1.6.2
  12. import random
  13. from hikkatl.types import Message
  14. from .. import loader, utils
  15. class Searcher(loader.Module):
  16. """Search in some bots"""
  17. strings = {
  18. "name": "Searcher",
  19. "err": "<emoji document_id=5260342697075416641>❌</emoji> Not found",
  20. }
  21. strings_ru = {"err": "<emoji document_id=5260342697075416641>❌</emoji> Не найдено"}
  22. @loader.command()
  23. async def pic(self, m: Message):
  24. """<str> - search in @pic"""
  25. args = utils.get_args_raw(m)
  26. if await m.get_reply_message():
  27. r = await m.get_reply_message()
  28. else:
  29. r = m
  30. result = await m.client.inline_query("pic", args)
  31. if not result:
  32. return await utils.answer(m, self.strings("err"))
  33. await result[random.randint(0, 20)].click(m.to_id, reply_to=r)
  34. await m.delete()
  35. @loader.command()
  36. async def vid(self, m: Message):
  37. """<str> - search in @vid"""
  38. args = utils.get_args_raw(m)
  39. if await m.get_reply_message():
  40. r = await m.get_reply_message()
  41. else:
  42. r = m
  43. result = await m.client.inline_query("vid", args)
  44. if not result:
  45. return await utils.answer(m, self.strings("err"))
  46. await result[random.randint(0, 1)].click(m.to_id, reply_to=r)
  47. await m.delete()
  48. @loader.command()
  49. async def mod(self, m: Message):
  50. """<str> - search in @ftg2bot"""
  51. args = utils.get_args_raw(m)
  52. if await m.get_reply_message():
  53. r = await m.get_reply_message()
  54. else:
  55. r = m
  56. result = await m.client.inline_query("ftg2bot", args)
  57. await result[0].click(m.to_id, reply_to=r)
  58. await m.delete()