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.

PsywerxHistory._pick_response()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
from base import PsywerxPlugin
2
from response import REPOSTS, MULTIPLE_REPOST, \
3
    SELF_REPOSTS, MULTIPLE_SELF_REPOST, random_response
4
5
6
class PsywerxHistory(PsywerxPlugin):
7
8
    def handle_message(self, channel, nick, msg, line=None):
9
        r = self.request(channel, 'irc/add', {'raw': line})
10
        if not r:
11
            return
12
        if r.startswith('REPOST'):
13
            self._handle_repost(r, channel)
14
        elif r != 'OK':
15
            self.bot.log_error("Response not OK: " + r)
16
17
    def handle_say(self, channel, msg, line):
18
        msg = ":" + self.bot.nick + "!~" + self.bot.nick + "@6.6.6.6 " + line
19
        self.request(channel, 'irc/add', {'raw': msg})
20
21
    def _handle_repost(self, r, channel):
22
        _, nick, repost_nick, message_type, num = r.split(' ')
23
        if message_type != 'M':
24
            return
25
26
        response = self._pick_response(nick == repost_nick, int(num) > 1)
27
        self.bot.say(response % {
28
            'nick': nick,
29
            'repost_nick': repost_nick,
30
            'num': num,
31
        }, channel)
32
33
    @staticmethod
34
    def _pick_response(is_self, is_multiple):
35
        f = [
36
            [REPOSTS, MULTIPLE_REPOST],
37
            [SELF_REPOSTS, MULTIPLE_SELF_REPOST],
38
        ]
39
        return random_response(f[is_self][is_multiple])
40