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   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 27
Duplicated Lines 0 %
Metric Value
dl 0
loc 27
rs 10
wmc 9

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __call__() 0 2 1
A queue() 0 8 2
A __init__() 0 3 1
A match() 0 5 4
A get_tab() 0 2 1
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