bmaker.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. from hikkatl.types import Message
  13. from .. import loader, utils # type: ignore
  14. @loader.tds
  15. class ButtonMaker(loader.Module):
  16. """"""
  17. strings = {
  18. "name": "ButtonMaker",
  19. "err": "Incorrect args",
  20. "bot_err": "Your inline bot did not respond. Try restarting the userbot",
  21. }
  22. strings_ru = {
  23. "err": "Неверные аргументы",
  24. "bot_err": "Ваш инлайн-бот не ответил. Попробуйте перезагрузить юзербота",
  25. }
  26. strings_es = {
  27. "err": "Argumentos incorrectos",
  28. "bot_err": "Su bot en línea no respondió. Intente reiniciar el bot de usuario",
  29. }
  30. strings_de = {
  31. "err": "Ungültige Argumente",
  32. "bot_err": (
  33. "Ihr Inline-Bot hat nicht geantwortet. Versuchen Sie, den Benutzerbot neu"
  34. " zu starten"
  35. ),
  36. }
  37. @loader.command(
  38. ru_doc=(
  39. "Создает сообщение с кнопкой. Агрументы: str, str, ссылка, разделенные <>"
  40. ),
  41. es_doc=(
  42. "Crea un mensaje con un botón. Argumentos: str, str, enlace separado por <>"
  43. ),
  44. de_doc=(
  45. "Erstellt eine Nachricht mit einer Schaltfläche. Argumente: str, str, Link"
  46. " getrennt durch <>"
  47. ),
  48. )
  49. async def inl(self, m: Message):
  50. """Creates a button. Args: str, str, link separated by <>"""
  51. args = utils.get_args_split_by(m, "<>")
  52. if len(args) != 3:
  53. await utils.answer(m, self.strings["err"])
  54. return
  55. if not args[2].startswith("https://") and not args[2].startswith("http://"):
  56. args[2] = "https://" + args[2]
  57. try:
  58. await self.inline.form(
  59. message=m,
  60. text=args[0],
  61. reply_markup=[[{"text": args[1], "url": args[2]}]],
  62. )
  63. await m.delete() # type: ignore
  64. except:
  65. await utils.answer(m, self.string["bot_err"])