mirror of
https://github.com/Redume/Shirino.git
synced 2025-05-19 10:15:26 +01:00
chore: Added translation for the start command, code link made as a button
This commit is contained in:
parent
6bf8b4c049
commit
722b79b523
1 changed files with 25 additions and 11 deletions
|
@ -1,28 +1,42 @@
|
|||
from aiogram import types, Router
|
||||
from aiogram.filters import CommandStart
|
||||
import re
|
||||
|
||||
from bot import bot
|
||||
from bot import bot, db
|
||||
from i18n.localization import I18n
|
||||
|
||||
router = Router()
|
||||
i18n = I18n()
|
||||
|
||||
def escape_md_v2(text: str) -> str:
|
||||
return re.sub(r'([_*\[\]()~#+\-=|{}.!\\])', r'\\\1', text)
|
||||
|
||||
@router.message(CommandStart())
|
||||
async def start(message: types.Message) -> None:
|
||||
get_bot = await bot.get_me()
|
||||
|
||||
keyboard = types.InlineKeyboardMarkup(inline_keyboard=[
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="Source Code",
|
||||
url="https://github.com/redume/shirino"
|
||||
data = await db.fetch(
|
||||
'SELECT lang FROM users WHERE user_id = $1',
|
||||
message.from_user.id
|
||||
)
|
||||
|
||||
locale = i18n.get_locale(data.get('lang'))
|
||||
|
||||
raw_template = locale.get("start_message")
|
||||
raw_text = raw_template.format(bot_username=get_bot.username)
|
||||
text = escape_md_v2(raw_text)
|
||||
|
||||
button_text = locale.get("source_code_button")
|
||||
|
||||
keyboard = types.InlineKeyboardMarkup(inline_keyboard=[
|
||||
[types.InlineKeyboardButton(
|
||||
text=button_text,
|
||||
url="https://github.com/redume/shirino")
|
||||
]
|
||||
])
|
||||
|
||||
await message.reply(
|
||||
'Shirino is a telegram bot for converting fiat or cryptocurrency. '
|
||||
'The example of use occurs via inline query:\n'
|
||||
f'`@{get_bot.username} USD RUB` \n'
|
||||
f'`@{get_bot.username} 12 USD RUB` \n\n',
|
||||
parse_mode='markdown',
|
||||
text,
|
||||
parse_mode="MarkdownV2",
|
||||
reply_markup=keyboard
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue