Add example. Check user language.

Demonstrate language and markdown utils.
This commit is contained in:
Alex Root Junior 2017-05-27 03:58:34 +03:00
parent 2fdd804114
commit e06920681d

View file

@ -0,0 +1,40 @@
import asyncio
import logging
from aiogram.bot import AIOGramBot
from aiogram.dispatcher import Dispatcher
from aiogram.types.message import ParseMode
from aiogram.utils.markdown import *
API_TOKEN = 'BOT TOKEN HERE'
logging.basicConfig(level=logging.INFO)
loop = asyncio.get_event_loop()
bot = AIOGramBot(token=API_TOKEN, loop=loop)
dp = Dispatcher(bot)
@dp.message_handler()
async def check_language(message):
language = message.from_user.language
await message.reply(text(
bold('Info about your language:'),
text(' 🔸', bold('Code:'), italic(language.code)),
text(' 🔸', bold('Type:'), italic(language.type)),
text(' 🔸', bold('Title:'), italic(language.title)),
sep='\n'), parse_mode=ParseMode.MARKDOWN)
async def main():
count = await dp.skip_updates()
print(f"Skipped {count} updates.")
await dp.start_pooling()
if __name__ == '__main__':
try:
loop.run_until_complete(main())
except KeyboardInterrupt:
loop.stop()