Make single elements ContentType object and ContentTypes class for listed elements

This commit is contained in:
Alex Root Junior 2018-08-13 23:53:37 +03:00
parent e31e08a072
commit b16963d4a9
5 changed files with 99 additions and 35 deletions

View file

@ -4,7 +4,7 @@ from aiogram import Bot
from aiogram import types
from aiogram.utils import executor
from aiogram.dispatcher import Dispatcher
from aiogram.types.message import ContentType
from aiogram.types.message import ContentTypes
BOT_TOKEN = 'BOT TOKEN HERE'
@ -86,7 +86,7 @@ async def checkout(pre_checkout_query: types.PreCheckoutQuery):
" try to pay again in a few minutes, we need a small rest.")
@dp.message_handler(content_types=ContentType.SUCCESSFUL_PAYMENT)
@dp.message_handler(content_types=ContentTypes.SUCCESSFUL_PAYMENT)
async def got_payment(message: types.Message):
await bot.send_message(message.chat.id,
'Hoooooray! Thanks for payment! We will proceed your order for `{} {}`'

View file

@ -9,7 +9,7 @@ from aiogram import Bot, types, Version
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher import Dispatcher
from aiogram.dispatcher.webhook import get_new_configured_app, SendMessage
from aiogram.types import ChatType, ParseMode, ContentType
from aiogram.types import ChatType, ParseMode, ContentTypes
from aiogram.utils.markdown import hbold, bold, text, link
TOKEN = 'BOT TOKEN HERE'
@ -31,7 +31,7 @@ WEBHOOK_URL = f"https://{WEBHOOK_HOST}:{WEBHOOK_PORT}{WEBHOOK_URL_PATH}"
WEBAPP_HOST = 'localhost'
WEBAPP_PORT = 3001
BAD_CONTENT = ContentType.PHOTO & ContentType.DOCUMENT & ContentType.STICKER & ContentType.AUDIO
BAD_CONTENT = ContentTypes.PHOTO & ContentTypes.DOCUMENT & ContentTypes.STICKER & ContentTypes.AUDIO
loop = asyncio.get_event_loop()
bot = Bot(TOKEN, loop=loop)