GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BotCommand.match()   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 4
dl 0
loc 5
rs 9.2
1
import telegram
2
3
4
class CommandError(Exception):
5
    pass
6
7
8
class BotCommand(object):
9
    command = None
10
11
    def __init__(self, bot, *args, **kwargs):
12
        self.bot = bot
13
        self._db = self.bot.db
14
15
    def __call__(self, message, *args, **kwargs):
16
        return self.default(message, *args, **kwargs)
17
18
    def queue(self, message, next_cmd):
19
        if isinstance(message.chat, telegram.user.User):
20
            # This is a direct chat with a user, reply to message will not
21
            # get populated. Instead wait for the message with id msg+1
22
            msg_id = message.message_id+1
23
        else:
24
            msg_id = message.message_id
25
        self.bot.queue['{}_{}'.format(message.chat.id, msg_id)] = next_cmd
26
27
    @classmethod
28
    def match(cls, message):
29
        if cls.command and message.text and message.text.startswith(cls.command):
30
            return True
31
        return False
32
33
    def get_tab(self, tab_id):
34
        return self._db.get_or_create_tab(tab_id)[0]
35