Exemple #1
0
def bas_config_init():
    """
    Initialization of configuration file.
    Sections: buffer.
    """
    global bas_config_file, bas_options
    bas_config_file = weechat.config_new(CONFIG_FILE_NAME,
                                         "bas_config_reload_cb", "")
    if bas_config_file == "":
        return

    # section "look"
    section_look = weechat.config_new_section(
        bas_config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "")
    if not section_look:
        weechat.config_free(bas_config_file)
        return

    # options in section "look"
    bas_options["look_timer"] = weechat.config_new_option(
        bas_config_file, section_look, "timer", "integer",
        "Timer used to delay the set of properties (in milliseconds, "
        "0 = don't use a timer)",
        "", 0, 2147483647, "1", "1", 0, "", "", "", "", "", "")

    # section "buffer"
    section_buffer = weechat.config_new_section(
        bas_config_file, "buffer", 1, 1, "", "", "", "", "", "",
        "bas_config_buffer_create_option_cb", "", "", "")
    if not section_buffer:
        weechat.config_free(bas_config_file)
        return
def init_own_config_file():
    # set up configuration options and load config file
    global CONFIG_FILE, CONFIG_SECTIONS
    CONFIG_FILE = weechat.config_new(SCRIPT_NAME, '', '')
    CONFIG_SECTIONS = {}
    CONFIG_SECTIONS['section_name'] = weechat.config_new_section(
        CONFIG_FILE, 'section_name', 0, 0, '', '', '', '', '', '', '', '', '', '')

    for option, typ, desc, default in [
            ('option_name',
             'boolean',
             'option description',
             'off'),
            ('option_name2',
             'boolean',
             'option name2 description ',
             'on'),
            ('option_name3',
             'string',
             'option name3 description',
             ''),
            ('option_name4',
             'string',
             'option name4 description',
             'set an default string here'),
        ]:
        weechat.config_new_option(
            CONFIG_FILE, CONFIG_SECTIONS['section_name'], option, typ, desc, '', 0,
            0, default, default, 0, '', '', '', '', '', '')

    weechat.config_read(CONFIG_FILE)
def bas_config_init():
    """
    Initialization of configuration file.
    Sections: buffer.
    """
    global bas_config_file, bas_options
    bas_config_file = weechat.config_new(CONFIG_FILE_NAME,
                                         "bas_config_reload_cb", "")
    if bas_config_file == "":
        return

    # section "look"
    section_look = weechat.config_new_section(bas_config_file, "look", 0, 0,
                                              "", "", "", "", "", "", "", "",
                                              "", "")
    if not section_look:
        weechat.config_free(bas_config_file)
        return

    # options in section "look"
    bas_options["look_timer"] = weechat.config_new_option(
        bas_config_file, section_look, "timer", "integer",
        "Timer used to delay the set of properties (in milliseconds, "
        "0 = don't use a timer)", "", 0, 2147483647, "1", "1", 0, "", "", "",
        "", "", "")

    # section "buffer"
    section_buffer = weechat.config_new_section(
        bas_config_file, "buffer", 1, 1, "", "", "", "", "", "",
        "bas_config_buffer_create_option_cb", "", "", "")
    if not section_buffer:
        weechat.config_free(bas_config_file)
        return
Exemple #4
0
def theme_config_init():
    """Initialization of configuration file. Sections: ???."""
    global theme_config_file, theme_config_option
    theme_config_file = weechat.config_new(THEME_CONFIG_FILE_NAME,
                                           'theme_config_reload_cb', '')
    if not theme_config_file:
        return
    
    # section "color"
    section_color = weechat.config_new_section(
        theme_config_file, 'color', 0, 0, '', '', '', '', '', '', '', '', '', '')
    if not section_color:
        weechat.config_free(theme_config_file)
        return
    theme_config_option['color_script'] = weechat.config_new_option(
        theme_config_file, section_color,
        'script', 'color', 'Color for script names', '', 0, 0,
        'cyan', 'cyan', 0, '', '', '', '', '', '')
    theme_config_option['color_installed'] = weechat.config_new_option(
        theme_config_file, section_color,
        'installed', 'color', 'Color for "installed" indicator', '', 0, 0,
        'yellow', 'yellow', 0, '', '', '', '', '', '')
    theme_config_option['color_running'] = weechat.config_new_option(
        theme_config_file, section_color,
        'running', 'color', 'Color for "running" indicator', '', 0, 0,
        'lightgreen', 'lightgreen', 0, '', '', '', '', '', '')
    theme_config_option['color_obsolete'] = weechat.config_new_option(
        theme_config_file, section_color,
        'obsolete', 'color', 'Color for "obsolete" indicator', '', 0, 0,
        'lightmagenta', 'lightmagenta', 0, '', '', '', '', '', '')
    theme_config_option['color_unknown'] = weechat.config_new_option(
        theme_config_file, section_color,
        'unknown', 'color', 'Color for "unknown status" indicator', '', 0, 0,
        'lightred', 'lightred', 0, '', '', '', '', '', '')
    theme_config_option['color_language'] = weechat.config_new_option(
        theme_config_file, section_color,
        'language', 'color', 'Color for language names', '', 0, 0,
        'lightblue', 'lightblue', 0, '', '', '', '', '', '')
    
    # section "themes"
    section_themes = weechat.config_new_section(
        theme_config_file, 'themes', 0, 0, '', '', '', '', '', '', '', '', '', '')
    if not section_themes:
        weechat.config_free(theme_config_file)
        return
    theme_config_option['themes_url'] = weechat.config_new_option(
        theme_config_file, section_themes,
        'url', 'string', 'URL for file with list of themes', '', 0, 0,
        'http://www.weechat.org/files/themes.json.gz',
        'http://www.weechat.org/files/themes.json.gz', 0, '', '', '', '', '', '')
    theme_config_option['themes_cache_expire'] = weechat.config_new_option(
        theme_config_file, section_themes,
        'cache_expire', 'integer', 'Local cache expiration time, in minutes '
        '(-1 = never expires, 0 = always expires)', '',
        -1, 60*24*365, '60', '60', 0, '', '', '', '', '', '')
    theme_config_option['themes_dir'] = weechat.config_new_option(
        theme_config_file, section_themes,
        'dir', 'string', 'Local directory for themes', '', 0, 0,
        '%h/themes', '%h/themes', 0, '', '', '', '', '', '')
	def __init__(self, filename):
		''' Initialize the configuration. '''

		self.filename         = filename
		self.config_file      = weechat.config_new(self.filename, '', '')
		self.sorting_section  = None

		self.case_sensitive   = False
		self.group_irc        = True
		self.rules            = []
		self.highest          = 0

		self.__case_sensitive = None
		self.__group_irc      = None
		self.__rules          = None

		if not self.config_file:
			log('Failed to initialize configuration file "{}".'.format(self.filename))
			return

		self.sorting_section = weechat.config_new_section(self.config_file, 'sorting', False, False, '', '', '', '', '', '', '', '', '', '')

		if not self.sorting_section:
			log('Failed to initialize section "sorting" of configuration file.')
			weechat.config_free(self.config_file)
			return

		self.__case_sensitive = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'case_sensitive', 'boolean',
			'If this option is on, sorting is case sensitive.',
			'', 0, 0, 'off', 'off', 0,
			'', '', '', '', '', ''
		)

		self.__group_irc = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'group_irc', 'boolean',
			'If this option is on, the script pretends that IRC channel/private buffers are renamed to "irc.server.{network}.{channel}" rather than "irc.{network}.{channel}".' +
			'This ensures that thsee buffers are grouped with their respective server buffer.',
			'', 0, 0, 'on', 'on', 0,
			'', '', '', '', '', ''
		)

		self.__rules = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'rules', 'string',
			'An ordered list of sorting rules encoded as JSON. See /help autosort for commands to manipulate these rules.',
			'', 0, 0, Config.default_rules, Config.default_rules, 0,
			'', '', '', '', '', ''
		)

		if weechat.config_read(self.config_file) != weechat.WEECHAT_RC_OK:
			log('Failed to load configuration file.')

		if weechat.config_write(self.config_file) != weechat.WEECHAT_RC_OK:
			log('Failed to write configuration file.')

		self.reload()
Exemple #6
0
def webex_config_init():
    """ Initialize config file: create sections and options in memory. """
    global webex_config_file, webex_config_section, webex_config_option

    # This will create webex.conf file
    webex_config_file = weechat.config_new(SCRIPT_NAME,
                                           "webex_config_reload_cb", "")
    if not webex_config_file:
        return

    # server section
    webex_config_section["server"] = weechat.config_new_section(
        webex_config_file, "server", 0, 0, "", "", "", "", "", "", "", "", "",
        "")

    webex_config_option["access_token"] = weechat.config_new_option(
        webex_config_file, webex_config_section["server"], "access_token",
        "string", "Access Token", "", 0, 0, "token", "token", 0, "", "", "",
        "", "", "")
    webex_config_option["autojoin"] = weechat.config_new_option(
        webex_config_file, webex_config_section["server"], "autojoin",
        "string", "Autojoin rooms when a new message comes in (yes/no)", "", 0,
        0, "no", "no", 0, "", "", "", "", "", "")
    webex_config_option["autojoin_last"] = weechat.config_new_option(
        webex_config_file, webex_config_section["server"], "autojoin_last",
        "integer", "Autojoin this number of rooms/chats (0 to disable)", "", 0,
        100, "0", "0", 0, "", "", "", "", "", "")
    webex_config_option["autojoin_rooms"] = weechat.config_new_option(
        webex_config_file, webex_config_section["server"], "autojoin_rooms",
        "string", "Rooms to join on startup", "", 0, 0, "", "", 0, "", "", "",
        "", "", "")
    webex_config_option["autojoin_directs"] = weechat.config_new_option(
        webex_config_file, webex_config_section["server"], "autojoin_directs",
        "string", "1:1 chats to open on startup", "", 0, 0, "", "", 0, "", "",
        "", "", "", "")
    webex_config_option["default_domain"] = weechat.config_new_option(
        webex_config_file, webex_config_section["server"], "default_domain",
        "string", "Default domain for emails.", "", 0, 0, "", "", 0, "", "",
        "", "", "", "")
    webex_config_option["node_bin_path"] = weechat.config_new_option(
        webex_config_file, webex_config_section["server"], "node_bin_path",
        "string", "The path to 'node' binary", "", 0, 0, "/usr/local/bin/node",
        "/usr/local/bin/node", 0, "", "", "", "", "", "")
    webex_config_option["websocket_proxy_app"] = weechat.config_new_option(
        webex_config_file, webex_config_section["server"],
        "websocket_proxy_app", "string",
        "The path to websocket proxy application 'app.js'", "", 0, 0,
        "/opt/hookbuster/app.js", "/opt/hookbuster/app.js", 0, "", "", "", "",
        "", "")
    webex_config_option["port"] = weechat.config_new_option(
        webex_config_file, webex_config_section["server"], "port", "integer",
        "The port used to create the socket (for incoming message using websocket)",
        "", 1, 65535, "8080", "8080", 0, "", "", "", "", "", "")
    webex_config_option["debug"] = weechat.config_new_option(
        webex_config_file, webex_config_section["server"], "debug", "string",
        "debug mode (yes/no)", "", 0, 0, "no", "no", 0, "", "", "", "", "", "")
