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

Complexity

Total Complexity 8

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
dl 0
loc 34
rs 10
c 3
b 0
f 0
wmc 8

4 Methods

Rating   Name   Duplication   Size   Complexity  
A handle_message() 0 8 4
A _handle_repost() 0 11 2
A _pick_response() 0 7 1
A handle_say() 0 3 1
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