markups.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import inspect
  2. import sys
  3. import typing
  4. from aiogram.types import (
  5. InlineKeyboardButton,
  6. InlineKeyboardMarkup,
  7. KeyboardButton,
  8. ReplyKeyboardMarkup,
  9. )
  10. from app import config
  11. from app.utils.helper import name_func
  12. NAVIGATION_BUTTONS = ("Главное меню", "Назад")
  13. def grades(*args) -> ReplyKeyboardMarkup:
  14. markup = ReplyKeyboardMarkup(row_width=4, resize_keyboard=True)
  15. buttons: typing.List[str] = [str(i) for i in range(1, 11 + 1)]
  16. markup.add(*buttons)
  17. return markup
  18. def subjects(subjects: typing.List[str]) -> ReplyKeyboardMarkup:
  19. markup = ReplyKeyboardMarkup(row_width=4, resize_keyboard=True)
  20. markup.add("Главное меню")
  21. markup.add("Назад")
  22. markup.add(*subjects)
  23. return markup
  24. def authors(authors: typing.List[str]) -> ReplyKeyboardMarkup:
  25. markup = ReplyKeyboardMarkup(row_width=4, resize_keyboard=True)
  26. markup.add("Главное меню")
  27. markup.add("Назад")
  28. markup.add(*authors)
  29. return markup
  30. def specifications(specifications: typing.List[str]) -> ReplyKeyboardMarkup:
  31. markup = ReplyKeyboardMarkup(row_width=4, resize_keyboard=True)
  32. markup.add("Главное меню")
  33. markup.add("Назад")
  34. markup.add(*specifications)
  35. return markup
  36. def years(years: typing.List[typing.Union[str, int]]) -> ReplyKeyboardMarkup:
  37. markup = ReplyKeyboardMarkup(row_width=4, resize_keyboard=True)
  38. markup.add("Главное меню")
  39. markup.add("Назад")
  40. markup.add(*years)
  41. return markup
  42. def main_topics(main_topics: typing.List[str]) -> ReplyKeyboardMarkup:
  43. markup = ReplyKeyboardMarkup(row_width=4, resize_keyboard=True)
  44. markup.add("Главное меню")
  45. markup.add("Назад")
  46. markup.add(*main_topics)
  47. return markup
  48. def sub_topics(sub_topics: typing.List[str]) -> ReplyKeyboardMarkup:
  49. markup = ReplyKeyboardMarkup(row_width=4, resize_keyboard=True)
  50. markup.add("Главное меню")
  51. markup.add("Назад")
  52. markup.add(*sub_topics)
  53. return markup
  54. def sub_sub_topics(sub_sub_topics: typing.List[str]) -> ReplyKeyboardMarkup:
  55. markup = ReplyKeyboardMarkup(row_width=4, resize_keyboard=True)
  56. markup.add("Главное меню")
  57. markup.add("Назад")
  58. markup.add(*sub_sub_topics)
  59. return markup
  60. def exercises(exercises: typing.List[str]) -> ReplyKeyboardMarkup:
  61. markup = ReplyKeyboardMarkup(row_width=4, resize_keyboard=True)
  62. markup.add("Главное меню")
  63. markup.add("Назад")
  64. markup.add(*exercises)
  65. return markup
  66. def confirm_send_all() -> InlineKeyboardMarkup:
  67. markup = InlineKeyboardMarkup()
  68. markup.add(InlineKeyboardButton("Да", callback_data=config.CB_SEND_ALL_YES))
  69. markup.add(InlineKeyboardButton("Нет", callback_data=config.CB_SEND_ALL_NO))
  70. return markup
  71. def confirm_block() -> InlineKeyboardMarkup:
  72. markup = InlineKeyboardMarkup()
  73. markup.add(InlineKeyboardButton("Да", callback_data=config.CB_BLOCK_YES))
  74. markup.add(InlineKeyboardButton("Нет", callback_data=config.CB_BLOCK_NO))
  75. return markup
  76. def confirm_unblock() -> InlineKeyboardMarkup:
  77. markup = InlineKeyboardMarkup()
  78. markup.add(InlineKeyboardButton("Да", callback_data=config.CB_UNBLOCK_YES))
  79. markup.add(InlineKeyboardButton("Нет", callback_data=config.CB_UNBLOCK_NO))
  80. return markup
  81. markups_list: typing.List[name_func] = [
  82. name_func(name, func)
  83. for name, func in inspect.getmembers(sys.modules[__name__], inspect.isfunction)
  84. ]