Exemple #7
0
    def __init__(self, filename):
        ''' Initialize the configuration. '''

        self.filename = filename
        self.config_file = weechat.config_new(self.filename, '', '')
        self.sorting_section = None

        self.case_sensitive = False
        self.group_irc = True
        self.rules = []
        self.highest = 0

        self.__case_sensitive = None
        self.__group_irc = None
        self.__rules = None

        if not self.config_file:
            log('Failed to initialize configuration file "{}".'.format(
                self.filename))
            return

        self.sorting_section = weechat.config_new_section(
            self.config_file, 'sorting', False, False, '', '', '', '', '', '',
            '', '', '', '')

        if not self.sorting_section:
            log('Failed to initialize section "sorting" of configuration file.'
                )
            weechat.config_free(config_file)
            return

        self.__case_sensitive = weechat.config_new_option(
            self.config_file, self.sorting_section, 'case_sensitive',
            'boolean', 'If this option is on, sorting is case sensitive.', '',
            0, 0, 'off', 'off', 0, '', '', '', '', '', '')

        self.__group_irc = weechat.config_new_option(
            self.config_file, self.sorting_section, 'group_irc', 'boolean',
            'If this option is on, the script pretends that IRC channel/private buffers are renamed to "irc.server.{network}.{channel}" rather than "irc.{network}.{channel}".'
            +
            'This ensures that thsee buffers are grouped with their respective server buffer.',
            '', 0, 0, 'on', 'on', 0, '', '', '', '', '', '')

        self.__rules = weechat.config_new_option(
            self.config_file, self.sorting_section, 'rules', 'string',
            'An ordered list of sorting rules encoded as JSON. See /help autosort for commands to manipulate these rules.',
            '', 0, 0, Config.default_rules, Config.default_rules, 0, '', '',
            '', '', '', '')

        if weechat.config_read(self.config_file) != weechat.WEECHAT_RC_OK:
            log('Failed to load configuration file.')

        if weechat.config_write(self.config_file) != weechat.WEECHAT_RC_OK:
            log('Failed to write configuration file.')

        self.reload()
Exemple #8
0
def fish_config_init():
    global fish_config_file, fish_config_section, fish_config_option

    fish_config_file = weechat.config_new(CONFIG_FILE_NAME,
                                          "fish_config_reload_cb", "")
    if not fish_config_file:
        return

    # look
    fish_config_section["look"] = weechat.config_new_section(
        fish_config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "")
    if not fish_config_section["look"]:
        weechat.config_free(fish_config_file)
        return

    fish_config_option["announce"] = weechat.config_new_option(
        fish_config_file, fish_config_section["look"], "announce", "boolean",
        "annouce if messages are being encrypted or not", "", 0, 0, "on", "on",
        0, "", "", "", "", "", "")
    fish_config_option["marker"] = weechat.config_new_option(
        fish_config_file, fish_config_section["look"], "marker", "string",
        "marker for important FiSH messages", "", 0, 0, "O<", "O<", 0, "", "",
        "", "", "", "")

    fish_config_option["mark_position"] = weechat.config_new_option(
        fish_config_file, fish_config_section["look"], "mark_position",
        "integer",
        "put marker for encrypted INCOMING messages at start or end",
        "off|begin|end", 0, 2, "off", "off", 0, "", "", "", "", "", "")

    fish_config_option["mark_encrypted"] = weechat.config_new_option(
        fish_config_file, fish_config_section["look"], "mark_encrypted",
        "string", "marker for encrypted INCOMING messages", "", 0, 0, "*", "*",
        0, "", "", "", "", "", "")

    # color
    fish_config_section["color"] = weechat.config_new_section(
        fish_config_file, "color", 0, 0, "", "", "", "", "", "", "", "", "",
        "")
    if not fish_config_section["color"]:
        weechat.config_free(fish_config_file)
        return

    fish_config_option["alert"] = weechat.config_new_option(
        fish_config_file, fish_config_section["color"], "alert", "color",
        "color for important FiSH message markers", "", 0, 0, "lightblue",
        "lightblue", 0, "", "", "", "", "", "")

    # keys
    fish_config_section["keys"] = weechat.config_new_section(
        fish_config_file, "keys", 0, 0, "fish_config_keys_read_cb", "",
        "fish_config_keys_write_cb", "", "", "", "", "", "", "")
    if not fish_config_section["keys"]:
        weechat.config_free(fish_config_file)
        return
Exemple #9
0
def fish_config_init():
    global fish_config_file, fish_config_section, fish_config_option

    fish_config_file = weechat.config_new(CONFIG_FILE_NAME,
            "fish_config_reload_cb", "")
    if not fish_config_file:
        return

    # look
    fish_config_section["look"] = weechat.config_new_section(fish_config_file,
            "look", 0, 0, "", "", "", "", "", "", "", "", "", "")
    if not fish_config_section["look"]:
        weechat.config_free(fish_config_file)
        return

    fish_config_option["announce"] = weechat.config_new_option(
            fish_config_file, fish_config_section["look"], "announce",
            "boolean", "annouce if messages are being encrypted or not", "", 0,
            0, "on", "on", 0, "", "", "", "", "", "")
    fish_config_option["marker"] = weechat.config_new_option(
            fish_config_file, fish_config_section["look"], "marker",
            "string", "marker for important FiSH messages", "", 0, 0,
            "O<", "O<", 0, "", "", "", "", "", "")

    fish_config_option["mark_position"] = weechat.config_new_option(
            fish_config_file, fish_config_section["look"], "mark_position",
            "integer", "put marker for encrypted INCOMING messages at start or end", "off|begin|end",
            0,2, "off", "off", 0, "", "", "", "", "", "")

    fish_config_option["mark_encrypted"] = weechat.config_new_option(
            fish_config_file, fish_config_section["look"], "mark_encrypted",
            "string", "marker for encrypted INCOMING messages", "", 0, 0,
            "*", "*", 0, "", "", "", "", "", "")

    # color
    fish_config_section["color"] = weechat.config_new_section(fish_config_file,
            "color", 0, 0, "", "", "", "", "", "", "", "", "", "")
    if not fish_config_section["color"]:
        weechat.config_free(fish_config_file)
        return

    fish_config_option["alert"] = weechat.config_new_option(
            fish_config_file, fish_config_section["color"], "alert",
            "color", "color for important FiSH message markers", "", 0, 0,
            "lightblue", "lightblue", 0, "", "", "", "", "", "")

    # keys
    fish_config_section["keys"] = weechat.config_new_section(fish_config_file,
            "keys", 0, 0,
            "fish_config_keys_read_cb", "",
            "fish_config_keys_write_cb", "", "",
            "", "", "", "", "")
    if not fish_config_section["keys"]:
        weechat.config_free(fish_config_file)
        return
Exemple #10
0
def execbot_config_init():
    '''Init configuration file'''
    global execbot_config_file
    execbot_config_file = weechat.config_new('execbot', 'execbot_config_reload_cb', '')
    if not execbot_config_file:
        return

    execbot_config_section['allows'] = weechat.config_new_section(
        execbot_config_file, 'allows', 0, 0, 'execbot_config_allows_read_cb', '',
        'execbot_config_allows_write_cb', '', '', '', '', '', '', '')
    if not execbot_config_section['allows']:
        weechat.config_free(execbot_config_file)
Exemple #11
0
def execbot_config_init():
    '''Init configuration file'''
    global execbot_config_file
    execbot_config_file = weechat.config_new('execbot', 'execbot_config_reload_cb', '')
    if not execbot_config_file:
        return

    execbot_config_section['allows'] = weechat.config_new_section(
        execbot_config_file, 'allows', 0, 0, 'execbot_config_allows_read_cb', '',
        'execbot_config_allows_write_cb', '', '', '', '', '', '', '')
    if not execbot_config_section['allows']:
        weechat.config_free(execbot_config_file)
Exemple #12
0
def theme_config_init():
    """Initialization of configuration file. Sections: color, themes."""
    global theme_cfg_file, theme_cfg
    theme_cfg_file = weechat.config_new(THEME_CONFIG_FILENAME,
                                        'theme_config_reload_cb', '')

    # section "color"
    section = weechat.config_new_section(
        theme_cfg_file, 'color', 0, 0,
        '', '', '', '', '', '', '', '', '', '')
    theme_cfg['color_script'] = weechat.config_new_option(
        theme_cfg_file, section, 'script', 'color',
        'Color for script names', '', 0, 0,
        'cyan', 'cyan', 0, '', '', '', '', '', '')
    theme_cfg['color_installed'] = weechat.config_new_option(
        theme_cfg_file, section, 'installed', 'color',
        'Color for "installed" indicator', '', 0, 0,
        'yellow', 'yellow', 0, '', '', '', '', '', '')
    theme_cfg['color_running'] = weechat.config_new_option(
        theme_cfg_file, section, 'running', 'color',
        'Color for "running" indicator', '', 0, 0,
        'lightgreen', 'lightgreen', 0, '', '', '', '', '', '')
    theme_cfg['color_obsolete'] = weechat.config_new_option(
        theme_cfg_file, section, 'obsolete', 'color',
        'Color for "obsolete" indicator', '', 0, 0,
        'lightmagenta', 'lightmagenta', 0, '', '', '', '', '', '')
    theme_cfg['color_unknown'] = weechat.config_new_option(
        theme_cfg_file, section, 'unknown', 'color',
        'Color for "unknown status" indicator', '', 0, 0,
        'lightred', 'lightred', 0, '', '', '', '', '', '')
    theme_cfg['color_language'] = weechat.config_new_option(
        theme_cfg_file, section, 'language', 'color',
        'Color for language names', '', 0, 0,
        'lightblue', 'lightblue', 0, '', '', '', '', '', '')

    # section "themes"
    section = weechat.config_new_section(
        theme_cfg_file, 'themes', 0, 0,
        '', '', '', '', '', '', '', '', '', '')
    theme_cfg['themes_url'] = weechat.config_new_option(
        theme_cfg_file, section,
        'url', 'string', 'URL for file with themes (.tar.bz2 file)', '', 0, 0,
        THEME_URL, THEME_URL, 0, '', '', '', '', '', '')
    theme_cfg['themes_cache_expire'] = weechat.config_new_option(
        theme_cfg_file, section,
        'cache_expire', 'integer', 'Local cache expiration time, in minutes '
        '(-1 = never expires, 0 = always expires)', '',
        -1, 60 * 24 * 365, '60', '60', 0, '', '', '', '', '', '')
    theme_cfg['themes_dir'] = weechat.config_new_option(
        theme_cfg_file, section,
        'dir', 'string', 'Local directory for themes', '', 0, 0,
        '%h/themes', '%h/themes', 0, '', '', '', '', '', '')
