<commit_before>from yapsy.ConfigurablePluginManager import ConfigurablePluginManager
import configparser


PLUGIN_CONFIG_NAME="plugins.conf"

class TelegramPluginManager(ConfigurablePluginManager):
    def __init__(self, bot):
        self.config = configparser.ConfigParser()
        self.config.read(PLUGIN_CONFIG_NAME)

        super().__init__(configparser_instance = self.config, 
                         config_change_trigger = lambda :self.save_config(),
                         directories_list = ["plugins"] )

        self.bot = bot

    def save_config(self):
        with open(PLUGIN_CONFIG_NAME, 'w') as f:
            self.config.write(f)
            return True
        return False

    def activatePluginByName(self, plugin_name, category_name="Default", save_state=True):
        plugin_object = super().activatePluginByName(plugin_name, category_name, save_state)

        if plugin_object:
            plugin_object.set_bot(self.bot)
            plugin_object.set_plugin_manager(self)
            self.name = None
            self.category_name = None
            return plugin_object
        
        return None
    
        <commit_msg>Actually assigning name and category to plugins when activated<commit_after>from yapsy.ConfigurablePluginManager import ConfigurablePluginManager
import configparser


PLUGIN_CONFIG_NAME="plugins.conf"

class TelegramPluginManager(ConfigurablePluginManager):
    def __init__(self, bot):
        self.config = configparser.ConfigParser()
        self.config.read(PLUGIN_CONFIG_NAME)

        super().__init__(configparser_instance = self.config, 
                         config_change_trigger = lambda :self.save_config(),
                         directories_list = ["plugins"] )

        self.bot = bot

    def save_config(self):
        with open(PLUGIN_CONFIG_NAME, 'w') as f:
            self.config.write(f)
            return True
        return False

    def activatePluginByName(self, plugin_name, category_name="Default", save_state=True):
        plugin_object = super().activatePluginByName(plugin_name, category_name, save_state)

        if plugin_object:
            plugin_object.set_bot(self.bot)
            plugin_object.set_plugin_manager(self)
            self.name = plugin_name
            self.category_name = category_name
            return plugin_object
        
        return None
    
        
{'fraction_non_alphanumeric': 0.07373271889400922, 'fraction_numerical': 0.0, 'mean_word_length': 2.537777777777778, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4086185', 'n_tokens_mistral': 639, 'n_tokens_neox': 620, 'n_words': 122}