-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
62 lines (51 loc) · 2.42 KB
/
main.py
File metadata and controls
62 lines (51 loc) · 2.42 KB
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
import asyncio
import logging
import sys
from aiogram import Bot, Dispatcher, F
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode
from aiogram.filters import CommandStart, Command
from aiogram.fsm.context import FSMContext
from aiogram.types import Message, KeyboardButton, LabeledPrice, PreCheckoutQuery, InlineQuery, \
InlineQueryResultArticle, InputTextMessageContent, InlineKeyboardButton
from aiogram.utils.i18n import gettext as _, I18n, FSMI18nMiddleware
from aiogram.utils.keyboard import ReplyKeyboardBuilder, InlineKeyboardBuilder
TOKEN = "7640973994:AAFe7Eg4cV_bL_0iWvuAgOmljW141MXp2og"
dp = Dispatcher()
@dp.message(CommandStart())
async def command_start_handler(message: Message) -> None:
# rkb = ReplyKeyboardBuilder()
# rkb.add(KeyboardButton(text="English"), KeyboardButton(text="Uzbek"))
# rkb = rkb.as_markup(resize_keyboard=True)
# await message.answer(_("Choose your language"), reply_markup=rkb)
ikb = InlineKeyboardBuilder()
ikb.add(InlineKeyboardButton(text="🔍 Search", switch_inline_query_current_chat= ""))
ikb = ikb.as_markup(resize_keyboard=True)
await message.answer(_("Choose your language"), reply_markup=ikb)
#
# @dp.message(F.text == "Uzbek")
# async def uzbek_lang_handler(message: Message, state: FSMContext, i18n) -> None:
# rkb = ReplyKeyboardBuilder()
# rkb.add(KeyboardButton(text="English"), KeyboardButton(text="Uzbek"))
# rkb = rkb.as_markup(resize_keyboard=True)
# await state.update_data({"locale" : 'uz'})
# i18n.current_locale = 'uz'
# await message.answer(_("Choose your language"), reply_markup=rkb)
#
#
# @dp.message(F.text == "English")
# async def english_lang_handler(message: Message, state: FSMContext, i18n) -> None:
# rkb = ReplyKeyboardBuilder()
# rkb.add(KeyboardButton(text="English"), KeyboardButton(text="Uzbek"))
# rkb = rkb.as_markup(resize_keyboard=True)
# await state.update_data({"locale": 'en'})
# i18n.current_locale = 'en'
# await message.answer(_("Choose your language"), reply_markup=rkb)
async def main() -> None:
i18n = I18n(path='locales', default_locale='en', domain="messages")
dp.update.middleware(FSMI18nMiddleware(i18n))
bot = Bot(token=TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML))
await dp.start_polling(bot)
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
asyncio.run(main())