Exemple #13
0
def colorize_config_init():
    '''
    Initialization of configuration file.
    Sections: look.
    '''
    global colorize_config_file, colorize_config_option
    colorize_config_file = weechat.config_new(CONFIG_FILE_NAME,
                                              "", "")
    if colorize_config_file == "":
        return

    # section "look"
    section_look = weechat.config_new_section(
        colorize_config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "")
    if section_look == "":
        weechat.config_free(colorize_config_file)
        return
    colorize_config_option["blacklist_channels"] = weechat.config_new_option(
        colorize_config_file, section_look, "blacklist_channels",
        "string", "Comma separated list of channels", "", 0, 0,
        "", "", 0, "", "", "", "", "", "")
    colorize_config_option["blacklist_nicks"] = weechat.config_new_option(
        colorize_config_file, section_look, "blacklist_nicks",
        "string", "Comma separated list of nicks", "", 0, 0,
        "so,root", "so,root", 0, "", "", "", "", "", "")
    colorize_config_option["min_nick_length"] = weechat.config_new_option(
        colorize_config_file, section_look, "min_nick_length",
        "integer", "Minimum length nick to colorize", "",
        2, 20, "", "", 0, "", "", "", "", "", "")
    colorize_config_option["colorize_input"] = weechat.config_new_option(
        colorize_config_file, section_look, "colorize_input",
        "boolean", "Whether to colorize input", "", 0,
        0, "off", "off", 0, "", "", "", "", "", "")
    colorize_config_option["ignore_tags"] = weechat.config_new_option(
        colorize_config_file, section_look, "ignore_tags",
        "string", "Comma separated list of tags to ignore; i.e. irc_join,irc_part,irc_quit", "", 0, 0,
        "", "", 0, "", "", "", "", "", "")
    colorize_config_option["greedy_matching"] = weechat.config_new_option(
        colorize_config_file, section_look, "greedy_matching",
        "boolean", "If off, then use lazy matching instead", "", 0,
        0, "on", "on", 0, "", "", "", "", "", "")
    colorize_config_option["match_limit"] = weechat.config_new_option(
        colorize_config_file, section_look, "match_limit",
        "integer", "Fall back to lazy matching if greedy matches exceeds this number", "",
        20, 1000, "", "", 0, "", "", "", "", "", "")
    colorize_config_option["ignore_nicks_in_urls"] = weechat.config_new_option(
        colorize_config_file, section_look, "ignore_nicks_in_urls",
        "boolean", "If on, don't colorize nicks inside URLs", "", 0,
        0, "off", "off", 0, "", "", "", "", "", "")
Exemple #14
0
def initialize_config(name):
    global config
    config = {}
    global config_file
    config_file = weechat.config_new(name, 'my_config_reload_cb', '')
    global config_values
    config_values = {}
    global config_keys
    config_keys = {
            'strings' : ['url', 'streams', 'stream_options', 'format']
            #'integers' : ['time_delay']
            }
    # Available colors
    global colors
    colors = ['white' , 'black', 'blue', 'green', 'lighred', 'red',
            'magenta', 'brown', 'yellow', 'lightgreen', 'cyan',
            'lightcyan', 'lightblue', 'lightmagenta', 'darkgray', 'gray']

    if not config_file:
        return
    section = weechat.config_new_section(config_file, 'config', 0,0, '', '', '', '', '', '', '', '', '', '')
    config['url'] = weechat.config_new_option(config_file, section,
            'icecast_json_url', 'string', 'http directory for /status-json.xsl',
            '', 0, 0,
            'http://icecast.nashgul.com.es/status-json.xsl', 'http://icecast.nashgul.com.es/status-json.xsl', 1,
            '', '',
            'load_str_vars_cb', '',
            '', '')
    config['streams'] = weechat.config_new_option(config_file, section,
            'streams', 'string', 'mounts to show (without slash and separated by commas)',
            '', 0, 0,
            'nashgul', 'nashgul', 1,
            'check_mounts_cb', '',
            'load_str_vars_cb', '',
            '', '')
    config['stream_options'] = weechat.config_new_option(config_file, section,
            'stream_options', 'string', 'stream options to show',
            '', 0, 0,
            'url,artist,title,listeners', 'url,artist,title,listeners', 1,
            '', '',
            'load_str_vars_cb', '',
            '', '')
    config['format'] = weechat.config_new_option(config_file, section,
            'output_format', 'string', 'Output string format (%s: attribute, %\'color\'; i.e.: Now playing on %red%s: %blue%s - %s - %s)',
            '', 0, 0,
            '%redAhora suena en %cyan%s%yellow: %lightblue%s %yellow- %lightblue%s %yellow( %magentaOyentes%yellow: %lightblue%s %yellow)', '%lightredAhora suena en %cyan%s%yellow: %lightblue%s %yellow- %lightblue%s %yellow( %magentaOyentes%yellow: %lightblue%s %yellow)', 1,
            '', '',
            'load_str_vars_cb', '',
            '', '')
Exemple #15
0
def theme_config_init():
    """Initialization of configuration file. Sections: color, themes."""
    global theme_cfg_file, theme_cfg
    theme_cfg_file = weechat.config_new(THEME_CONFIG_FILENAME,
                                        'theme_config_reload_cb', '')

    # section "color"
    section = weechat.config_new_section(theme_cfg_file, 'color', 0, 0, '', '',
                                         '', '', '', '', '', '', '', '')
    theme_cfg['color_script'] = weechat.config_new_option(
        theme_cfg_file, section, 'script', 'color', 'Color for script names',
        '', 0, 0, 'cyan', 'cyan', 0, '', '', '', '', '', '')
    theme_cfg['color_installed'] = weechat.config_new_option(
        theme_cfg_file, section, 'installed', 'color',
        'Color for "installed" indicator', '', 0, 0, 'yellow', 'yellow', 0, '',
        '', '', '', '', '')
    theme_cfg['color_running'] = weechat.config_new_option(
        theme_cfg_file, section, 'running', 'color',
        'Color for "running" indicator', '', 0, 0, 'lightgreen', 'lightgreen',
        0, '', '', '', '', '', '')
    theme_cfg['color_obsolete'] = weechat.config_new_option(
        theme_cfg_file, section, 'obsolete', 'color',
        'Color for "obsolete" indicator', '', 0, 0, 'lightmagenta',
        'lightmagenta', 0, '', '', '', '', '', '')
    theme_cfg['color_unknown'] = weechat.config_new_option(
        theme_cfg_file, section, 'unknown', 'color',
        'Color for "unknown status" indicator', '', 0, 0, 'lightred',
        'lightred', 0, '', '', '', '', '', '')
    theme_cfg['color_language'] = weechat.config_new_option(
        theme_cfg_file, section, 'language', 'color',
        'Color for language names', '', 0, 0, 'lightblue', 'lightblue', 0, '',
        '', '', '', '', '')

    # section "themes"
    section = weechat.config_new_section(theme_cfg_file, 'themes', 0, 0, '',
                                         '', '', '', '', '', '', '', '', '')
    theme_cfg['themes_url'] = weechat.config_new_option(
        theme_cfg_file, section, 'url', 'string',
        'URL for file with themes (.tar.bz2 file)', '', 0, 0, THEME_URL,
        THEME_URL, 0, '', '', '', '', '', '')
    theme_cfg['themes_cache_expire'] = weechat.config_new_option(
        theme_cfg_file, section, 'cache_expire', 'integer',
        'Local cache expiration time, in minutes '
        '(-1 = never expires, 0 = always expires)', '', -1, 60 * 24 * 365,
        '60', '60', 0, '', '', '', '', '', '')
    theme_cfg['themes_dir'] = weechat.config_new_option(
        theme_cfg_file, section, 'dir', 'string', 'Local directory for themes',
        '', 0, 0, '%h/themes', '%h/themes', 0, '', '', '', '', '', '')
def ircrypt_config_init():
	''' This method initializes the configuration file. It creates sections and
	options in memory and prepares the handling of key sections.
	'''
	global ircrypt_config_file, ircrypt_config_section, ircrypt_config_option
	ircrypt_config_file = weechat.config_new('ircrypt-keyex', 'ircrypt_config_reload_cb', '')
	if not ircrypt_config_file:
		return

	# public key identifier
	ircrypt_config_section['asym_id'] = weechat.config_new_section(
			ircrypt_config_file, 'asym_id', 0, 0,
			'ircrypt_config_asym_id_read_cb', '',
			'ircrypt_config_asym_id_write_cb', '', '', '', '', '', '', '')
	if not ircrypt_config_section['asym_id']:
		weechat.config_free(ircrypt_config_file)
Exemple #17
0
def initialize_config(name):
    global config
    config = {}
    global config_file
    config_file = weechat.config_new(name, 'my_config_reload_cb', '')
    global config_values
    config_values = {}
    global config_keys
    config_keys = {
        'strings': ['url', 'streams', 'stream_options', 'format']
        #'integers' : ['time_delay']
    }
    # Available colors
    global colors
    colors = [
        'white', 'black', 'blue', 'green', 'lighred', 'red', 'magenta',
        'brown', 'yellow', 'lightgreen', 'cyan', 'lightcyan', 'lightblue',
        'lightmagenta', 'darkgray', 'gray'
    ]

    if not config_file:
        return
    section = weechat.config_new_section(config_file, 'config', 0, 0, '', '',
                                         '', '', '', '', '', '', '', '')
    config['url'] = weechat.config_new_option(
        config_file, section, 'icecast_json_url', 'string',
        'http directory for /status-json.xsl', '', 0, 0,
        'http://icecast.nashgul.com.es/status-json.xsl',
        'http://icecast.nashgul.com.es/status-json.xsl', 1, '', '',
        'load_str_vars_cb', '', '', '')
    config['streams'] = weechat.config_new_option(
        config_file, section, 'streams', 'string',
        'mounts to show (without slash and separated by commas)', '', 0, 0,
        'nashgul', 'nashgul', 1, 'check_mounts_cb', '', 'load_str_vars_cb', '',
        '', '')
    config['stream_options'] = weechat.config_new_option(
        config_file, section, 'stream_options', 'string',
        'stream options to show', '', 0, 0, 'url,artist,title,listeners',
        'url,artist,title,listeners', 1, '', '', 'load_str_vars_cb', '', '',
        '')
    config['format'] = weechat.config_new_option(
        config_file, section, 'output_format', 'string',
        'Output string format (%s: attribute, %\'color\'; i.e.: Now playing on %red%s: %blue%s - %s - %s)',
        '', 0, 0,
        '%redAhora suena en %cyan%s%yellow: %lightblue%s %yellow- %lightblue%s %yellow( %magentaOyentes%yellow: %lightblue%s %yellow)',
        '%lightredAhora suena en %cyan%s%yellow: %lightblue%s %yellow- %lightblue%s %yellow( %magentaOyentes%yellow: %lightblue%s %yellow)',
        1, '', '', 'load_str_vars_cb', '', '', '')
