예제 #1
0
    def __init__(self, Hakcbot):
        self.Hakcbot = Hakcbot

        self.hakcusr = USER_TUPLE(
            'hakcbot', False, False, False,
            False, True, fast_time()
        )
예제 #2
0
    def recently_announced(self, prior_announcement):
        if (not prior_announcement): return False

        current_time = fast_time()
        if (current_time - prior_announcement > ANNOUNCEMENT_INTERVAL):
            return False

        return True
예제 #3
0
    async def _message_handler(self, data):
        loop, user = asyncio.get_running_loop(), None
        if (data == 'PING :tmi.twitch.tv'):
            await loop.sock_sendall(self.sock, 'PONG :tmi.twitch.tv\r\n'.encode('utf-8'))

        elif ('PRIVMSG' in data):
            valid_data = await self.Spam.pre_process(data)
            if (not valid_data): return

            self.linecount += 1
            self.last_message = fast_time()
            user, message = valid_data

            # function will check if already in progress before sending to the queue
            self.AccountAge.add_to_queue(user)
            await self.Execute.task_handler(user, message)

        # placeholder for when i want to track joins/ see if a user joins
        elif ('JOIN' in data):
            L.l3(data)

        # probably a bunk ass message, not sure????? should protect higher tier titles for now.
        else:
            L.l3(f'else: {data}')
            return

        # T2 TITLES
        if (not user): return
        try:
            titled_user = self.titles[user.name] # pylint: disable=no-member
        except KeyError:
            pass
        else:
            prior_announcement = self.announced_titles.get(user.name, None)
            if titled_user['tier'] == 2 and not self.recently_announced(prior_announcement):

                # already announced users - type > set()
                self.announced_titles[user.name] = fast_time()

                # announcing the user to chat
                if (self.online):
                    await self.announce_title(user.name, titled_user['title'])
예제 #4
0
    async def reset_line_count(self):
        time_elapsed = fast_time() - self.Hakcbot.last_message
        if (time_elapsed > FIVE_MIN):
            self.Hakcbot.linecount = 0

        return FIVE_MIN
    def permit(self, usr):
        self.Hakcbot.Spam.permit_list[usr.lower()] = fast_time() + THREE_MIN
        message = f'/untimeout {usr}'
        response = f'{usr}, you can now post links for 3 minutes.'

        return message, response
예제 #6
0
    def on_cooldown(cls, c_name):
        cd_time = cls._COMMANDS.get(c_name, None)
        if (fast_time() <= cd_time): return True

        return False