예제 #1
0
def fill_last_lines(buffer):
    last_lines.append(get_input_line(buffer, -1))
    hdata = w.hdata_get("buffer")
    lines = w.hdata_pointer(hdata, buffer, "own_lines")

    found = 0
    processed = 0
    lines_limit = int(w.config_get_plugin("lines"))
    raw_lines_limit = int(w.config_get_plugin("raw_lines"))
    line  = w.hdata_pointer(w.hdata_get('lines'), lines, "last_line")

    while found < lines_limit and processed < raw_lines_limit and line != "":
        line_data = w.hdata_pointer(w.hdata_get('line'), line, "data")

        count = w.hdata_integer(w.hdata_get("line_data"), line_data, "tags_count")
        if count == 0:
            processed += 1
            continue

        tag = w.hdata_string(w.hdata_get('line_data'), line_data, "0|tags_array")
        if tag == 'irc_privmsg':
            message = w.hdata_string(w.hdata_get('line_data'), line_data, "message")
            last_lines.append(message)
            found += 1
        line = w.hdata_pointer(w.hdata_get('line'), line, "prev_line")
        processed += 1

    last_lines.append(get_input_line(buffer, 1))
예제 #2
0
def bufsave_cmd(data, buffer, args):
    filename = weechat.buffer_get_string(
        buffer, 'localvar_server') + '.' + weechat.buffer_get_string(
            buffer,
            'localvar_channel')[1:] + '-' + time.strftime('%y_%m_%d') + '.log'
    filename = weechat.string_eval_path_home('%h/logs/' + filename, {}, {}, {})
    try:
        fp = open(filename, 'w')
    except:
        weechat.prnt('', 'Error writing to target file!')
        return weechat.WEECHAT_RC_OK
    own_lines = weechat.hdata_pointer(weechat.hdata_get('buffer'), buffer,
                                      'own_lines')
    if own_lines:
        line = weechat.hdata_pointer(weechat.hdata_get('lines'), own_lines,
                                     'first_line')
        hdata_line = weechat.hdata_get('line')
        hdata_line_data = weechat.hdata_get('line_data')
        while line:
            data = weechat.hdata_pointer(hdata_line, line, 'data')
            if data:
                date = weechat.hdata_time(hdata_line_data, data, 'date')
                if not isinstance(date, str):
                    date = time.strftime('%F %T', time.localtime(int(date)))
                fp.write('{0} {1} {2}\n'.format(
                    date,
                    cstrip(
                        weechat.hdata_string(hdata_line_data, data, 'prefix')),
                    cstrip(
                        weechat.hdata_string(hdata_line_data, data,
                                             'message'))))
            line = weechat.hdata_move(hdata_line, line, 1)
    fp.close()
    return weechat.WEECHAT_RC_OK
예제 #3
0
def layout_apply_cb(data, buffer, command):
    if weechat.config_string_to_boolean(
            weechat.config_get_plugin("layout_apply")):
        m = LAYOUT_APPLY_RE.match(command)
        if m:
            layout_name = m.group(1) or "default"
            hdata_layout = weechat.hdata_get("layout")
            layouts = weechat.hdata_get_list(hdata_layout, "gui_layouts")
            layout = weechat.hdata_search(hdata_layout, layouts,
                                          "${layout.name} == " + layout_name,
                                          1)
            if layout:
                hdata_layout_buffer = weechat.hdata_get("layout_buffer")
                layout_buffer = weechat.hdata_pointer(hdata_layout, layout,
                                                      "layout_buffers")
                while layout_buffer:
                    plugin_name = weechat.hdata_string(hdata_layout_buffer,
                                                       layout_buffer,
                                                       "plugin_name")
                    buffer_name = weechat.hdata_string(hdata_layout_buffer,
                                                       layout_buffer,
                                                       "buffer_name")
                    full_name = "{}.{}".format(plugin_name, buffer_name)

                    buffer = weechat.buffer_search("==", full_name)
                    if not buffer:
                        buffer_open_full_name(full_name, noswitch=True)

                    layout_buffer = weechat.hdata_move(hdata_layout_buffer,
                                                       layout_buffer, 1)
    return weechat.WEECHAT_RC_OK