Exemple #18
0
def bas_config_init():
    """
    Initialization of configuration file.
    Sections: buffer.
    """
    global bas_config_file
    bas_config_file = weechat.config_new(CONFIG_FILE_NAME, "bas_config_reload_cb", "")
    if bas_config_file == "":
        return

    # section "buffer"
    section_buffer = weechat.config_new_section(
        bas_config_file, "buffer", 1, 1, "", "", "", "", "", "", "bas_config_buffer_create_option_cb", "", "", ""
    )
    if section_buffer == "":
        weechat.config_free(bas_config_file)
        return
def colorize_config_init():
    '''
    Initialization of configuration file.
    Sections: look.
    '''
    global colorize_config_file, colorize_config_option
    colorize_config_file = weechat.config_new(CONFIG_FILE_NAME,
                                              "colorize_config_reload_cb", "")
    if colorize_config_file == "":
        return

    # section "look"
    section_look = weechat.config_new_section(
        colorize_config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "")
    if section_look == "":
        weechat.config_free(colorize_config_file)
        return
    colorize_config_option["blacklist_channels"] = weechat.config_new_option(
        colorize_config_file, section_look, "blacklist_channels",
        "string", "Comma separated list of channels", "", 0, 0,
        "", "", 0, "", "", "", "", "", "")
    colorize_config_option["blacklist_nicks"] = weechat.config_new_option(
        colorize_config_file, section_look, "blacklist_nicks",
        "string", "Comma separated list of nicks", "", 0, 0,
        "so,root", "so,root", 0, "", "", "", "", "", "")
    colorize_config_option["min_nick_length"] = weechat.config_new_option(
        colorize_config_file, section_look, "min_nick_length",
        "integer", "Minimum length nick to colorize", "",
        2, 20, "", "", 0, "", "", "", "", "", "")
    colorize_config_option["colorize_input"] = weechat.config_new_option(
        colorize_config_file, section_look, "colorize_input",
        "boolean", "Whether to colorize input", "", 0,
        0, "off", "off", 0, "", "", "", "", "", "")
    colorize_config_option["ignore_tags"] = weechat.config_new_option(
        colorize_config_file, section_look, "ignore_tags",
        "string", "Comma separated list of tags to ignore; i.e. irc_join,irc_part,irc_quit", "", 0, 0,
        "", "", 0, "", "", "", "", "", "")
    colorize_config_option["greedy_matching"] = weechat.config_new_option(
        colorize_config_file, section_look, "greedy_matching",
        "boolean", "If off, then use lazy matching instead", "", 0,
        0, "on", "on", 0, "", "", "", "", "", "")
    colorize_config_option["ignore_nicks_in_urls"] = weechat.config_new_option(
        colorize_config_file, section_look, "ignore_nicks_in_urls",
        "boolean", "If on, don't colorize nicks inside URLs", "", 0,
        0, "off", "off", 0, "", "", "", "", "", "")
Exemple #20
0
def bas_config_init():
    """
    Initialization of configuration file.
    Sections: buffer.
    """
    global bas_config_file
    bas_config_file = weechat.config_new(CONFIG_FILE_NAME,
                                         "bas_config_reload_cb", "")
    if bas_config_file == "":
        return

    # section "buffer"
    section_buffer = weechat.config_new_section(
        bas_config_file, "buffer", 1, 1, "", "", "", "", "", "",
        "bas_config_buffer_create_option_cb", "", "", "")
    if section_buffer == "":
        weechat.config_free(bas_config_file)
        return
Exemple #21
0
    def setup_config_file(self):
        """Initialize the configuration."""
        config_file = weechat.config_new(
            self._config_name,
            self._reload_cb,
            self._reload_cb_data)

        if not config_file:
            return None

        for section in SCRIPT_CONFIG:
            config_section = weechat.config_new_section(
                config_file,
                section,
                0, 0, "", "", "", "", "", "", "", "", "", ""
            )

            if not config_section:
                weechat.config_free(config_file)
                return None

            for option_name, props in SCRIPT_CONFIG[section].items():
                weechat.config_new_option(
                    config_file,
                    config_section,
                    option_name,
                    props['type'],
                    props['desc'],
                    props['string_values'],
                    props['min'],
                    props['max'],
                    props['default'],
                    props['default'],
                    0,
                    props['check_cb'],
                    "",
                    props['change_cb'],
                    props['change_data'],
                    props['delete_cb'],
                    ""
                )

        return config_file
Exemple #22
0
def multirpg_config_init():
    global multirpg_config_file, multirpg_config_option
    multirpg_config_file = weechat.config_new(CONFIG_FILE_NAME, "", "")
    if multirpg_config_file == "":
        return
    section_multirpg = weechat.config_new_section(multirpg_config_file,
                                                  "multirpg", 0, 0, "", "", "",
                                                  "", "", "", "", "", "", "")
    if section_multirpg == "":
        weechat.config_free(multirpg_config_file)
        return
    multirpg_config_option["mynick"] = weechat.config_new_option(
        multirpg_config_file, section_multirpg, "mynick", "string",
        "multirpg nickname", "", 0, 0, "", "", 0, "", "", "", "", "", "")
    multirpg_config_option["myclass"] = weechat.config_new_option(
        multirpg_config_file, section_multirpg, "myclass", "string",
        "multirpg class", "", 0, 0, "", "", 0, "", "", "", "", "", "")
    multirpg_config_option["ircserver"] = weechat.config_new_option(
        multirpg_config_file, section_multirpg, "ircserver", "string",
        "multirpg ircserver", "", 0, 0, "", "", 0, "", "", "", "", "", "")
Exemple #23
0
def config_init():
    """
    Initialization of configuration file.
    Sections: buffer.
    """
    global config_file, options
    config_file = weechat.config_new(CONFIG_FILE_NAME, "config_reload_cb", "")
    if config_file == "":
        return

    # section "buffer"
    section_buffer = weechat.config_new_section(
        config_file, "buffer", 1, 1, "", "", "", "", "", "",
        "config_buffer_create_option_cb", "", "", "")
    if not section_buffer:
        weechat.config_free(config_file)
        return
    options["favorites"] = weechat.config_new_option(
        config_file, section_buffer, "favorites", "string",
        "comma-delimited list of favorite rooms", "", 0, 0, "", "", 0, "", "",
        "", "", "", "")
Exemple #24
0
def init_own_config_file():
    # set up configuration options and load config file
    global CONFIG_FILE, CONFIG_SECTIONS
    CONFIG_FILE = weechat.config_new(SCRIPT_NAME, '', '')
    CONFIG_SECTIONS = {}
    CONFIG_SECTIONS['section_name'] = weechat.config_new_section(
        CONFIG_FILE, 'section_name', 0, 0, '', '', '', '', '', '', '', '', '',
        '')

    for option, typ, desc, default in [
        ('option_name', 'boolean', 'option description', 'off'),
        ('option_name2', 'boolean', 'option name2 description ', 'on'),
        ('option_name3', 'string', 'option name3 description', ''),
        ('option_name4', 'string', 'option name4 description',
         'set an default string here'),
    ]:
        weechat.config_new_option(CONFIG_FILE, CONFIG_SECTIONS['section_name'],
                                  option, typ, desc, '', 0, 0, default,
                                  default, 0, '', '', '', '', '', '')

    weechat.config_read(CONFIG_FILE)
def jmh_config_init():
    """ Initialize config file: create sections and options in memory. """
    global jmh_config_file, jmh_config_section
    jmh_config_file = weechat.config_new("jabber_message_handler",
            "jmh_config_reload_cb", "")
    if not jmh_config_file:
        return
    # options
    jmh_config_section["options"] = weechat.config_new_section(
        jmh_config_file, "options", 0, 0, "", "", "", "", "",
        "", "", "", "", "")
    if not jmh_config_section["options"]:
        weechat.config_free(jmh_config_file)
        return
    # prototype option = weechat.config_new_option(
    #    config_file, section,
    #    name, type, description,
    #    string_values, min, max, default_value, value, null_value_allowed,
    #    callback_check_value, callback_check_value_data,
    #    callback_change, callback_change_data,
    #    callback_delete, callback_delete_data)
    jmh_config_option["enabled"] = weechat.config_new_option(
        jmh_config_file, jmh_config_section["options"],
        "enabled", "boolean", "jabber_message_handler service enabled",
        "", 0, 0, "off", "off", 0,
        "", "", "", "", "", "")
    jmh_config_option["log"] = weechat.config_new_option(
        jmh_config_file, jmh_config_section["options"],
        "log", "string", "jabber_message_handler events log file",
        "", 0, 0, "~/.weechat/logs/events", "~/.weechat/logs/events", 0,
        "", "", "", "", "", "")
    jmh_config_option["verbose"] = weechat.config_new_option(
        jmh_config_file, jmh_config_section["options"],
        "verbose", "boolean", "set verbose on/off",
        "", 0, 0, "off", "off", 0,
        "", "", "", "", "", "")
Exemple #26
0
            msg = ' '.join(arglist[2:])
            server.getChatByRecipient(groups[0], groups[1], create = True).send(msg)
        else :
            weechat.prnt(buffer, 'Message recipient must be of type login_x[:fd]')
    elif arglist[0] == 'who' and server.isConnected() and len(arglist) > 1 :
        server._ns_user_cmd_who(arglist[1])
    elif arglist[0] == 'state' and server.isConnected() and len(arglist) > 1 :
        server._ns_state(arglist[1])
    else :
        weechat.prnt(buffer, '%sNo such command, wrong argument count, or you need to (dis)connect' % weechat.prefix('error'))
    return weechat.WEECHAT_RC_OK

######################################
# Main
######################################

if __name__ == "__main__" :
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', 'weeNS_script_unload_cb'):
        weechat.hook_command('ns', 'weeNetsoul main command', 'connect | disconnect | send <login> <msg> | state <status> | who <login>',
                             "    connect : Connect\n"
                             " disconnect : Diconnect\n"
                             "       send : Send <msg> to <login> (any client) or to <:fd> (unique client)\n"
                             "      state : Change status to <status> (en ligne/actif/whatever)\n"
                             "        who : Show infos about <login>\n",
                             'connect|disconnect|send|state|who', 'weeNS_hook_cmd_ns', '')
        weeNS_config_file = weechat.config_new(SCRIPT_NAME, '', '')
        weeNS_config_server_section = weechat.config_new_section(weeNS_config_file, 'server', 0, 0, 'weeNS_server_section_read_cb', '', '', '',  '', '', '', '', '', '')
        server = weeNSServer()
        weechat.config_read(weeNS_config_file)
        weechat.config_write(weeNS_config_file)
