示例#1
0
	def reload(self):
		''' Load configuration variables. '''

		self.case_sensitive = weechat.config_boolean(self.__case_sensitive)

		rules_blob    = weechat.config_string(self.__rules)
		helpers_blob  = weechat.config_string(self.__helpers)
		signals_blob  = weechat.config_string(self.__signals)

		self.rules          = decode_rules(rules_blob)
		self.helpers        = decode_helpers(helpers_blob)
		self.signals        = signals_blob.split()
		self.signal_delay   = weechat.config_integer(self.__signal_delay)
		self.sort_limit     = weechat.config_integer(self.__sort_limit)
		self.sort_on_config = weechat.config_boolean(self.__sort_on_config)
		self.debug_log      = weechat.config_boolean(self.__debug_log)
示例#2
0
    def reload(self):
        ''' Load configuration variables. '''

        self.case_sensitive = weechat.config_boolean(self.__case_sensitive)

        rules_blob = weechat.config_string(self.__rules)
        helpers_blob = weechat.config_string(self.__helpers)
        signals_blob = weechat.config_string(self.__signals)

        self.rules = decode_rules(rules_blob)
        self.helpers = decode_helpers(helpers_blob)
        self.signals = signals_blob.split()
        self.signal_delay = weechat.config_integer(self.__signal_delay)
        self.sort_limit = weechat.config_integer(self.__sort_limit)
        self.sort_on_config = weechat.config_boolean(self.__sort_on_config)
        self.debug_log = weechat.config_boolean(self.__debug_log)
示例#3
0
 def __getitem__(self, key):
     if key == "historysize":
         return weechat.config_integer(self.data[key])
     elif key == 'output_main_buffer':
         return weechat.config_boolean(self.data[key])
     #elif key.startswith('color'):
     #    return weechat.config_color(self.data[key])
     else:
         return weechat.config_string(self.data[key])
示例#4
0
def irc_nick_find_color(nick):

    color = weechat.info_get('irc_nick_color', nick)
    if not color:
        # probably we're in WeeChat 0.3.0
        color %= weechat.config_integer(weechat.config_get("weechat.look.color_nicks_number"))
        color = weechat.config_get('weechat.color.chat_nick_color%02d' %(color+1))
        color = w.color(weechat.config_string(color))
    return '%s%s%s' %(color, nick, weechat.color('reset'))
示例#5
0
def irc_nick_find_color(nick):

    color = weechat.info_get('irc_nick_color', nick)
    if not color:
        # probably we're in WeeChat 0.3.0
        color %= weechat.config_integer(weechat.config_get("weechat.look.color_nicks_number"))
        color = weechat.config_get('weechat.color.chat_nick_color%02d' %(color+1))
        color = weechat.color(weechat.config_string(color))
    return '%s%s%s' %(color, nick, weechat.color('reset'))
示例#6
0
def bas_signal_buffer_opened_cb(data, signal, signal_data):
    global bas_options
    buffer = signal_data
    timer = weechat.config_integer(bas_options["look_timer"])
    if timer == 0:
        bas_apply_options_for_buffer(buffer)
    else:
        weechat.hook_timer(timer, 0, 1, "bas_timer_buffer_opened_cb",
                           weechat.buffer_get_string(buffer, "full_name"))
    return weechat.WEECHAT_RC_OK
示例#7
0
def bas_signal_buffer_opened_cb(data, signal, signal_data):
    global bas_options
    buffer = signal_data
    timer = weechat.config_integer(bas_options["look_timer"])
    if timer == 0:
        bas_apply_options_for_buffer(buffer)
    else:
        weechat.hook_timer(timer, 0, 1,
                           "bas_timer_buffer_opened_cb",
                           weechat.buffer_get_string(buffer, "full_name"))
    return weechat.WEECHAT_RC_OK
示例#8
0
def irc_nick_find_color(nick, bgcolor='default'):

    color = weechat.info_get('irc_nick_color', nick)
    if not color:
        # probably we're in WeeChat 0.3.0
        color = 0
        for char in nick:
            color += ord(char)

        color %= w.config_integer(w.config_get("weechat.look.color_nicks_number"))
        color = w.config_get('weechat.color.chat_nick_color%02d' %(color+1))
        color = w.config_string(color)
    return '%s%s%s' %(w.color('%s,%s' %(color, bgcolor)), nick, w.color('reset'))
示例#9
0
def irc_nick_find_color(nick):
    if not nick: # nick (actually prefix) is empty, irc_nick_color returns None on empty input
        return ''

    color = weechat.info_get('irc_nick_color', nick)
    if not color:
        # probably we're in WeeChat 0.3.0
        color = 0
        for char in nick:
            color += ord(char)
        
        color %= weechat.config_integer(weechat.config_get("weechat.look.color_nicks_number"))
        color = weechat.config_get('weechat.color.chat_nick_color%02d' %(color+1))
        color = w.color(weechat.config_string(color))
    return '%s%s%s' %(color, nick, weechat.color('reset'))
