-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
72 lines (58 loc) · 2.08 KB
/
bot.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
import logging
from aiogram import Bot, Dispatcher, executor, types
import inline_keyboard
import messages
import config
logging.basicConfig(level=logging.INFO)
bot = Bot(token=config.BOT_API_TOKEN)
dp = Dispatcher(bot)
@dp.message_handler(commands=['start', 'weather'])
async def show_weather(message: types.Message):
await message.answer(
text=messages.weather(),
reply_markup=inline_keyboard.WEATHER
)
@dp.message_handler(commands=['help'])
async def show_help_message(message: types.Message):
await message.answer(
text=f'Этот бот получает текущую погоду от вашего IP-адреса',
reply_markup=inline_keyboard.HELP
)
@dp.message_handler(commands=['wind'])
async def show_wind(message: types.Message):
await message.answer(
text=messages.wind(),
reply_markup=inline_keyboard.WIND
)
@dp.message_handler(commands=['sun_time'])
async def show_sun_time(message: types.Message):
await message.answer(
text=messages.sun_time(),
reply_markup=inline_keyboard.SUN_TIME
)
@dp.callback_query_handler(text='weather')
async def process_callback_weather(callback_query: types.CallbackQuery):
await bot.answer_callback_query(callback_query.id)
await bot.send_message(
callback_query.from_user.id,
text=messages.weather(),
reply_markup=inline_keyboard.WEATHER
)
@dp.callback_query_handler(text='wind')
async def callback_wind(callback_query: types.CallbackQuery):
await bot.answer_callback_query(callback_query.id)
await bot.send_message(
callback_query.from_user.id,
text=messages.wind(),
reply_markup=inline_keyboard.WIND
)
@dp.callback_query_handler(text='sun_time')
async def callbacl_sun_time(callback_query: types.CallbackQuery):
await bot.answer_callback_query(callback_query.id)
await bot.send_message(
callback_query.from_user.id,
text=messages.sun_time(),
reply_markup=inline_keyboard.SUN_TIME
)
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)