Exemple #27
0
def ircrypt_config_init():
	''' This method initializes the configuration file. It creates sections and
	options in memory and prepares the handling of key sections.
	'''
	global ircrypt_config_file
	ircrypt_config_file = weechat.config_new('ircrypt', 'ircrypt_config_reload_cb', '')
	if not ircrypt_config_file:
		return

	# marker
	ircrypt_config_section['marker'] = weechat.config_new_section(
			ircrypt_config_file, 'marker', 0, 0, '', '', '', '', '', '', '', '',
			'', '')
	if not ircrypt_config_section['marker']:
		weechat.config_free(ircrypt_config_file)
		return
	ircrypt_config_option['encrypted'] = weechat.config_new_option(
			ircrypt_config_file, ircrypt_config_section['marker'],
			'encrypted', 'string', 'Marker for encrypted messages', '', 0, 0,
			'encrypted', 'encrypted', 0, '', '', '', '', '', '')
	ircrypt_config_option['unencrypted'] = weechat.config_new_option(
			ircrypt_config_file, ircrypt_config_section['marker'], 'unencrypted',
			'string', 'Marker for unencrypted messages received in an encrypted channel',
			'', 0, 0, '', 'u', 0, '', '', '', '', '', '')

	# cipher options
	ircrypt_config_section['cipher'] = weechat.config_new_section(
			ircrypt_config_file, 'cipher', 0, 0, '', '', '', '', '', '', '', '',
			'', '')
	if not ircrypt_config_section['cipher']:
		weechat.config_free(ircrypt_config_file)
		return
	ircrypt_config_option['sym_cipher'] = weechat.config_new_option(
			ircrypt_config_file, ircrypt_config_section['cipher'],
			'sym_cipher', 'string', 'symmetric cipher used by default', '', 0, 0,
			'TWOFISH', 'TWOFISH', 0, '', '', '', '', '', '')

	# general options
	ircrypt_config_section['general'] = weechat.config_new_section(
			ircrypt_config_file, 'general', 0, 0, '', '', '', '', '', '', '', '',
			'', '')
	if not ircrypt_config_section['general']:
		weechat.config_free(ircrypt_config_file)
		return
	ircrypt_config_option['binary'] = weechat.config_new_option(
			ircrypt_config_file, ircrypt_config_section['general'],
			'binary', 'string', 'GnuPG binary to use', '', 0, 0,
			'', '', 0, '', '', '', '', '', '')

	# keys
	ircrypt_config_section['keys'] = weechat.config_new_section(
			ircrypt_config_file, 'keys', 0, 0, 'ircrypt_config_keys_read_cb', '',
			'ircrypt_config_keys_write_cb', '', '', '', '', '', '', '')
	if not ircrypt_config_section['keys']:
		weechat.config_free(ircrypt_config_file)

	# Special Ciphers
	ircrypt_config_section['special_cipher'] = weechat.config_new_section(
			ircrypt_config_file, 'special_cipher', 0, 0,
			'ircrypt_config_special_cipher_read_cb', '',
			'ircrypt_config_special_cipher_write_cb', '', '', '', '', '', '', '')
	if not ircrypt_config_section['special_cipher']:
		weechat.config_free(ircrypt_config_file)
Exemple #28
0
    def __init__(
            self,
            filename=CONFIG_FILE_NAME,
            mailpath=str(pathlib.Path().home().joinpath("mail", "inbox")),
    ):

        self._config_file = None
        self._section_conf = None
        self._is_read = False
        self._mail_dir = None
        self._bar_text = None
        self._log_to_weechat = None
        self._interval = None

        self._config_file = weechat.config_new(filename, "", "")
        if self._config_file == "":
            weechat.prnt(
                "",
                f"{weechat.prefix('error')} Error reading check_mail config")
            return

        self._section_conf = weechat.config_new_section(
            self._config_file, "conf", 0, 0, "", "", "", "", "", "", "", "",
            "", "")

        if self._section_conf == "":
            weechat.config_free(self._config_file)
            weechat.prnt(
                "", f"{weechat.prefix('error')} Error check_mail conf section")
            return

        # No keyword argument support =(
        self._mail_dir = weechat.config_new_option(
            self._config_file,
            self._section_conf,
            "maildir_path",
            "string",
            "Path of mail directory",
            "",
            0,
            0,
            mailpath,
            mailpath,
            0,
            "",
            "",
            "",
            "",
            "",
            "",
        )

        self._interval = weechat.config_new_option(
            self._config_file,
            self._section_conf,
            "interval",
            "integer",
            "Interval in seconds for triggering check mail",
            "",
            0,
            9999999,
            "1",
            "1",
            0,
            "",
            "",
            "",
            "",
            "",
            "",
        )

        self._bar_text = weechat.config_new_option(
            self._config_file,
            self._section_conf,
            "bar_text",
            "string",
            "Text to display",
            "",
            0,
            0,
            "MI",
            "MI",
            0,
            "",
            "",
            "",
            "",
            "",
            "",
        )

        self._log_to_weechat = weechat.config_new_option(
            self._config_file,
            self._section_conf,
            "log_to_weechat_buffer",
            "boolean",
            "Log new mails to weechat buffer",
            "",
            0,
            0,
            "on",
            "on",
            0,
            "",
            "",
            "",
            "",
            "",
            "",
        )
        self.reload()
Exemple #29
0
def wg_config_init():
    """
    Initialization of configuration file.
    Sections: color, scripts.
    """
    global wg_config_file, wg_config_option
    wg_config_file = weechat.config_new(CONFIG_FILE_NAME,
                                        "wg_config_reload_cb", "")
    if wg_config_file == "":
        return

    # section "color"
    section_color = weechat.config_new_section(
        wg_config_file, "color", 0, 0, "", "", "", "", "", "", "", "", "", "")
    if section_color == "":
        weechat.config_free(wg_config_file)
        return
    wg_config_option["color_script"] = weechat.config_new_option(
        wg_config_file, section_color,
        "script", "color", "Color for script names", "", 0, 0,
        "cyan", "cyan", 0, "", "", "", "", "", "")
    wg_config_option["color_installed"] = weechat.config_new_option(
        wg_config_file, section_color,
        "installed", "color", "Color for \"installed\" indicator", "", 0, 0,
        "yellow", "yellow", 0, "", "", "", "", "", "")
    wg_config_option["color_running"] = weechat.config_new_option(
        wg_config_file, section_color,
        "running", "color", "Color for \"running\" indicator", "", 0, 0,
        "lightgreen", "lightgreen", 0, "", "", "", "", "", "")
    wg_config_option["color_obsolete"] = weechat.config_new_option(
        wg_config_file, section_color,
        "obsolete", "color", "Color for \"obsolete\" indicator", "", 0, 0,
        "lightmagenta", "lightmagenta", 0, "", "", "", "", "", "")
    wg_config_option["color_unknown"] = weechat.config_new_option(
        wg_config_file, section_color,
        "unknown", "color", "Color for \"unknown status\" indicator", "", 0, 0,
        "lightred", "lightred", 0, "", "", "", "", "", "")
    wg_config_option["color_language"] = weechat.config_new_option(
        wg_config_file, section_color,
        "language", "color", "Color for language names", "", 0, 0,
        "lightblue", "lightblue", 0, "", "", "", "", "", "")

    # section "scripts"
    section_scripts = weechat.config_new_section(
        wg_config_file, "scripts", 0, 0, "", "", "", "", "", "", "", "", "", "")
    if section_scripts == "":
        weechat.config_free(wg_config_file)
        return
    wg_config_option["scripts_url"] = weechat.config_new_option(
        wg_config_file, section_scripts,
        "url", "string", "URL for file with list of plugins", "", 0, 0,
        "http://www.weechat.org/files/plugins.xml.gz",
        "http://www.weechat.org/files/plugins.xml.gz", 0, "", "", "", "", "", "")
    wg_config_option["scripts_dir"] = weechat.config_new_option(
        wg_config_file, section_scripts,
        "dir", "string", "Local cache directory for" + SCRIPT_NAME, "", 0, 0,
        "%h/" + SCRIPT_NAME, "%h/" + SCRIPT_NAME, 0, "", "", "", "", "", "")
    wg_config_option["scripts_cache_expire"] = weechat.config_new_option(
        wg_config_file, section_scripts,
        "cache_expire", "integer", "Local cache expiration time, in minutes "
        "(-1 = never expires, 0 = always expires)", "",
        -1, 60*24*365, "60", "60", 0, "", "", "", "", "", "")
Exemple #30
0
def wg_config_init():
    """
    Initialization of configuration file.
    Sections: color, scripts.
    """
    global wg_config_file, wg_config_option
    wg_config_file = weechat.config_new(CONFIG_FILE_NAME,
                                        "wg_config_reload_cb", "")
    if wg_config_file == "":
        return

    # section "color"
    section_color = weechat.config_new_section(wg_config_file, "color", 0, 0,
                                               "", "", "", "", "", "", "", "",
                                               "", "")
    if section_color == "":
        weechat.config_free(wg_config_file)
        return
    wg_config_option["color_script"] = weechat.config_new_option(
        wg_config_file, section_color, "script", "color",
        "Color for script names", "", 0, 0, "cyan", "cyan", 0, "", "", "", "",
        "", "")
    wg_config_option["color_installed"] = weechat.config_new_option(
        wg_config_file, section_color, "installed", "color",
        "Color for \"installed\" indicator", "", 0, 0, "yellow", "yellow", 0,
        "", "", "", "", "", "")
    wg_config_option["color_running"] = weechat.config_new_option(
        wg_config_file, section_color, "running", "color",
        "Color for \"running\" indicator", "", 0, 0, "lightgreen",
        "lightgreen", 0, "", "", "", "", "", "")
    wg_config_option["color_obsolete"] = weechat.config_new_option(
        wg_config_file, section_color, "obsolete", "color",
        "Color for \"obsolete\" indicator", "", 0, 0, "lightmagenta",
        "lightmagenta", 0, "", "", "", "", "", "")
    wg_config_option["color_unknown"] = weechat.config_new_option(
        wg_config_file, section_color, "unknown", "color",
        "Color for \"unknown status\" indicator", "", 0, 0, "lightred",
        "lightred", 0, "", "", "", "", "", "")
    wg_config_option["color_language"] = weechat.config_new_option(
        wg_config_file, section_color, "language", "color",
        "Color for language names", "", 0, 0, "lightblue", "lightblue", 0, "",
        "", "", "", "", "")

    # section "scripts"
    section_scripts = weechat.config_new_section(wg_config_file, "scripts", 0,
                                                 0, "", "", "", "", "", "", "",
                                                 "", "", "")
    if section_scripts == "":
        weechat.config_free(wg_config_file)
        return
    wg_config_option["scripts_url"] = weechat.config_new_option(
        wg_config_file, section_scripts, "url", "string",
        "URL for file with list of plugins", "", 0, 0,
        "http://www.weechat.org/files/plugins.xml.gz",
        "http://www.weechat.org/files/plugins.xml.gz", 0, "", "", "", "", "",
        "")
    wg_config_option["scripts_dir"] = weechat.config_new_option(
        wg_config_file, section_scripts, "dir", "string",
        "Local cache directory for" + SCRIPT_NAME, "", 0, 0,
        "%h/" + SCRIPT_NAME, "%h/" + SCRIPT_NAME, 0, "", "", "", "", "", "")
    wg_config_option["scripts_cache_expire"] = weechat.config_new_option(
        wg_config_file, section_scripts, "cache_expire", "integer",
        "Local cache expiration time, in minutes "
        "(-1 = never expires, 0 = always expires)", "", -1, 60 * 24 * 365,
        "60", "60", 0, "", "", "", "", "", "")
