<commit_before>from irc3.plugins.command import command
import irc3


@irc3.plugin
class Bar(object):
    def __init__(self, bot):
        self.bot = bot

    @command(permission='admin')
    def addtobar(self, mask, target, args):
        '''add <item> with <text> to bar

            %%addtobar <item> <text>...
        '''
        key = args['<item>']
        value = ' '.join(args['<text>'])
        if self in self.bot.db:
            self.bot.db[self][key] = value
        else:
            self.bot.db[self] = {key: value}
        return 'Successfully added {} to bar!'.format(key)

    @command(permission='admin')
    def removefrombar(self, mask, target, args):
        '''remove <item> from bar

            %%removefrombar <item>
        '''
        if self not in self.bot.db:
            return 'No items in bar!'
        if args['<item>'] in self.bot.db[self]:
            del self.bot.db[self][args['<item>']]
            return 'Successfully removed {} from bar!'.format(args['<item>'])
        else:
            return 'Bar doesn\'t contain this item!'

    @command
    def bar(self, mask, target, args):
        '''get all items in bar or return specific value

            %%bar [<item>]
        '''
        if self in self.bot.db:
            item = args['<item>']
            if item is not None:
                # get specific argument
                if item in self.bot.db[self]:
                    return self.bot.db[self][item]
                else:
                    return 'My bar doesn\'t contain this item!'
            else:
                # list bar
                keys = self.bot.db[self].keys()
                if len(keys) >= 1:
                    return ', '.join(keys)
        return 'No items in bar!'<commit_msg>add _ and give-command _<item> => access <item> !give <nick> <item> => "give" <item> to <nick><commit_after>from irc3.plugins.command import command
import irc3


@irc3.plugin
class Bar(object):
    def __init__(self, bot):
        self.bot = bot

    @command(permission='admin')
    def addtobar(self, mask, target, args):
        '''add <item> with <text> to bar

            %%addtobar <item> <text>...
        '''
        key = args['<item>'].lower()
        value = ' '.join(args['<text>'])
        if self in self.bot.db:
            self.bot.db[self][key] = value
        else:
            self.bot.db[self] = {key: value}
        return 'Successfully added {} to bar!'.format(key)

    @command(permission='admin')
    def removefrombar(self, mask, target, args):
        '''remove <item> from bar

            %%removefrombar <item>
        '''
        if self not in self.bot.db:
            return 'No items in bar!'
        item = args['<item>'].lower()
        if item in self.bot.db[self]:
            del self.bot.db[self][item]
            return 'Successfully removed {} from bar!'.format(item)
        else:
            return 'Bar doesn\'t contain this item!'

    @command
    def bar(self, mask, target, args):
        '''get all items in bar
            if you want to access an specific item, use _<item>
            or if you want to "give" an item to a user use !give <nick> <item>

            %%bar [<item>]
        '''
        if self in self.bot.db:
            # list bar
            keys = self.bot.db[self].keys()
            if len(keys) >= 1:
                return ', '.join(keys)
        return 'No items in bar!'

    @command
    def give(self, mask, target, args):
        '''"give" an item to an specific user

            %%give <nick> <item>
        '''
        if self in self.bot.db and len(self.bot.db[self]) >= 1:
            item = args['<item>']
            if item in self.bot.db[self]:
                return '{}: {}'.format(args['<nick>'], self.bot.db[self][item])
            else:
                return 'Bar doesn\'t contain this item!'
        return 'No items in bar!'

    @irc3.event(irc3.rfc.PRIVMSG)
    def bar_get(self, mask=None, event=None, target=None, data=None):
        if data.startswith('_'):
            item = data.split()[0][1:]
            if item in self.bot.db[self]:
                self.bot.privmsg(target, self.bot.db[self][item])
{'fraction_non_alphanumeric': 0.1434396737826817, 'fraction_numerical': 0.0031182537778843846, 'mean_word_length': 1.7634194831013916, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 44, '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': '541113', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1231, 'n_words': 366}