예제 #4
0
def bufsave_cmd(data, buffer, args):
    ''' Callback for /bufsave command '''

    filename_raw = args

    if not filename_raw:
        w.command('', '/help %s' % SCRIPT_COMMAND)
        return w.WEECHAT_RC_OK

    filename = w.string_eval_path_home(filename_raw, {}, {}, {})

    if exists(filename):
        w.prnt('', 'Error: target file already exists!')
        return w.WEECHAT_RC_OK

    try:
        fp = open(filename, 'w')
    except:
        w.prnt('', 'Error writing to target file!')
        return w.WEECHAT_RC_OK

    version = w.info_get('version_number', '') or 0
    if int(version) >= 0x00030600:
        # use hdata with WeeChat >= 0.3.6 (direct access to data, very fast)
        own_lines = w.hdata_pointer(w.hdata_get('buffer'), buffer, 'own_lines')
        if own_lines:
            line = w.hdata_pointer(w.hdata_get('lines'), own_lines,
                                   'first_line')
            hdata_line = w.hdata_get('line')
            hdata_line_data = w.hdata_get('line_data')
            while line:
                data = w.hdata_pointer(hdata_line, line, 'data')
                if data:
                    date = w.hdata_time(hdata_line_data, data, 'date')
                    # since WeeChat 0.3.9, hdata_time returns long instead of string
                    if not isinstance(date, str):
                        date = time.strftime('%F %T',
                                             time.localtime(int(date)))
                    fp.write('%s %s %s\n' %(\
                            date,
                            cstrip(w.hdata_string(hdata_line_data, data, 'prefix')),
                            cstrip(w.hdata_string(hdata_line_data, data, 'message')),
                            ))
                line = w.hdata_move(hdata_line, line, 1)
    else:
        # use infolist with WeeChat <= 0.3.5 (full duplication of lines, slow and uses memory)
        infolist = w.infolist_get('buffer_lines', buffer, '')
        while w.infolist_next(infolist):
            fp.write('%s %s %s\n' %(\
                    w.infolist_time(infolist, 'date'),
                    cstrip(w.infolist_string(infolist, 'prefix')),
                    cstrip(w.infolist_string(infolist, 'message')),
                    ))
        w.infolist_free(infolist)

    fp.close()

    return w.WEECHAT_RC_OK
예제 #5
0
def bufsave_cmd(data, buffer, args):
    ''' Callback for /bufsave command '''

    filename_raw = args

    if not filename_raw:
        w.command('', '/help %s' %SCRIPT_COMMAND)
        return w.WEECHAT_RC_OK
    
    filename = w.string_eval_path_home(filename_raw, {}, {}, {})

    if exists(filename):
        w.prnt('', 'Error: target file already exists!')
        return w.WEECHAT_RC_OK

    try:
        fp = open(filename, 'w')
    except:
        w.prnt('', 'Error writing to target file!')
        return w.WEECHAT_RC_OK

    version = w.info_get('version_number', '') or 0
    if int(version) >= 0x00030600:
        # use hdata with WeeChat >= 0.3.6 (direct access to data, very fast)
        own_lines = w.hdata_pointer(w.hdata_get('buffer'), buffer, 'own_lines')
        if own_lines:
            line = w.hdata_pointer(w.hdata_get('lines'), own_lines, 'first_line')
            hdata_line = w.hdata_get('line')
            hdata_line_data = w.hdata_get('line_data')
            while line:
                data = w.hdata_pointer(hdata_line, line, 'data')
                if data:
                    date = w.hdata_time(hdata_line_data, data, 'date')
                    # since WeeChat 0.3.9, hdata_time returns long instead of string
                    if not isinstance(date, str):
                        date = time.strftime('%F %T', time.localtime(int(date)))
                    fp.write('%s %s %s\n' %(\
                            date,
                            cstrip(w.hdata_string(hdata_line_data, data, 'prefix')),
                            cstrip(w.hdata_string(hdata_line_data, data, 'message')),
                            ))
                line = w.hdata_move(hdata_line, line, 1)
    else:
        # use infolist with WeeChat <= 0.3.5 (full duplication of lines, slow and uses memory)
        infolist = w.infolist_get('buffer_lines', buffer, '')
        while w.infolist_next(infolist):
            fp.write('%s %s %s\n' %(\
                    w.infolist_time(infolist, 'date'),
                    cstrip(w.infolist_string(infolist, 'prefix')),
                    cstrip(w.infolist_string(infolist, 'message')),
                    ))
        w.infolist_free(infolist)

    fp.close()

    return w.WEECHAT_RC_OK
