<commit_before>from tenyksservice import TenyksService, run_service


class AFK(TenyksService):
    direct_only = False
    irc_message_filters = {
        'depart': [r'^(?i)(xopa|away|afk|brb)'],
        'return': [r'^(?i)(xoka|back)']
    }

    def handle_depart(self, data, match):
        self.logger.debug('{nick} went AFK.'.format(nick=data['nick']))
        self.send('{nick} is now AFK.'.format(nick=data['nick']), data)

    def handle_return(self, data, match):
        self.logger.debug('{nick} is no longer AFK.'.format(nick=data['nick']))
        self.send('{nick} is no longer AFK.'.format(nick=data['nick']), data)


def main():
    run_service(AFK)


if __name__ == '__main__':
    main()<commit_msg>Add ability to query if a user is away<commit_after>from tenyksservice import TenyksService, run_service

away = {}

class AFK(TenyksService):
    direct_only = False
    irc_message_filters = {
        'depart': [r'^(?i)(xopa|away|afk|brb)'],
        'return': [r'^(?i)(xoka|back)'],
        'query': [r'(?P<nick>(.*))\?$']
    }

    def handle_depart(self, data, match):
        self.logger.debug('{nick} went AFK.'.format(nick=data['nick']))
        self.send('{nick} is now AFK.'.format(nick=data['nick']), data)
        away[data['nick']] = True

    def handle_return(self, data, match):
        self.logger.debug('{nick} is no longer AFK.'.format(nick=data['nick']))
        self.send('{nick} is no longer AFK.'.format(nick=data['nick']), data)
        away[data['nick']] = False

    def handle_query(self, data, match):
        nick = match.groupdict()['nick']

        if nick in away:
            status = 'AFK' if away[nick] else 'present'
            self.logger.debug('{nick} is currently {status}'.format(nick=nick, status=status))
            self.send('{nick} is currently {status}.'.format(nick=nick, status=status), data)
        else:
            self.logger.debug('{nick}\' status is unknown.'.format(nick=nick))
            self.send('{nick}\'s status is unknown.'.format(nick=nick), data)


def main():
    run_service(AFK)


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.18346007604562736, 'fraction_numerical': 0.0, 'mean_word_length': 3.2871690427698574, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1740292', 'n_tokens_mistral': 739, 'n_tokens_neox': 718, 'n_words': 147}