Exemple #31
0
######################################
# Main
######################################

if __name__ == "__main__":
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENSE, SCRIPT_DESC, '',
                        'wee_ns_script_unload_cb'):
        weechat.hook_completion('ns_send', 'login completion',
                                'wee_ns_hook_completion_send', '')
        weechat.hook_command('ns', 'weeNetsoul: A netsoul plugin for weechat',
                             ' | '.join("%s%s" % (k, "" if 'desc' not in v
                                                  else " " + v['desc'])
                                        for k, v in hook_cmd_ns.items()),
                             '\n'.join("%s: %s" % (k, v['cb'].__doc__)
                                       for k, v in hook_cmd_ns.items()),
                             ' || '.join("%s%s" % (k, "" if 'compl' not in v
                                                   else " " + v['compl'])
                                         for k, v in hook_cmd_ns.items()),
                             'wee_ns_hook_cmd_ns', '')
        wee_ns_config_file = weechat.config_new(SCRIPT_NAME, '', '')
        wee_ns_conf_serv_sect = weechat.config_new_section(wee_ns_config_file,
                                                           'server', 0, 0,
                                                           ('wee_ns_serv_'
                                                            'sect_read_cb'),
                                                           '', '', '', '', '',
                                                           '', '', '', '')
        server = WeeNSServer()
        weechat.config_read(wee_ns_config_file)
        weechat.config_write(wee_ns_config_file)
Exemple #32
0
	def __init__(self, filename):
		''' Initialize the configuration. '''

		self.filename         = filename
		self.config_file      = weechat.config_new(self.filename, '', '')
		self.sorting_section  = None
		self.v3_section       = None

		self.case_sensitive   = False
		self.rules            = []
		self.helpers          = {}
		self.signals          = []
		self.signal_delay     = Config.default_signal_delay,
		self.sort_on_config   = True

		self.__case_sensitive = None
		self.__rules          = None
		self.__helpers        = None
		self.__signals        = None
		self.__signal_delay   = None
		self.__sort_on_config = None

		if not self.config_file:
			log('Failed to initialize configuration file "{0}".'.format(self.filename))
			return

		self.sorting_section = weechat.config_new_section(self.config_file, 'sorting', False, False, '', '', '', '', '', '', '', '', '', '')
		self.v3_section      = weechat.config_new_section(self.config_file, 'v3',      False, False, '', '', '', '', '', '', '', '', '', '')

		if not self.sorting_section:
			log('Failed to initialize section "sorting" of configuration file.')
			weechat.config_free(self.config_file)
			return

		self.__case_sensitive = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'case_sensitive', 'boolean',
			'If this option is on, sorting is case sensitive.',
			'', 0, 0, 'off', 'off', 0,
			'', '', '', '', '', ''
		)

		weechat.config_new_option(
			self.config_file, self.sorting_section,
			'rules', 'string',
			'Sort rules used by autosort v2.x and below. Not used by autosort anymore.',
			'', 0, 0, '', '', 0,
			'', '', '', '', '', ''
		)

		weechat.config_new_option(
			self.config_file, self.sorting_section,
			'replacements', 'string',
			'Replacement patterns used by autosort v2.x and below. Not used by autosort anymore.',
			'', 0, 0, '', '', 0,
			'', '', '', '', '', ''
		)

		self.__rules = weechat.config_new_option(
			self.config_file, self.v3_section,
			'rules', 'string',
			'An ordered list of sorting rules encoded as JSON. See /help autosort for commands to manipulate these rules.',
			'', 0, 0, Config.default_rules, Config.default_rules, 0,
			'', '', '', '', '', ''
		)

		self.__helpers = weechat.config_new_option(
			self.config_file, self.v3_section,
			'helpers', 'string',
			'A dictionary helper variables to use in the sorting rules, encoded as JSON. See /help autosort for commands to manipulate these helpers.',
			'', 0, 0, Config.default_helpers, Config.default_helpers, 0,
			'', '', '', '', '', ''
		)

		self.__signals = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'signals', 'string',
			'A space separated list of signals that will cause autosort to resort your buffer list.',
			'', 0, 0, Config.default_signals, Config.default_signals, 0,
			'', '', '', '', '', ''
		)

		self.__signal_delay = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'signal_delay', 'integer',
			'Delay in milliseconds to wait after a signal before sorting the buffer list. This prevents triggering many times if multiple signals arrive in a short time. It can also be needed to wait for buffer localvars to be available.',
			'', 0, 1000, str(Config.default_signal_delay), str(Config.default_signal_delay), 0,
			'', '', '', '', '', ''
		)

		self.__sort_on_config = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'sort_on_config_change', 'boolean',
			'Decides if the buffer list should be sorted when autosort configuration changes.',
			'', 0, 0, 'on', 'on', 0,
			'', '', '', '', '', ''
		)

		if weechat.config_read(self.config_file) != weechat.WEECHAT_RC_OK:
			log('Failed to load configuration file.')

		if weechat.config_write(self.config_file) != weechat.WEECHAT_RC_OK:
			log('Failed to write configuration file.')

		self.reload()
Exemple #33
0
    else:
        buf = weechat.get_current_buffer()

    server, channel = get_buffer_info(buf)
    dict_key = u'{0}.{1}'.format(server, channel)
    if dict_key in channel_data:
        return "ENC"

    return ""
# }}}