예제 #6
0
def test12(data, buffer, arg):
    own_lines = weechat.hdata_pointer(weechat.hdata_get("buffer"), buffer,
                                      'own_lines')
    line = weechat.hdata_pointer(weechat.hdata_get('lines'), own_lines,
                                 'last_line')
    hdata_line_data = weechat.hdata_get('line_data')
    hdata_line = weechat.hdata_get('line')
    d = weechat.hdata_pointer(hdata_line, line, 'data')
    weechat.prnt(buffer, weechat.hdata_string(hdata_line_data, d, 'message'))
    weechat.prnt(buffer, weechat.hdata_string(hdata_line_data, d, 'prefix'))
    return weechat.WEECHAT_RC_OK
예제 #7
0
def logexport_export_cmd(buff, exportFile, mustExportLine):
    """ Called when an export function is called, as `/logexport time`.

    `exportFile` is the name of the file to which we will export.

    `mustExportLine`, when fed a message line (ie. `timestamp, prefix, msg`),
    should return `True` iff this line should be included in the export. The
    lines will be fed one by one starting from the most recent.
    When all the lines that should be exported have been checked, this function
    should raise `StopExport` to avoid looping uselessly through all the
    backlog.
    It is eventually called with `None, None, None` when the top of the backlog
    is reached, and could raise an exception at this time if something went
    wrong.
    """

    cBuffer = weechat.hdata_get('buffer')
    lines = weechat.hdata_pointer(cBuffer, buff, 'lines')
    # 'lines' and not 'own_lines': match what the user sees.

    cLine = weechat.hdata_pointer(weechat.hdata_get('lines'), lines,
                                  'last_line')
    hdata_line = weechat.hdata_get('line')
    hdata_line_data = weechat.hdata_get('line_data')

    gathered = []
    reachedTop = True  # Only False if we `break` at some point
    while cLine:
        data = weechat.hdata_pointer(hdata_line, cLine, 'data')
        if data:
            timestamp = weechat.hdata_time(hdata_line_data, data, 'date')
            prefix = weechat.hdata_string(hdata_line_data, data, 'prefix')
            msg = weechat.hdata_string(hdata_line_data, data, 'message')

            try:
                if mustExportLine(timestamp, prefix, msg):
                    gathered.append(LogLine(timestamp, prefix, msg))
            except StopExport:
                reachedTop = False
                break

        cLine = weechat.hdata_pointer(hdata_line, cLine, 'prev_line')

    if reachedTop:
        # Give `mustExportLine` the chance to signal something went wrong.
        mustExportLine(None, None, None)

    html = renderHtml(gathered[::-1], buff)
    writeFile(html, formatFilePath(exportFile))
예제 #8
0
def get_merged_buffers(ptr):
    """
	Get a list of buffers which are merged with "ptr".
	"""

    hdata = weechat.hdata_get("buffer")
    buffers = weechat.hdata_get_list(hdata, "gui_buffers")
    buffer = weechat.hdata_search(
        hdata, buffers,
        "${buffer.number} == %i" % weechat.hdata_integer(hdata, ptr, "number"),
        1)
    nbuffer = weechat.hdata_move(hdata, buffer, 1)

    ret = []
    while buffer:
        ret.append(weechat.hdata_string(hdata, buffer, "full_name"))

        if (weechat.hdata_integer(hdata, buffer,
                                  "number") == weechat.hdata_integer(
                                      hdata, nbuffer, "number")):
            buffer = nbuffer
            nbuffer = weechat.hdata_move(hdata, nbuffer, 1)
        else:
            buffer = None

    return ret
예제 #9
0
def buffer_build_regex(buffer):
	"""
	Build a regex according to "buffer"'s search settings.
	"""

	hdata = weechat.hdata_get("buffer")
	input = weechat.hdata_string(hdata, buffer, "input_buffer")
	exact = weechat.hdata_integer(hdata, buffer, "text_search_exact")
	where = weechat.hdata_integer(hdata, buffer, "text_search_where")
	regex = weechat.hdata_integer(hdata, buffer, "text_search_regex")

	if not regex:
		input = re.escape(input)

	if exact:
		input = "(?-i)%s" % input

	filter_regex = None
	if where == 1: # message
		filter_regex = input
	elif where == 2: # prefix
		filter_regex = "%s\\t" % input
	else: # prefix | message
		filter_regex = input # TODO: impossible with current filter regex

	return "!%s" % filter_regex
