-
Notifications
You must be signed in to change notification settings - Fork 20
/
keyboards.py
63 lines (52 loc) · 2.02 KB
/
keyboards.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import os
from pathlib import Path
from aiogram.contrib.middlewares.i18n import I18nMiddleware
from aiogram.types import (
ReplyKeyboardMarkup,
KeyboardButton,
InlineKeyboardMarkup,
InlineKeyboardButton,
)
from dotenv import load_dotenv
load_dotenv()
BASE_DIR = Path(__file__).parent
LOCALES_DIR = BASE_DIR / "locales"
BOT_LANGUAGE = os.environ.get("BOT_LANGUAGE")
i18n = I18nMiddleware("bot", LOCALES_DIR, default="en")
# Initialize reply keyboard
start_keyboard = ReplyKeyboardMarkup(resize_keyboard=True)
sell_button = KeyboardButton(
i18n.gettext("bot.start_keyboard_sell", locale=BOT_LANGUAGE)
) # Create a button with the text "/sell"
help_button = KeyboardButton(i18n.gettext("bot.start_keyboard_help", locale=BOT_LANGUAGE))
start_keyboard.add(sell_button) # Add the button to the keyboard
start_keyboard.add(help_button) # Add the button to the keyboard
sell_keyboard = ReplyKeyboardMarkup(resize_keyboard=True)
cancel_button = KeyboardButton(i18n.gettext("bot.sell_keyboard_cancel", locale=BOT_LANGUAGE))
sell_keyboard.add(cancel_button)
empty_inline_keyboard = InlineKeyboardMarkup()
def moderator_keyboard(userid, msg_id):
moderator_inline_keyboard = InlineKeyboardMarkup()
moderator_inline_keyboard.add(
InlineKeyboardButton(
i18n.gettext("bot.moderator_approval", locale=BOT_LANGUAGE),
callback_data=f"moderator:approved {userid}.{msg_id}",
)
)
moderator_inline_keyboard.add(
InlineKeyboardButton(
i18n.gettext("bot.moderator_declination", locale=BOT_LANGUAGE),
callback_data=f"moderator:declined {userid}.{msg_id}",
)
)
return moderator_inline_keyboard
def cancel_listing_keyboard(channel_message_id, msg_id):
# Cancel listing markup for seller
reply_markup = InlineKeyboardMarkup()
reply_markup.add(
InlineKeyboardButton(
i18n.gettext("bot.cancel_sell", locale=BOT_LANGUAGE),
callback_data=f"cancel {channel_message_id}.{msg_id}",
)
)
return reply_markup