-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusing_asyncio.py
72 lines (54 loc) · 1.89 KB
/
using_asyncio.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
Babel is required.
"""
import logging
from aiogram import Bot, Dispatcher, executor, md, types
from tmdbv3api import TMDb
from tmdbv3api import Movie
API_TOKEN = "API_TOKEN"
logging.basicConfig(level=logging.INFO)
bot = Bot(token=API_TOKEN, parse_mode=types.ParseMode.MARKDOWN_V2)
dp = Dispatcher(bot)
@dp.message_handler(commands=["start", "help"])
async def send_welcome(message: types.Message):
"""
This handler will be called when user sends `/start` or `/help` command.
"""
await message.reply("Menu")
@dp.message_handler(commands=["search"])
async def send_welcome(message: types.Message):
"""
This handler will be called when user sends `/start` or `/help` command.
"""
await message.reply("Hi")
movie_name = message["text"][8:]
resp = await search(message)
# @dp.message_handler(commands=["search"])
async def search(message: types.Message):
"""
This handler will be called when user sends `/start` or `/hep` command.
"""
tmdb = TMDb()
tmdb.api_key = "YOUR_KEY"
movie_name = message["text"][8:]
movie = Movie()
resp = movie.search(movie_name)
logging.info(resp)
await message.reply(md.text(md.bold("Info about your language:")))
@dp.message_handler()
async def check_language(message: types.Message):
locale = message.from_user.locale
await message.reply(
md.text(
md.bold("Info about your language:"),
md.text("🔸", md.bold("Code:"), md.code(locale.language)),
md.text("🔸", md.bold("Territory:"), md.code(locale.territory or "Unknown")),
md.text("🔸", md.bold("Language name:"), md.code(locale.language_name)),
md.text(
"🔸", md.bold("English language name:"), md.code(locale.english_name)
),
sep="\n",
)
)
if __name__ == "__main__":
executor.start_polling(dp, skip_updates=True)