if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
                    SCRIPT_DESC, "", "UTF-8"):
    # load config
    config_file = weechat.config_new(SCRIPT_NAME, 'reload_config_cb', '')
    weechat.config_new_section(config_file, 'keys', 1, 1,
                               'keys_read_option_cb', '',
                               '', '',
                               '', '',
                               'keys_create_option_cb', '',
                               '', '')
    weechat.config_read(config_file)

    weechat.hook_command(SCRIPT_NAME,
                         "change weesodium options",
                         "[enable KEY] || "
                         "[disable]",
                         "",
                         "enable %-|| "
                         "disable",
Exemple #34
0
def init_config():
    """Set up configuration options and load config file."""
    global CONFIG_FILE
    CONFIG_FILE = weechat.config_new(SCRIPT_NAME, 'config_reload_cb', '')

    global CONFIG_SECTIONS
    CONFIG_SECTIONS = {}

    CONFIG_SECTIONS['general'] = weechat.config_new_section(
        CONFIG_FILE, 'general', 0, 0, '', '', '', '', '', '', '', '', '', '')

    for option, typ, desc, default in [
        ('debug', 'boolean', 'OTR script debugging', 'off'),
    ]:
        weechat.config_new_option(CONFIG_FILE, CONFIG_SECTIONS['general'],
                                  option, typ, desc, '', 0, 0, default,
                                  default, 0, '', '', '', '', '', '')

    CONFIG_SECTIONS['color'] = weechat.config_new_section(
        CONFIG_FILE, 'color', 0, 0, '', '', '', '', '', '', '', '', '', '')

    for option, desc, default, update_cb in [
        ('status.default', 'status bar default color', 'default',
         'bar_config_update_cb'),
        ('status.encrypted', 'status bar encrypted indicator color', 'green',
         'bar_config_update_cb'),
        ('status.unencrypted', 'status bar unencrypted indicator color',
         'lightred', 'bar_config_update_cb'),
        ('status.authenticated', 'status bar authenticated indicator color',
         'green', 'bar_config_update_cb'),
        ('status.unauthenticated',
         'status bar unauthenticated indicator color', 'lightred',
         'bar_config_update_cb'),
        ('status.logged', 'status bar logged indicator color', 'lightred',
         'bar_config_update_cb'),
        ('status.notlogged', 'status bar not logged indicator color', 'green',
         'bar_config_update_cb'),
    ]:
        weechat.config_new_option(CONFIG_FILE, CONFIG_SECTIONS['color'],
                                  option, 'color', desc, '', 0, 0, default,
                                  default, 0, '', '', update_cb, '', '', '')

    CONFIG_SECTIONS['look'] = weechat.config_new_section(
        CONFIG_FILE, 'look', 0, 0, '', '', '', '', '', '', '', '', '', '')

    for option, desc, default, update_cb in [
        ('bar.prefix', 'prefix for OTR status bar item', 'OTR:',
         'bar_config_update_cb'),
        ('bar.state.encrypted',
         'shown in status bar when conversation is encrypted', 'SEC',
         'bar_config_update_cb'),
        ('bar.state.unencrypted',
         'shown in status bar when conversation is not encrypted', '!SEC',
         'bar_config_update_cb'),
        ('bar.state.authenticated',
         'shown in status bar when peer is authenticated', 'AUTH',
         'bar_config_update_cb'),
        ('bar.state.unauthenticated',
         'shown in status bar when peer is not authenticated', '!AUTH',
         'bar_config_update_cb'),
        ('bar.state.logged',
         'shown in status bar when peer conversation is being logged to disk',
         'LOG', 'bar_config_update_cb'),
        ('bar.state.notlogged',
         'shown in status bar when peer conversation is not being logged to disk',
         '!LOG', 'bar_config_update_cb'),
        ('bar.state.separator', 'separator for states in the status bar', ',',
         'bar_config_update_cb'),
    ]:
        weechat.config_new_option(CONFIG_FILE, CONFIG_SECTIONS['look'], option,
                                  'string', desc, '', 0, 0, default, default,
                                  0, '', '', update_cb, '', '', '')

    CONFIG_SECTIONS['policy'] = weechat.config_new_section(
        CONFIG_FILE, 'policy', 1, 1, '', '', '', '', '', '',
        'policy_create_option_cb', '', '', '')

    for option, desc, default in [
        ('default.allow_v2', 'default allow OTR v2 policy', 'on'),
        ('default.require_encryption', 'default require encryption policy',
         'off'),
        ('default.send_tag', 'default send tag policy', 'off'),
    ]:
        weechat.config_new_option(CONFIG_FILE, CONFIG_SECTIONS['policy'],
                                  option, 'boolean', desc, '', 0, 0, default,
                                  default, 0, '', '', '', '', '', '')

    weechat.config_read(CONFIG_FILE)
Exemple #35
0
def theme_config_init():
    """Initialization of configuration file. Sections: ???."""
    global theme_config_file, theme_config_option
    theme_config_file = weechat.config_new(THEME_CONFIG_FILE_NAME,
                                           'theme_config_reload_cb', '')
    if not theme_config_file:
        return

    # section "color"
    section_color = weechat.config_new_section(theme_config_file, 'color', 0,
                                               0, '', '', '', '', '', '', '',
                                               '', '', '')
    if not section_color:
        weechat.config_free(theme_config_file)
        return
    theme_config_option['color_script'] = weechat.config_new_option(
        theme_config_file, section_color, 'script', 'color',
        'Color for script names', '', 0, 0, 'cyan', 'cyan', 0, '', '', '', '',
        '', '')
    theme_config_option['color_installed'] = weechat.config_new_option(
        theme_config_file, section_color, 'installed', 'color',
        'Color for "installed" indicator', '', 0, 0, 'yellow', 'yellow', 0, '',
        '', '', '', '', '')
    theme_config_option['color_running'] = weechat.config_new_option(
        theme_config_file, section_color, 'running', 'color',
        'Color for "running" indicator', '', 0, 0, 'lightgreen', 'lightgreen',
        0, '', '', '', '', '', '')
    theme_config_option['color_obsolete'] = weechat.config_new_option(
        theme_config_file, section_color, 'obsolete', 'color',
        'Color for "obsolete" indicator', '', 0, 0, 'lightmagenta',
        'lightmagenta', 0, '', '', '', '', '', '')
    theme_config_option['color_unknown'] = weechat.config_new_option(
        theme_config_file, section_color, 'unknown', 'color',
        'Color for "unknown status" indicator', '', 0, 0, 'lightred',
        'lightred', 0, '', '', '', '', '', '')
    theme_config_option['color_language'] = weechat.config_new_option(
        theme_config_file, section_color, 'language', 'color',
        'Color for language names', '', 0, 0, 'lightblue', 'lightblue', 0, '',
        '', '', '', '', '')

    # section "themes"
    section_themes = weechat.config_new_section(theme_config_file, 'themes', 0,
                                                0, '', '', '', '', '', '', '',
                                                '', '', '')
    if not section_themes:
        weechat.config_free(theme_config_file)
        return
    theme_config_option['themes_url'] = weechat.config_new_option(
        theme_config_file, section_themes, 'url', 'string',
        'URL for file with list of themes', '', 0, 0,
        'http://www.weechat.org/files/themes.json.gz',
        'http://www.weechat.org/files/themes.json.gz', 0, '', '', '', '', '',
        '')
    theme_config_option['themes_cache_expire'] = weechat.config_new_option(
        theme_config_file, section_themes, 'cache_expire', 'integer',
        'Local cache expiration time, in minutes '
        '(-1 = never expires, 0 = always expires)', '', -1, 60 * 24 * 365,
        '60', '60', 0, '', '', '', '', '', '')
    theme_config_option['themes_dir'] = weechat.config_new_option(
        theme_config_file, section_themes, 'dir', 'string',
        'Local directory for themes', '', 0, 0, '%h/themes', '%h/themes', 0,
        '', '', '', '', '', '')
Exemple #36
0
	def __init__(self, filename):
		''' Initialize the configuration. '''

		self.filename         = filename
		self.config_file      = weechat.config_new(self.filename, '', '')
		self.sorting_section  = None

		self.case_sensitive   = False
		self.group_irc        = True
		self.rules            = []
		self.replacements     = []
		self.signals          = []
		self.sort_on_config   = True

		self.__case_sensitive = None
		self.__group_irc      = None
		self.__rules          = None
		self.__replacements   = None
		self.__signals        = None
		self.__sort_on_config = None

		if not self.config_file:
			log('Failed to initialize configuration file "{0}".'.format(self.filename))
			return

		self.sorting_section = weechat.config_new_section(self.config_file, 'sorting', False, False, '', '', '', '', '', '', '', '', '', '')

		if not self.sorting_section:
			log('Failed to initialize section "sorting" of configuration file.')
			weechat.config_free(self.config_file)
			return

		self.__case_sensitive = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'case_sensitive', 'boolean',
			'If this option is on, sorting is case sensitive.',
			'', 0, 0, 'off', 'off', 0,
			'', '', '', '', '', ''
		)

		self.__group_irc = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'group_irc', 'boolean',
			'If this option is on, the script pretends that IRC channel/private buffers are renamed to "irc.server.{network}.{channel}" rather than "irc.{network}.{channel}".' +
			'This ensures that these buffers are grouped with their respective server buffer.',
			'', 0, 0, 'on', 'on', 0,
			'', '', '', '', '', ''
		)

		self.__rules = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'rules', 'string',
			'An ordered list of sorting rules encoded as JSON. See /help autosort for commands to manipulate these rules.',
			'', 0, 0, Config.default_rules, Config.default_rules, 0,
			'', '', '', '', '', ''
		)

		self.__replacements = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'replacements', 'string',
			'An ordered list of replacement patterns to use on buffer name components, encoded as JSON. See /help autosort for commands to manipulate these replacements.',
			'', 0, 0, Config.default_replacements, Config.default_replacements, 0,
			'', '', '', '', '', ''
		)

		self.__signals = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'signals', 'string',
			'The signals that will cause autosort to resort your buffer list. Seperate signals with spaces.',
			'', 0, 0, Config.default_signals, Config.default_signals, 0,
			'', '', '', '', '', ''
		)

		self.__sort_on_config = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'sort_on_config_change', 'boolean',
			'Decides if the buffer list should be sorted when autosort configuration changes.',
			'', 0, 0, 'on', 'on', 0,
			'', '', '', '', '', ''
		)

		if weechat.config_read(self.config_file) != weechat.WEECHAT_RC_OK:
			log('Failed to load configuration file.')

		if weechat.config_write(self.config_file) != weechat.WEECHAT_RC_OK:
			log('Failed to write configuration file.')

		self.reload()
Exemple #37
0
    crypt_ciphers[option_name.lower()] = Cipher(value)
    return weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED


def crypt_config_keys_write(data, config_file, section_name):
    weechat.config_write_line(config_file, section_name, "")
    for target, cipher in sorted(crypt_ciphers.items()):
        weechat.config_write_line(config_file, target, cipher.key)
    return weechat.WEECHAT_RC_OK



if __name__ == "__main__":
    weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "crypt_unload", "")

    crypt_config_file = weechat.config_new(SCRIPT_NAME, "crypt_config_reload", "")
    if crypt_config_file:
        weechat.config_new_section(crypt_config_file, "options", 0, 0, "", "", "", "", "", "", "", "", "", "")
        weechat.config_new_section(crypt_config_file, "keys", 0, 0, "crypt_config_keys_read", "",
                "crypt_config_keys_write", "", "", "", "", "", "", "")
        weechat.config_read(crypt_config_file)

    weechat.hook_command("crypt", "Manage E2EE encryption keys",
            "listkeys | setkey <target> <key> | delkey <target> | sendplain <msg> ",
            SCRIPT_HELP_TEXT,
            "listkeys || setkey %(irc_channel)|%(nicks)|%(irc_servers) %- "
            "|| delkey %(irc_channel)|%(nicks)|%(irc_servers) %- || sendplain %-",
            "crypt_cmd_crypt", "")

    weechat.hook_modifier("irc_in_notice", "crypt_modifier_incoming", "")
    weechat.hook_modifier("irc_in_privmsg", "crypt_modifier_incoming", "")
Exemple #38
0
	def __init__(self, filename):
		''' Initialize the configuration. '''

		self.filename         = filename
		self.config_file      = weechat.config_new(self.filename, '', '')
		self.sorting_section  = None

		self.case_sensitive   = False
		self.group_irc        = True
		self.rules            = []
		self.replacements     = []
		self.signals          = []
		self.sort_on_config   = True

		self.__case_sensitive = None
		self.__group_irc      = None
		self.__rules          = None
		self.__replacements   = None
		self.__signals        = None
		self.__sort_on_config = None

		if not self.config_file:
			log('Failed to initialize configuration file "{0}".'.format(self.filename))
			return

		self.sorting_section = weechat.config_new_section(self.config_file, 'sorting', False, False, '', '', '', '', '', '', '', '', '', '')

		if not self.sorting_section:
			log('Failed to initialize section "sorting" of configuration file.')
			weechat.config_free(self.config_file)
			return

		self.__case_sensitive = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'case_sensitive', 'boolean',
			'If this option is on, sorting is case sensitive.',
			'', 0, 0, 'off', 'off', 0,
			'', '', '', '', '', ''
		)

		self.__group_irc = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'group_irc', 'boolean',
			'If this option is on, the script pretends that IRC channel/private buffers are renamed to "irc.server.{network}.{channel}" rather than "irc.{network}.{channel}".' +
			'This ensures that these buffers are grouped with their respective server buffer.',
			'', 0, 0, 'on', 'on', 0,
			'', '', '', '', '', ''
		)

		self.__rules = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'rules', 'string',
			'An ordered list of sorting rules encoded as JSON. See /help autosort for commands to manipulate these rules.',
			'', 0, 0, Config.default_rules, Config.default_rules, 0,
			'', '', '', '', '', ''
		)

		self.__replacements = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'replacements', 'string',
			'An ordered list of replacement patterns to use on buffer name components, encoded as JSON. See /help autosort for commands to manipulate these replacements.',
			'', 0, 0, Config.default_replacements, Config.default_replacements, 0,
			'', '', '', '', '', ''
		)

		self.__signals = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'signals', 'string',
			'The signals that will cause autosort to resort your buffer list. Seperate signals with spaces.',
			'', 0, 0, Config.default_signals, Config.default_signals, 0,
			'', '', '', '', '', ''
		)

		self.__sort_on_config = weechat.config_new_option(
			self.config_file, self.sorting_section,
			'sort_on_config_change', 'boolean',
			'Decides if the buffer list should be sorted when autosort configuration changes.',
			'', 0, 0, 'on', 'on', 0,
			'', '', '', '', '', ''
		)

		if weechat.config_read(self.config_file) != weechat.WEECHAT_RC_OK:
			log('Failed to load configuration file.')

		if weechat.config_write(self.config_file) != weechat.WEECHAT_RC_OK:
			log('Failed to write configuration file.')

		self.reload()
