summaryrefslogtreecommitdiff
path: root/keyboards.py
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2020-02-11 18:52:54 +0400
committerAndrew <saintruler@gmail.com>2020-02-11 18:52:54 +0400
commita2d7e6357ea7d9ffcd361580b5d48eefeb1e69cb (patch)
treed2a56d22b1b1add044a8c4bfd6510f0f675467fd /keyboards.py
parent1ca68c0b1af0f7fb5812c831d61cd85d282f08e1 (diff)
Implemented basic state handling and bot views.
Diffstat (limited to 'keyboards.py')
-rw-r--r--keyboards.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/keyboards.py b/keyboards.py
new file mode 100644
index 0000000..5966d90
--- /dev/null
+++ b/keyboards.py
@@ -0,0 +1,69 @@
+import backend_api
+from abc import ABC
+
+
+class Keyboard(ABC):
+ @classmethod
+ def get_keyboard(cls, telegram_id=None):
+ pass
+
+
+class MenuKeyboard(Keyboard):
+ CHOOSE_TASK = "Выбрать задание"
+ TOP_10 = "Топ-10"
+ RULES = "Правила"
+ ADMIN = "/admin"
+
+ @classmethod
+ def get_keyboard(cls, telegram_id=None):
+ return [
+ [cls.CHOOSE_TASK],
+ [cls.TOP_10, cls.RULES],
+ ]
+
+
+class BackToMenuKeyboard(Keyboard):
+ CANCEL = "Вернуться в меню"
+
+ @classmethod
+ def get_keyboard(cls, telegram_id=None):
+ return [[cls.CANCEL]]
+
+
+class TasksKeyboard(Keyboard):
+ CANCEL = "Вернуться в меню"
+
+ @classmethod
+ def get_keyboard(cls, telegram_id=None):
+ tasks = backend_api.get_tasks()
+ titles_keyboard = [[cls.CANCEL]]
+ titles_keyboard.extend([task.get("title")] for task in tasks)
+ return titles_keyboard
+
+
+class TaskChosenKeyboard(Keyboard):
+ TYPE_ANSWER = "Ввести ответ"
+ CANCEL = "Назад"
+
+ @classmethod
+ def get_keyboard(cls, telegram_id=None):
+ return [
+ [cls.TYPE_ANSWER],
+ [cls.CANCEL],
+ ]
+
+
+class ContinueKeyboard(Keyboard):
+ CONTINUE = "Продолжить"
+
+ @classmethod
+ def get_keyboard(cls, telegram_id=None):
+ return [[cls.CONTINUE]]
+
+
+class AnsweringKeyboard(Keyboard):
+ CANCEL = "Отмена"
+
+ @classmethod
+ def get_keyboard(cls, telegram_id=None):
+ return [[cls.CANCEL]]