<commit_before>require 'json'
require 'abstraction'

class Bot
    abstract
    attr_reader :config_file, :flag

    def initialize(config_path, name, father_bot = nil, flag = 'f')
        unless father_bot.nil?
            @id = father_bot.id
            @api = father_bot.api
        end
        
        @flag = flag
        @name = name
        @config_file = config_path + @name + "." + @id + ".json" 
        @Markup_empty = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: [])
        @user_cmds = {"def_cmd" => :def_cmd, "help" => :help, "start" => :start}
        
        load_config()
    end

    def load_config
        @config = JSON.parse(File.read(@config_file))
    end

    def update_config
        File.open(@config_file, "w") do |f|
            f.write(@config.to_json)
        end
    end
    
    def get_id
        @id
    end

    def get_config
        @config
    end

    def get_flag
        @flag
    end

    def get_name
        @name
    end

    def get_api
        @api
    end

    def get_user_cmds
        @user_cmds
    end
 
    def user_usage
        "<b>User usage:</b>" + get_user_cmds.map{ |k, v| 
            "<code>#{k}</code>\n#{get_method_usage(v)}" if k!= "def_cmd"
        }.drop(1).join("\n")
    end
    
    def get_method_usage(methode_name)
        "Override me !"
        #eval "@@" + methode_name.to_s + "_usage"
    end

    
    def usage_prefix
        "My prefix is '#{get_flag}'"
    end

    def short_usage
        "- #{usage_prefix} and you can show my help with '/#{get_flag} help'"
    end

    def usage(chat_id)
        usage = user_usage

        <<~HEREDOC
            Help for <b>#{name}</b> :
            #{usage_prefix}
            #{usage}
        HEREDOC

    end<commit_msg>\n after User command help title<commit_after>require 'json'
require 'abstraction'

class Bot
    abstract
    attr_reader :config_file, :flag

    def initialize(config_path, name, father_bot = nil, flag = 'f')
        unless father_bot.nil?
            @id = father_bot.id
            @api = father_bot.api
        end
        
        @flag = flag
        @name = name
        @config_file = config_path + @name + "." + @id + ".json" 
        @Markup_empty = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: [])
        @user_cmds = {"def_cmd" => :def_cmd, "help" => :help, "start" => :start}
        
        load_config()
    end

    def load_config
        @config = JSON.parse(File.read(@config_file))
    end

    def update_config
        File.open(@config_file, "w") do |f|
            f.write(@config.to_json)
        end
    end
    
    def get_id
        @id
    end

    def get_config
        @config
    end

    def get_flag
        @flag
    end

    def get_name
        @name
    end

    def get_api
        @api
    end

    def get_user_cmds
        @user_cmds
    end
 
    def user_usage
        "<b>User usage:</b>\n" + get_user_cmds.map{ |k, v| 
            "<code>#{k}</code>\n#{get_method_usage(v)}" if k!= "def_cmd"
        }.drop(1).join("\n")
    end
    
    def get_method_usage(methode_name)
        "Override me !"
        #eval "@@" + methode_name.to_s + "_usage"
    end

    
    def usage_prefix
        "My prefix is '#{get_flag}'"
    end

    def short_usage
        "- #{usage_prefix} and you can show my help with '/#{get_flag} help'"
    end

    def usage(chat_id)
        usage = user_usage

        <<~HEREDOC
            Help for <b>#{name}</b> :
            #{usage_prefix}
            #{usage}
        HEREDOC

    end
{'fraction_non_alphanumeric': 0.1187728679988742, 'fraction_numerical': 0.0005629045876723895, 'mean_word_length': 1.7338461538461538, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '3410045', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1195, 'n_words': 274}