예제 #10
0
def buffer_build_regex(buffer):
    """
    Build a regex according to "buffer"'s search settings.
    """

    hdata = weechat.hdata_get("buffer")
    input = weechat.hdata_string(hdata, buffer, "input_buffer")
    exact = weechat.hdata_integer(hdata, buffer, "text_search_exact")
    where = weechat.hdata_integer(hdata, buffer, "text_search_where")
    regex = weechat.hdata_integer(hdata, buffer, "text_search_regex")

    if not regex:
        input = re.escape(input)

    if exact:
        input = "(?-i)%s" % input

    filter_regex = None
    if where == 1:  # message
        filter_regex = input
    elif where == 2:  # prefix
        filter_regex = "%s\\t" % input
    else:  # prefix | message
        filter_regex = input  # TODO: impossible with current filter regex

    return "!%s" % filter_regex
예제 #11
0
파일: soju.py 프로젝트: weechat/scripts
def get_last_message_time(buffer):
    lines = weechat.hdata_pointer(weechat.hdata_get("buffer"), buffer,
                                  "own_lines")
    line = weechat.hdata_pointer(weechat.hdata_get("lines"), lines,
                                 "last_line")
    while line:
        line_data = weechat.hdata_pointer(weechat.hdata_get("line"), line,
                                          "data")
        tags_count = weechat.hdata_integer(weechat.hdata_get("line_data"),
                                           line_data, "tags_count")
        tags = [
            weechat.hdata_string(weechat.hdata_get("line_data"), line_data,
                                 "{}|tags_array".format(i))
            for i in range(tags_count)
        ]
        irc_tags = [t for t in tags if t.startswith("irc_")]
        if len(irc_tags) > 0:
            break
        line = weechat.hdata_pointer(weechat.hdata_get("line"), line,
                                     "prev_line")
    if not line:
        return None
    # TODO: get timestamp with millisecond granularity
    ts = weechat.hdata_time(weechat.hdata_get("line_data"), line_data, "date")
    t = datetime.datetime.fromtimestamp(ts, tz=datetime.timezone.utc)
    return t
예제 #12
0
def hdata_server(server_to_search):
    hdata = weechat.hdata_get('irc_server')
    hdata_servers = weechat.hdata_get_list(hdata,'irc_servers')
    server = weechat.hdata_search(hdata, hdata_servers,'${irc_server.name} =* %s' % server_to_search, 1)
    if server:
        is_connected = weechat.hdata_integer(hdata, server, 'is_connected')
        nick_modes = weechat.hdata_string(hdata, server, 'nick_modes')
        buffer_ptr = weechat.hdata_pointer(hdata, server, 'buffer')
    return
예제 #13
0
def hdata_server(server_to_search):
    hdata = weechat.hdata_get('irc_server')
    hdata_servers = weechat.hdata_get_list(hdata, 'irc_servers')
    server = weechat.hdata_search(
        hdata, hdata_servers, '${irc_server.name} =* %s' % server_to_search, 1)
    if server:
        is_connected = weechat.hdata_integer(hdata, server, 'is_connected')
        nick_modes = weechat.hdata_string(hdata, server, 'nick_modes')
        buffer_ptr = weechat.hdata_pointer(hdata, server, 'buffer')
    return
예제 #14
0
파일: soju.py 프로젝트: weechat/scripts
def handle_hotlist_change(data, signal, signal_data):
    buffer = signal_data

    if buffer:
        sync_buffer_hotlist(buffer)
        return weechat.WEECHAT_RC_OK

    hdata = weechat.hdata_get("buffer")
    buffer = weechat.hdata_get_list(hdata, "gui_buffers")
    while buffer:
        full_name = weechat.hdata_string(hdata, buffer, "full_name")
        short_name = weechat.hdata_string(hdata, buffer, "short_name")
        hotlist = weechat.hdata_pointer(hdata, buffer, "hotlist")
        if not hotlist and full_name.startswith(
                "irc.") and not full_name.startswith("irc.server."):
            # Trim "irc." prefix and ".<target>" suffix to obtain server name
            server_name = full_name.replace("irc.", "",
                                            1)[:-len(short_name) - 1]
            send_buffer_read(buffer, server_name, short_name)
        buffer = weechat.hdata_pointer(hdata, buffer, "next_buffer")
    return weechat.WEECHAT_RC_OK
예제 #15
0
def irc_buffer_open(server, name, noswitch):
    hdata_irc_server = weechat.hdata_get("irc_server")
    irc_servers = weechat.hdata_get_list(hdata_irc_server, "irc_servers")
    irc_server = weechat.hdata_search(hdata_irc_server, irc_servers,
                                      "${irc_server.name} == " + server, 1)
    chantypes = weechat.hdata_string(hdata_irc_server, irc_server, "chantypes")
    is_channel = name[0] in chantypes

    noswitch_flag = "-noswitch " if noswitch else ""
    if is_channel:
        command_plugin(
            "irc", "/join {}-server {} {}".format(noswitch_flag, server, name))
    else:
        command_plugin(
            "irc", "/query {}-server {} {}".format(noswitch_flag, server,
                                                   name))
