<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

def plugs(bot, msg):
    if msg.user != bot.owner:
        return
    split = msg.msg.split(' ')
    if len(split) < 2:
        return;
    if split[0] == '!plug':
        if bot.plugins.load(split[1],bot):
            bot.sendChannelMessage(msg.replyTo, 'Loaded %s' % split[1])
        else:
            bot.sendChannelMessage(msg.replyTo, 'Couldn\'t load %s' % split[1])
    elif split[0] == '!unplug':
        if bot.plugins.unload(split[1],bot):
            bot.sendChannelMessage(msg.replyTo, 'Unloaded %s' % split[1])
        else:
            bot.sendChannelMessage(msg.replyTo, 'Couldn\'t unload %s' % split[1])

def init(bot):
    bot.events.register('channelMessage',plugs)

def close(bot):
    bot.events.unregister('channelMessage',plugs)<commit_msg>made the plugin loading plugin catch exceptions loading plugins<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

def plugs(bot, msg):
    if msg.user != bot.owner:
        return
    split = msg.msg.split(' ')
    if len(split) < 2:
        return;

    #(re)load plugin
    if split[0] == '!plug':
        plugName = split[1]
        try:
            if bot.plugins.load(plugName,bot):
                bot.sendChannelMessage(msg.replyTo, 'Loaded %s' % plugName)
                return
        except Exception as ex:
            pass

        #plugin couldn't be loaded
        bot.sendChannelMessage(msg.replyTo, 'Couldn\'t load %s' % plugName)
        return

    #unload plugin
    elif split[0] == '!unplug':
        try:
            if bot.plugins.unload(split[1],bot):
                bot.sendChannelMessage(msg.replyTo, 'Unloaded %s' % plugName)
                return
        except Exception as ex:
            pass
        #plugin couldn't be properly unloaded
        bot.sendChannelMessage(msg.replyTo, 'Couldn\'t unload %s' % plugName)

def init(bot):
    bot.events.register('channelMessage',plugs)

def close(bot):
    bot.events.unregister('channelMessage',plugs)
{'fraction_non_alphanumeric': 0.1410064773293473, 'fraction_numerical': 0.007972097658196313, 'mean_word_length': 2.330016583747927, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4691933', 'n_tokens_mistral': 649, 'n_tokens_neox': 634, 'n_words': 139}