Exemple #39
0
def ircrypt_config_init():
    ''' This method initializes the configuration file. It creates sections and
	options in memory and prepares the handling of key sections.
	'''
    global ircrypt_config_file
    ircrypt_config_file = weechat.config_new('ircrypt',
                                             'ircrypt_config_reload_cb', '')
    if not ircrypt_config_file:
        return

    # marker
    ircrypt_config_section['marker'] = weechat.config_new_section(
        ircrypt_config_file, 'marker', 0, 0, '', '', '', '', '', '', '', '',
        '', '')
    if not ircrypt_config_section['marker']:
        weechat.config_free(ircrypt_config_file)
        return
    ircrypt_config_option['encrypted'] = weechat.config_new_option(
        ircrypt_config_file, ircrypt_config_section['marker'], 'encrypted',
        'string', 'Marker for encrypted messages', '', 0, 0, 'encrypted',
        'encrypted', 0, '', '', '', '', '', '')
    ircrypt_config_option['unencrypted'] = weechat.config_new_option(
        ircrypt_config_file, ircrypt_config_section['marker'], 'unencrypted',
        'string',
        'Marker for unencrypted messages received in an encrypted channel', '',
        0, 0, '', 'u', 0, '', '', '', '', '', '')

    # cipher options
    ircrypt_config_section['cipher'] = weechat.config_new_section(
        ircrypt_config_file, 'cipher', 0, 0, '', '', '', '', '', '', '', '',
        '', '')
    if not ircrypt_config_section['cipher']:
        weechat.config_free(ircrypt_config_file)
        return
    ircrypt_config_option['sym_cipher'] = weechat.config_new_option(
        ircrypt_config_file, ircrypt_config_section['cipher'], 'sym_cipher',
        'string', 'symmetric cipher used by default', '', 0, 0, 'TWOFISH',
        'TWOFISH', 0, '', '', '', '', '', '')

    # general options
    ircrypt_config_section['general'] = weechat.config_new_section(
        ircrypt_config_file, 'general', 0, 0, '', '', '', '', '', '', '', '',
        '', '')
    if not ircrypt_config_section['general']:
        weechat.config_free(ircrypt_config_file)
        return
    ircrypt_config_option['binary'] = weechat.config_new_option(
        ircrypt_config_file, ircrypt_config_section['general'], 'binary',
        'string', 'GnuPG binary to use', '', 0, 0, '', '', 0, '', '', '', '',
        '', '')

    # keys
    ircrypt_config_section['keys'] = weechat.config_new_section(
        ircrypt_config_file, 'keys', 0, 0, 'ircrypt_config_keys_read_cb', '',
        'ircrypt_config_keys_write_cb', '', '', '', '', '', '', '')
    if not ircrypt_config_section['keys']:
        weechat.config_free(ircrypt_config_file)

    # Special Ciphers
    ircrypt_config_section['special_cipher'] = weechat.config_new_section(
        ircrypt_config_file, 'special_cipher', 0, 0,
        'ircrypt_config_special_cipher_read_cb', '',
        'ircrypt_config_special_cipher_write_cb', '', '', '', '', '', '', '')
    if not ircrypt_config_section['special_cipher']:
        weechat.config_free(ircrypt_config_file)
Exemple #40
0
 def __init__(self):
     UserDict.__init__(self)
     self.data = {}
     self.config_file = weechat.config_new(CONFIG_FILE_NAME,
                                     "ug_config_reload_cb", "")
     if not self.config_file:
         return
         
     section_color = weechat.config_new_section(
         self.config_file, "color", 0, 0, "", "", "", "", "", "",
                  "", "", "", "")
     section_default = weechat.config_new_section(
         self.config_file, "default", 0, 0, "", "", "", "", "", "",
                  "", "", "", "")
                  
     self.data['color_buffer']=weechat.config_new_option(
         self.config_file, section_color,
         "color_buffer", "color", "Color to display buffer name", "", 0, 0,
         "red", "red", 0, "", "", "", "", "", "")
     
     self.data['color_url']=weechat.config_new_option(
         self.config_file, section_color,
         "color_url", "color", "Color to display urls", "", 0, 0,
         "blue", "blue", 0, "", "", "", "", "", "")
      
     self.data['color_time']=weechat.config_new_option(
         self.config_file, section_color,
         "color_time", "color", "Color to display time", "", 0, 0,
         "cyan", "cyan", 0, "", "", "", "", "", "")
    
     self.data['color_buffer_selected']=weechat.config_new_option(
         self.config_file, section_color,
         "color_buffer_selected", "color", 
         "Color to display buffer selected name", "", 0, 0, "red", "red", 
         0, "", "", "", "", "", "")
     
     self.data['color_url_selected']=weechat.config_new_option(
         self.config_file, section_color,
         "color_url_selected", "color", "Color to display url selected",
          "", 0, 0, "blue", "blue", 0, "", "", "", "", "", "")
         
     self.data['color_time_selected']=weechat.config_new_option(
         self.config_file, section_color,
         "color_time_selected", "color", "Color to display tim selected", 
         "", 0, 0, "cyan", "cyan", 0, "", "", "", "", "", "")    
     
     self.data['color_bg_selected']=weechat.config_new_option(
         self.config_file, section_color,
         "color_bg_selected", "color", "Background for selected row", "", 0, 0,
         "green", "green", 0, "", "", "", "", "", "") 
         
     self.data['historysize']=weechat.config_new_option(
         self.config_file, section_default,
         "historysize", "integer", "Max number of urls to store per buffer", 
         "", 0, 999, "10", "10", 0, "", "", "", "", "", "") 
     
     self.data['method']=weechat.config_new_option(
         self.config_file, section_default,
         "method", "string", """Where to launch URLs
         If 'local', runs %localcmd%.
         If 'remote' runs the following command:
         '%remodecmd%'""", "", 0, 0,
         "local", "local", 0, "", "", "", "", "", "") 
         
         
     self.data['localcmd']=weechat.config_new_option(
         self.config_file, section_default,
         "localcmd", "string", """Local command to execute""", "", 0, 0,
         "firefox %s", "firefox %s", 0, "", "", "", "", "", "") 
     
     remotecmd="ssh -x localhost -i ~/.ssh/id_rsa -C \"export DISPLAY=\":0.0\" &&  firefox %s\""
     self.data['remotecmd']=weechat.config_new_option(
         self.config_file, section_default,
         "remotecmd", "string", remotecmd, "", 0, 0,
         remotecmd, remotecmd, 0, "", "", "", "", "", "")
         
     self.data['url_log']=weechat.config_new_option(
         self.config_file, section_default,
         "url_log", "string", """log location""", "", 0, 0,
         "~/.weechat/urls.log", "~/.weechat/urls.log", 0, "", "", "", "", "", "")
         
     self.data['time_format']=weechat.config_new_option(
         self.config_file, section_default,
         "time_format", "string", """TIme format""", "", 0, 0,
         "%H:%M:%S", "%H:%M:%S", 0, "", "", "", "", "", "")
         
     self.data['output_main_buffer']=weechat.config_new_option(
         self.config_file, section_default,
         "output_main_buffer", "boolean", 
         """Print text to main buffer or current one""", "", 0, 0, "1", "1",
          0, "", "", "", "", "", "")
     weechat.config_read(self.config_file)
def init_config():
    """Set up configuration options and load config file."""
    global CONFIG_FILE
    CONFIG_FILE = weechat.config_new(SCRIPT_NAME, 'config_reload_cb', '')

    global CONFIG_SECTIONS
    CONFIG_SECTIONS = {}

    CONFIG_SECTIONS['general'] = weechat.config_new_section(
        CONFIG_FILE, 'general', 0, 0, '', '', '', '', '', '', '', '', '', '')

    for option, typ, desc, default in [
        ('debug', 'boolean', 'OTR script debugging', 'off'),
        ]:
        weechat.config_new_option(
            CONFIG_FILE, CONFIG_SECTIONS['general'], option, typ, desc, '', 0,
            0, default, default, 0, '', '', '', '', '', '')

    CONFIG_SECTIONS['color'] = weechat.config_new_section(
        CONFIG_FILE, 'color', 0, 0, '', '', '', '', '', '', '', '', '', '')

    for option, desc, default, update_cb in [
        ('status.default', 'status bar default color', 'default',
         'bar_config_update_cb'),
        ('status.encrypted', 'status bar encrypted indicator color', 'green',
         'bar_config_update_cb'),
        ('status.unencrypted', 'status bar unencrypted indicator color',
         'lightred', 'bar_config_update_cb'),
        ('status.authenticated', 'status bar authenticated indicator color',
         'green', 'bar_config_update_cb'),
        ('status.unauthenticated', 'status bar unauthenticated indicator color',
         'lightred', 'bar_config_update_cb'),
        ('status.logged', 'status bar logged indicator color', 'lightred',
         'bar_config_update_cb'),
        ('status.notlogged', 'status bar not logged indicator color',
         'green', 'bar_config_update_cb'),
        ]:
        weechat.config_new_option(
            CONFIG_FILE, CONFIG_SECTIONS['color'], option, 'color', desc, '', 0,
            0, default, default, 0, '', '', update_cb, '', '', '')

    CONFIG_SECTIONS['look'] = weechat.config_new_section(
        CONFIG_FILE, 'look', 0, 0, '', '', '', '', '', '', '', '', '', '')

    for option, desc, default, update_cb in [
        ('bar.prefix', 'prefix for OTR status bar item', 'OTR:',
         'bar_config_update_cb'),
        ('bar.state.encrypted',
         'shown in status bar when conversation is encrypted', 'SEC',
         'bar_config_update_cb'),
        ('bar.state.unencrypted',
         'shown in status bar when conversation is not encrypted', '!SEC',
         'bar_config_update_cb'),
        ('bar.state.authenticated',
         'shown in status bar when peer is authenticated', 'AUTH',
         'bar_config_update_cb'),
        ('bar.state.unauthenticated',
         'shown in status bar when peer is not authenticated', '!AUTH',
         'bar_config_update_cb'),
        ('bar.state.logged',
         'shown in status bar when peer conversation is being logged to disk',
         'LOG',
         'bar_config_update_cb'),
        ('bar.state.notlogged',
         'shown in status bar when peer conversation is not being logged to disk',
         '!LOG',
         'bar_config_update_cb'),
        ('bar.state.separator', 'separator for states in the status bar', ',',
         'bar_config_update_cb'),
        ]:
        weechat.config_new_option(
            CONFIG_FILE, CONFIG_SECTIONS['look'], option, 'string', desc, '',
            0, 0, default, default, 0, '', '', update_cb, '', '', '')

    CONFIG_SECTIONS['policy'] = weechat.config_new_section(
        CONFIG_FILE, 'policy', 1, 1, '', '', '', '', '', '',
        'policy_create_option_cb', '', '', '')

    for option, desc, default in [
        ('default.allow_v2', 'default allow OTR v2 policy', 'on'),
        ('default.require_encryption', 'default require encryption policy',
         'off'),
        ('default.send_tag', 'default send tag policy', 'off'),
        ]:
        weechat.config_new_option(
            CONFIG_FILE, CONFIG_SECTIONS['policy'], option, 'boolean', desc, '',
            0, 0, default, default, 0, '', '', '', '', '', '')

    weechat.config_read(CONFIG_FILE)