Total Complexity | 7 |
Total Lines | 80 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
2 | # pylint: disable=R0401 |
||
3 | |||
4 | """Processing commands received from telegram bot""" |
||
5 | |||
6 | from app.bot.telegram import bot, msg, cbq |
||
7 | from app.bot.telegram.handlers.commands import bot_cmd_start, bot_cmd_gle, bot_cmd_log |
||
8 | from app.bot.telegram.handlers.messages import bot_text_messages_handler |
||
9 | from app.bot.telegram.handlers.inline import bot_callback_inline |
||
10 | from app.decorators import logging_time |
||
11 | |||
12 | |||
13 | @bot.message_handler(commands=["start"]) |
||
14 | @logging_time |
||
15 | def command_start(message: msg): |
||
16 | """ |
||
17 | Handle command /start |
||
18 | :param message: |
||
19 | :return: |
||
20 | """ |
||
21 | bot_cmd_start(message) |
||
22 | |||
23 | |||
24 | @bot.message_handler( |
||
25 | commands=[ |
||
26 | "g", |
||
27 | "e", |
||
28 | "gle", |
||
29 | "gleci", |
||
30 | ] |
||
31 | ) |
||
32 | @logging_time |
||
33 | def command_gleci(message: msg): |
||
34 | """ |
||
35 | Handle command /gleci |
||
36 | :param message: |
||
37 | :return: |
||
38 | """ |
||
39 | bot_cmd_gle(message) |
||
40 | |||
41 | |||
42 | @bot.message_handler( |
||
43 | commands=[ |
||
44 | "l", |
||
45 | "log", |
||
46 | "logli", |
||
47 | ] |
||
48 | ) |
||
49 | @logging_time |
||
50 | def command_logli(message: msg): |
||
51 | """ |
||
52 | Handle command /logli |
||
53 | :param message: |
||
54 | :return: |
||
55 | """ |
||
56 | bot_cmd_log(message) |
||
57 | |||
58 | |||
59 | @bot.message_handler(regexp="/[a-z]+") |
||
60 | @bot.message_handler(func=lambda message: True, content_types=["text"]) |
||
61 | @logging_time |
||
62 | def cpx_messages_handler(message: msg): |
||
63 | """ |
||
64 | All text requests to the bot are processed by this function |
||
65 | :param message: |
||
66 | :return: |
||
67 | """ |
||
68 | bot_text_messages_handler(message) |
||
69 | |||
70 | |||
71 | @bot.callback_query_handler(func=lambda call: True) |
||
72 | @logging_time |
||
73 | def callback_inline(call: cbq): |
||
74 | """ |
||
75 | All inline requests are processed by this function |
||
76 | :param call: Incoming inline request |
||
77 | :return: |
||
78 | """ |
||
79 | bot_callback_inline(call) |
||
80 |