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 __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()
###################################### # 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)
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)
def ircrypt_config_read(): ''' Read IRCrypt configuration file (ircrypt.conf). ''' return weechat.config_read(ircrypt_config_file)
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 "{}".'.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()
def ug_config_reload_cb(data, config_file): """ Reload configuration file. """ return weechat.config_read(config_file)
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()
def read(self): """Read the config file.""" return 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)
def theme_config_read(): """Read configuration file.""" return weechat.config_read(theme_cfg_file)
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", "command_cb", "") weechat.hook_modifier('irc_in_privmsg', 'in_privmsg_cb', '') weechat.hook_modifier('irc_out_privmsg', 'out_privmsg_cb', '') weechat.hook_signal('buffer_closing', 'buffer_closing_cb', '') statusbar = weechat.bar_item_new(SCRIPT_NAME, 'statusbar_cb', '')
def config_read(): return weechat.config_read(config_file)
def fish_config_read(): global fish_config_file return weechat.config_read(fish_config_file)
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()
def bas_config_read(): """Read configuration file.""" global bas_config_file return weechat.config_read(bas_config_file)
def colorize_config_read(): """ Read configuration file. """ global colorize_config_file return weechat.config_read(colorize_config_file)
def colorize_config_read(): ''' Read configuration file. ''' global colorize_config_file return weechat.config_read(colorize_config_file)
def execbot_config_read(): ''' Read Execbot configuration file (execbot.conf).''' return weechat.config_read(execbot_config_file)
def wg_config_read(): """ Read configuration file. """ global wg_config_file return weechat.config_read(wg_config_file)
def jmh_config_read(): """ Read jabber config file (jabber.conf). """ global jmh_config_file return weechat.config_read(jmh_config_file)
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)