-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainbot.py
53 lines (36 loc) · 1.61 KB
/
mainbot.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
from aiogram import Bot, types, executor
from aiogram.dispatcher import Dispatcher
from config import bottoken, findgame
from config.service.service import FindState as fs
from aiogram.dispatcher import FSMContext
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher.filters import Text
bot = Bot(token=bottoken.token)
dp = Dispatcher(bot, storage=MemoryStorage())
@dp.message_handler(commands=['start'])
async def process_start_command(message: types.Message):
await message.reply('Hello, i can help find game!\nEnter /find', reply=False)
@dp.message_handler(commands=['help'])
async def help_command(message: types.Message):
await message.reply('У меня безграничные возможности', reply=False)
@dp.message_handler(state='*', commands=['cancel'])
@dp.message_handler(Text(equals='cancel', ignore_case=True), state='*')
async def cancel_handler(message: types.Message, state: FSMContext):
await state.finish()
await message.reply('Cancelled.', reply=False)
@dp.message_handler(state="*", commands=['find'])
async def find_game(message: types.Message, state: FSMContext):
await message.answer(" Enter game name\nOr enter /cancel for cancel", reply=False)
await fs.wait_game.set()
@dp.message_handler(state=fs.wait_game)
async def finder(message: types.ContentType, state: FSMContext):
game_text = message.text
aio = await findgame.main(text=game_text)
print(aio)
await message.reply(aio)
# user_data = await state.get_data()
await state.finish()
def main():
executor.start_polling(dp)
if __name__ == '__main__':
main()