| Conditions | 3 |
| Total Lines | 28 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
| 20 | @rate_limit(5, 'dice') |
||
| 21 | @dp.message_handler(commands='dice') |
||
| 22 | async def bot_message(message: types.Message): |
||
| 23 | |||
| 24 | """ |
||
| 25 | |||
| 26 | The function is designed for tossing a dice. |
||
| 27 | |||
| 28 | """ |
||
| 29 | |||
| 30 | await types.ChatActions.typing() |
||
| 31 | |||
| 32 | user = await message.bot.send_dice(chat_id=message.chat.id) |
||
| 33 | await asyncio.sleep(1) |
||
| 34 | |||
| 35 | bot = await message.bot.send_dice(chat_id=message.chat.id) |
||
| 36 | await asyncio.sleep(3) |
||
| 37 | |||
| 38 | await asyncio.sleep(1) |
||
| 39 | if user.dice.value > bot.dice.value: |
||
| 40 | await message.answer(f"Выиграл {message.from_user.first_name}!") |
||
| 41 | |||
| 42 | elif user.dice.value < bot.dice.value: |
||
| 43 | bot_name = await message.bot.get_me() |
||
| 44 | await message.answer(f"Выиграл {bot_name.first_name}!") |
||
| 45 | |||
| 46 | else: |
||
| 47 | await message.answer("Ничья!") |
||
| 48 |