示例#1
0
文件: quest.py 项目: kyroskoh/pajbot
    def on_stream_stop(self):
        if self.current_quest is None:
            log.info('No quest active on stream stop.')
            return False

        self.current_quest.stop_quest()
        self.current_quest = None
        self.bot.say('Stream ended, quest has been reset.')

        redis = RedisManager.get()

        # Remove any mentions of the current quest
        redis.delete(self.current_quest_key)

        last_stream_id = StreamHelper.get_last_stream_id()
        if last_stream_id is False:
            log.error('No last stream ID found.')
            # No last stream ID found. why?
            return False

        # XXX: Should we use a pipeline for any of this?
        # Go through user tokens and remove any from more than 2 streams ago
        for key in redis.keys('{streamer}:*:tokens'.format(streamer=StreamHelper.get_streamer())):
            all_tokens = redis.hgetall(key)
            for stream_id_str in all_tokens:
                try:
                    stream_id = int(stream_id_str)
                except (TypeError, ValueError):
                    log.error('Invalid stream id in tokens by {}'.format(key))
                    continue

                if last_stream_id - stream_id > 1:
                    log.info('Removing tokens for stream {}'.format(stream_id))
                    redis.hdel(key, stream_id)
示例#2
0
文件: quest.py 项目: cubelious/pajbot
    def on_stream_stop(self):
        if self.current_quest is None:
            log.info('No quest active on stream stop.')
            return False

        self.current_quest.stop_quest()
        self.current_quest = None
        self.bot.say('Stream ended, quest has been reset.')

        redis = RedisManager.get()

        # Remove any mentions of the current quest
        redis.delete(self.current_quest_key)

        last_stream_id = StreamHelper.get_last_stream_id()
        if last_stream_id is False:
            log.error('No last stream ID found.')
            # No last stream ID found. why?
            return False

        # XXX: Should we use a pipeline for any of this?
        # Go through user tokens and remove any from more than 2 streams ago
        for key in redis.keys('{streamer}:*:tokens'.format(streamer=StreamHelper.get_streamer())):
            all_tokens = redis.hgetall(key)
            for stream_id_str in all_tokens:
                try:
                    stream_id = int(stream_id_str)
                except (TypeError, ValueError):
                    log.error('Invalid stream id in tokens by {}'.format(key))
                    continue

                if last_stream_id - stream_id > 1:
                    log.info('Removing tokens for stream {}'.format(stream_id))
                    redis.hdel(key, stream_id)
示例#3
0
文件: quest.py 项目: zneix/pajbot
    def on_stream_stop(self, **rest):
        if self.current_quest is None:
            log.info("No quest active on stream stop.")
            return False

        if not self.current_quest_key:
            log.error(
                "Current quest key not set when on_stream_stop event fired, something is wrong"
            )
            return False

        self.current_quest.stop_quest()
        self.current_quest = None
        self.bot.say("Stream ended, quest has been reset.")

        redis = RedisManager.get()

        # Remove any mentions of the current quest
        redis.delete(self.current_quest_key)

        last_stream_id = StreamHelper.get_last_stream_id()
        if last_stream_id is False:
            log.error("No last stream ID found.")
            # No last stream ID found. why?
            return False

        return True
示例#4
0
    def on_stream_stop(self):
        if self.current_quest is None:
            log.info('No quest active on stream stop.')
            return False

        self.current_quest.stop_quest()
        self.current_quest = None
        self.bot.say('Stream ended, quest has been reset.')

        redis = RedisManager.get()

        # Remove any mentions of the current quest
        redis.delete(self.current_quest_key)

        last_stream_id = StreamHelper.get_last_stream_id()
        if last_stream_id is False:
            log.error('No last stream ID found.')
            # No last stream ID found. why?
            return False
示例#5
0
文件: quest.py 项目: smackedhs/pajbot
    def on_stream_stop(self):
        if self.current_quest is None:
            log.info('No quest active on stream stop.')
            return False

        self.current_quest.stop_quest()
        self.current_quest = None
        self.bot.say('Stream ended, quest has been reset.')

        redis = RedisManager.get()

        # Remove any mentions of the current quest
        redis.delete(self.current_quest_key)

        last_stream_id = StreamHelper.get_last_stream_id()
        if last_stream_id is False:
            log.error('No last stream ID found.')
            # No last stream ID found. why?
            return False