示例#10
0
def irc_nick_find_color(nick):
    if not nick:  # nick (actually prefix) is empty, irc_nick_color returns None on empty input
        return ''

    color = weechat.info_get('irc_nick_color', nick)
    if not color:
        # probably we're in WeeChat 0.3.0
        color = 0
        for char in nick:
            color += ord(char)

        color %= weechat.config_integer(
            weechat.config_get("weechat.look.color_nicks_number"))
        color = weechat.config_get('weechat.color.chat_nick_color%02d' %
                                   (color + 1))
        color = w.color(weechat.config_string(color))
    return '%s%s%s' % (color, nick, weechat.color('reset'))
示例#11
0
def wg_read_scripts(download_list=True):
    """ Read scripts list (download list if needed and asked). """
    global wg_scripts
    cache_file = wg_config_get_cache_filename()
    if os.path.isfile(cache_file):
        # check if local cache file is too old
        cache_expire = weechat.config_integer(wg_config_option["scripts_cache_expire"]) * 60
        if cache_expire >= 0:
            diff_time = time.time() - os.stat(cache_file)[stat.ST_MTIME]
            if download_list and diff_time >= cache_expire:
                os.unlink(cache_file)
                wg_scripts.clear()
    if len(wg_scripts) > 0:
        wg_execute_action()
    else:
        if os.path.isfile(cache_file):
            wg_parse_xml()
        elif download_list:
            wg_update_cache()
示例#12
0
def wg_read_scripts(download_list=True):
    """ Read scripts list (download list if needed and asked). """
    global wg_scripts
    cache_file = wg_config_get_cache_filename()
    if os.path.isfile(cache_file):
        # check if local cache file is too old
        cache_expire = weechat.config_integer(wg_config_option["scripts_cache_expire"]) * 60
        if cache_expire >= 0:
            diff_time = time.time() - os.stat(cache_file)[stat.ST_MTIME]
            if download_list and diff_time >= cache_expire:
                os.unlink(cache_file)
                wg_scripts.clear()
    if len(wg_scripts) > 0:
        wg_execute_action()
    else:
        if os.path.isfile(cache_file):
            wg_parse_xml()
        elif download_list:
            wg_update_cache()
示例#13
0
	def color_nick(nick):
		"""Returns coloured nick, with coloured mode if any."""
		# XXX should check if nick has a prefix and subfix string?
		modes = '@!+%' # nick modes
		if not nick: return ''
		# nick mode
		if nick[0] in modes:
			mode, nick = nick[0], nick[1:]
			mode_color = weechat.config_string(weechat.config_get('weechat.color.nicklist_prefix%d' \
				%(modes.find(mode) + 1)))
			mode_color = weechat.color(mode_color)
		else:
			mode = ''
			mode_color = ''
		color_nicks_number = weechat.config_integer(weechat.config_get('weechat.look.color_nicks_number'))
		idx = (sum(map(ord, nick))%color_nicks_number) + 1
		color = weechat.config_string(weechat.config_get('weechat.color.chat_nick_color%02d' %idx))
		nick_color = weechat.color(color)
		return '%s%s%s%s' %(mode_color, mode, nick_color, nick)
示例#14
0
 def color_nick(nick):
     """Returns coloured nick, with coloured mode if any."""
     # XXX should check if nick has a prefix and subfix string?
     modes = '@!+%'  # nick modes
     if not nick: return ''
     # nick mode
     if nick[0] in modes:
         mode, nick = nick[0], nick[1:]
         mode_color = weechat.config_string(weechat.config_get('weechat.color.nicklist_prefix%d' \
          %(modes.find(mode) + 1)))
         mode_color = weechat.color(mode_color)
     else:
         mode = ''
         mode_color = ''
     color_nicks_number = weechat.config_integer(
         weechat.config_get('weechat.look.color_nicks_number'))
     idx = (sum(map(ord, nick)) % color_nicks_number) + 1
     color = weechat.config_string(
         weechat.config_get('weechat.color.chat_nick_color%02d' % idx))
     nick_color = weechat.color(color)
     return '%s%s%s%s' % (mode_color, mode, nick_color, nick)
