-
Notifications
You must be signed in to change notification settings - Fork 0
/
kb_botfather_01.py
47 lines (34 loc) · 2.03 KB
/
kb_botfather_01.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
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.types import callback_query
from aiogram.utils import executor
from config import TOKEN
# from keyboards import kb
from keyboards import kb_bf
bot = Bot(token=TOKEN)
storage = MemoryStorage()
dp = Dispatcher(bot)
@dp.message_handler(content_types=["text"])
async def process_start_command(message: types.Message):
await message.reply("testing kb", reply_markup=kb_bf.keyboardmain)
@dp.callback_query_handler(lambda callback_query: True)
async def callback_inline(callback_query: types.CallbackQuery):
if call.data == "mainmenu":
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="menu", reply_markup=kb_bf.keyboardmain)
if call.data == "first":
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="replaced text", reply_markup=kb_bf.keyboard_1)
elif call.data == "second":
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="replaced text", reply_markup=kb_bf.keyboard_2)
elif call.data == "1" or call.data == "2" or call.data == "3":
bot.answer_callback_query(callback_query_id=call.id, show_alert=True, text="alert")
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="last layer", reply_markup=kb_bf.keyboard_3)
# @dp.callback_query_handler(func=lambda c: c.data == 'button1')
# async def process_callback_button1(callback_query: types.CallbackQuery):
# await bot.answer_callback_query(callback_query.id)
# await bot.send_message(callback_query.from_user.id, 'Нажата первая кнопка!')
# @dp.message_handler(message=['text'])
# async def process_message(message: types.Message):
# await message.reply('Довідка - /help', reply_markup=kb_bf.keyboardmain)
if __name__ == '__main__':
executor.start_polling(dp)