예제 #16
0
def get_merged_buffers(ptr):
    """
    Get a list of buffers which are merged with "ptr".
    """

    weechat_version = int(weechat.info_get("version_number", "") or 0)

    hdata = weechat.hdata_get("buffer")
    buffers = weechat.hdata_get_list(hdata, "gui_buffers")
    if weechat_version >= 0x03040000:
        buffer = weechat.hdata_search(
            hdata,
            buffers,
            "${buffer.number} == ${value}",
            {},
            {"value": str(weechat.hdata_integer(hdata, ptr, "number"))},
            {},
            1,
        )
    else:
        buffer = weechat.hdata_search(
            hdata,
            buffers,
            "${buffer.number} == %i" %
            weechat.hdata_integer(hdata, ptr, "number"),
            1,
        )
    nbuffer = weechat.hdata_move(hdata, buffer, 1)

    ret = []
    while buffer:
        ret.append(weechat.hdata_string(hdata, buffer, "full_name"))

        if weechat.hdata_integer(hdata, buffer,
                                 "number") == weechat.hdata_integer(
                                     hdata, nbuffer, "number"):
            buffer = nbuffer
            nbuffer = weechat.hdata_move(hdata, nbuffer, 1)
        else:
            buffer = None

    return ret
예제 #17
0
def get_merged_buffers(ptr):
	"""
	Get a list of buffers which are merged with "ptr".
	"""

	hdata = weechat.hdata_get("buffer")
	buffers = weechat.hdata_get_list(hdata, "gui_buffers")
	buffer = weechat.hdata_search(hdata, buffers, "${buffer.number} == %i" % weechat.hdata_integer(hdata, ptr, "number"), 1)
	nbuffer = weechat.hdata_move(hdata, buffer, 1)

	ret = []
	while buffer:
		ret.append(weechat.hdata_string(hdata, buffer, "full_name"))

		if (weechat.hdata_integer(hdata, buffer, "number") == weechat.hdata_integer(hdata, nbuffer, "number")):
			buffer = nbuffer
			nbuffer = weechat.hdata_move(hdata, nbuffer, 1)
		else:
			buffer = None

	return ret
예제 #18
0
def command_debug(buffer, command, args):
	hdata, buffers = get_buffers()
	buffers = merge_buffer_list(buffers)

	# Show evaluation results.
	log('Individual evaluation results:')
	start = perf_counter()
	key = buffer_sort_key(config.rules, config.helpers, config.case_sensitive)
	results = []
	for merged in buffers:
		for buffer in merged:
			fullname = weechat.hdata_string(hdata, buffer, 'full_name')
			if isinstance(fullname, bytes): fullname = fullname.decode('utf-8')
			results.append((fullname, key(buffer)))
	elapsed = perf_counter() - start

	for fullname, result in results:
			log('{0}: {1}'.format(fullname, result))
	log('Computing evalutaion results took {0:.4f} seconds.'.format(elapsed))

	return weechat.WEECHAT_RC_OK
예제 #19
0
def command_debug(buffer, command, args):
	hdata, buffers = get_buffers()
	buffers = merge_buffer_list(buffers)

	# Show evaluation results.
	log('Individual evaluation results:')
	start = perf_counter()
	key = buffer_sort_key(config.rules, config.helpers, config.case_sensitive)
	results = []
	for merged in buffers:
		for buffer in merged:
			fullname = weechat.hdata_string(hdata, buffer, 'full_name')
			if isinstance(fullname, bytes): fullname = fullname.decode('utf-8')
			results.append((fullname, key(buffer)))
	elapsed = perf_counter() - start

	for fullname, result in results:
			log('{0}: {1}'.format(fullname, result))
	log('Computing evalutaion results took {0:.4f} seconds.'.format(elapsed))

	return weechat.WEECHAT_RC_OK
예제 #20
0
def sort_buffers(hdata, buffers, rules, helpers, case_sensitive):
	for merged in buffers:
		for buffer in merged:
			name = weechat.hdata_string(hdata, buffer, 'name')

	return sorted(buffers, key=merged_sort_key(rules, helpers, case_sensitive))
예제 #21
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