示例#15
0
def build_list(data, item, window):
    # Setup variables
    # First retrieve the `hdata`s, then get relevant lists
    buffer_hdata = weechat.hdata_get('buffer')
    server_hdata = weechat.hdata_get('irc_server')
    hotlist_hdata = weechat.hdata_get('hotlist')
    buffer_pointer = weechat.hdata_get_list(buffer_hdata, 'gui_buffers')
    server_pointer = weechat.hdata_get_list(server_hdata, 'irc_servers')
    bar_width = weechat.config_integer(
        weechat.config_get('weechat.bar.buffers.size'))
    buflist = ''

    # Start looping through the buffers
    while buffer_pointer:
        # Grab the hotlist and priority level for the current buffer
        hotlist_pointer = weechat.hdata_pointer(buffer_hdata, buffer_pointer,
                                                "hotlist")
        if hotlist_pointer:
            priority = weechat.hdata_integer(hotlist_hdata, hotlist_pointer,
                                             'priority')
        else:
            priority = 0

        # Setup the info variables for the current buffer
        nick = weechat.buffer_get_string(buffer_pointer, "localvar_nick")
        name = weechat.buffer_get_string(buffer_pointer, "short_name")
        full_name = weechat.buffer_get_string(buffer_pointer, "name")
        plugin = weechat.buffer_get_string(buffer_pointer, "plugin")
        buffer_type = weechat.buffer_get_string(buffer_pointer,
                                                "localvar_type")
        server = weechat.buffer_get_string(buffer_pointer, 'localvar_server')
        icon_color = weechat.buffer_get_string(buffer_pointer,
                                               "localvar_icon_color") or 0
        current_buffer = 1 if weechat.current_buffer() == buffer_pointer else 0

        # Setup info variables for next buffer
        next_pointer = weechat.hdata_move(buffer_hdata, buffer_pointer, 1)
        next_type = weechat.buffer_get_string(next_pointer, "plugin")

        # Start building!

        # Draw icons for non-IRC buffers - core, script, fset, etc
        # You can set an `icon_color` localvar to override the `color.icon` option for a particular buffer when it's active
        # This isn't exactly ideal. Another option would be to use a localvar for each buffer that gets an icon, and then do a check for that
        if plugin != 'irc':
            if current_buffer:
                if icon_color:
                    buflist += weechat.color(icon_color)
                else:
                    buflist += weechat.color(option_values['color.icon'])
            else:
                buflist += weechat.color(option_values['color.default_fg'])

            buflist += "●  "
            buflist += weechat.color(option_values['color.default_fg'])

            # Add a newline if the next buffer is the start of IRC buffers
            if next_type == 'irc':
                buflist += '\n'
        # Start adding other buffers
        else:
            # Add separator between servers
            if option_values[
                    'look.server_separator'] == '1' and buffer_type == 'server':
                buflist += '─' * bar_width + '\n'
            # Print the appropriate color for the current buffer, as well as an icon for the current buffer
            if current_buffer:
                buflist += weechat.color(option_values['color.current_fg'])
                buflist += "●"
            elif priority == 1:
                buflist += weechat.color(
                    option_values['color.hotlist_message'])
            elif priority == 2:
                buflist += weechat.color(
                    option_values['color.hotlist_private'])
            elif priority == 3:
                buflist += weechat.color(
                    option_values['color.hotlist_highlight'])
            else:
                buflist += weechat.color(option_values['color.default_fg'])

            # Spacing between icon and name
            if current_buffer:
                buflist += ' '
            else:
                buflist += '  '
            if buffer_type != 'server':
                buflist += '   '
            if buffer_type == 'private':
                buflist += '  '

            # Add the nick prefix (@, +, etc)
            nick_prefix = get_nick_prefix(buffer_pointer)
            buflist += nick_prefix

            # Add the buffer name
            buflist += name

            # Add nick modes next to server buffers, if any are set
            if buffer_type == 'server':
                # Search for and retrieve a pointer for the server
                pointer = weechat.hdata_search(
                    server_hdata, server_pointer,
                    '${irc_server.name} == ' + server, 1)

                # Then get the nick modes for that server
                nick_modes = weechat.hdata_string(server_hdata, pointer,
                                                  'nick_modes')

                if nick_modes:
                    buflist += ' (+{})'.format(nick_modes)

            # Add the newline after each buffer
            buflist += '\n'

        # Move to the next buffer
        buffer_pointer = weechat.hdata_move(buffer_hdata, buffer_pointer, 1)

    # All done. Return the list
    return buflist
示例#16
0
 def get_config_int_value(self, option):
     """ Get an option """
     global webex_config_option
     return weechat.config_integer(webex_config_option[option])
示例#17
0
 def reload(self):
     self.mail_dir = weechat.config_string(self._mail_dir)
     self.bar_text = weechat.config_string(self._bar_text)
     self.interval = weechat.config_integer(self._interval)
     self.should_log = weechat.config_boolean(self._log_to_weechat)