Beispiel #1
0
def exclude_server():
    global OPTIONS
    for server_exclude in OPTIONS['server_exclude'].split(','):
        if server_exclude == '*':  # show buffer for all server
            weechat.command(
                '', '/buffer unhide -all')  # simply unload script, no!? :-)
            break

        # search exclude server in list of servers
        hdata = weechat.hdata_get('irc_server')
        servers = weechat.hdata_get_list(hdata, 'irc_servers')
        if int(version) >= 0x03040000:
            server = weechat.hdata_search(
                hdata,
                servers,
                '${irc_server.name} =* ${server_name}',
                {},
                {'server_name': server_exclude},
                {},
                1,
            )
        else:
            server = weechat.hdata_search(
                hdata,
                servers,
                '${irc_server.name} =* %s' % server_exclude,
                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')
            weechat.command(buffer_ptr, '/allchan -current /buffer unhide')
    return
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
Beispiel #3
0
def hotlist_item_cb(data, item, window):
    priorities = {}
    titles = {}

    hdata_hotlist = w.hdata_get('hotlist')
    ptr_hotlist = w.hdata_get_list(hdata_hotlist, 'gui_hotlist')
    while ptr_hotlist:
        priority = w.hdata_integer(hdata_hotlist, ptr_hotlist, 'priority')
        buffer = w.hdata_pointer(hdata_hotlist, ptr_hotlist, 'buffer')
        count = w.hdata_integer(
            hdata_hotlist, ptr_hotlist, '%d|count' % GUI_HOTLIST_MESSAGE)
        number = w.buffer_get_integer(buffer, 'number')
        name = w.buffer_get_string(buffer, 'short_name')

        if priority != GUI_HOTLIST_LOW:
            priorities[number] = priority
            titles[number] = '%d:%s' % (number, name)
            if count:
                titles[number] += '(%d)' % count

        ptr_hotlist = w.hdata_move(hdata_hotlist, ptr_hotlist, 1)

    items = []
    for number, priority in sorted(priorities.items()):
        items.append('%s %s %s' % (
            w.color(COLORS[priority]),
            titles[number],
            w.color('reset')))
    return ' '.join(items)
Beispiel #4
0
def filter_exists(name):
    """
    Check whether a filter named "name" exists.
    """

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

    hdata = weechat.hdata_get("filter")
    filters = weechat.hdata_get_list(hdata, "gui_filters")
    if weechat_version >= 0x03040000:
        filter = weechat.hdata_search(
            hdata,
            filters,
            "${filter.name} == ${name}",
            {},
            {"name": name},
            {},
            1,
        )
    else:
        filter = weechat.hdata_search(
            hdata,
            filters,
            "${filter.name} == %s" % name,
            1,
        )

    return bool(filter)
Beispiel #5
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
Beispiel #6
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
Beispiel #7
0
def filter_exists(name):
	"""
	Check whether a filter named "name" exists.
	"""

	hdata = weechat.hdata_get("filter")
	filters = weechat.hdata_get_list(hdata, "gui_filters")
	filter = weechat.hdata_search(hdata, filters, "${filter.name} == %s" % name, 1)

	return bool(filter)
Beispiel #8
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
Beispiel #9
0
def filter_exists(name):
	"""
	Check whether a filter named "name" exists.
	"""

	hdata = weechat.hdata_get("filter")
	filters = weechat.hdata_get_list(hdata, "gui_filters")
	filter = weechat.hdata_search(hdata, filters, "${filter.name} == %s" % name, 1)

	return bool(filter)
Beispiel #10
0
def get_buffers():
	''' Get a list of all the buffers in weechat. '''
	hdata  = weechat.hdata_get('buffer')
	buffer = weechat.hdata_get_list(hdata, "gui_buffers");

	result = []
	while buffer:
		number = weechat.hdata_integer(hdata, buffer, 'number')
		result.append((number, buffer))
		buffer = weechat.hdata_pointer(hdata, buffer, 'next_buffer')
	return hdata, result
Beispiel #11
0
def auth_command(data, buffer, args):
    list_args = args.split(" ")
    server, channel = get_channel_from_buffer_args(buffer, args)
    #strip spaces
    while '' in list_args:
        list_args.remove('')
    while ' ' in list_args:
        list_args.remove(' ')

    h_servers = weechat.hdata_get("irc_server")
    l_servers = weechat.hdata_get_list(h_servers, "irc_servers")

    if len(list_args) ==  0:
        weechat.command(buffer, "/help auth")
    elif list_args[0] not in ["add", "del", "list", "cmd"]:
        weechat.prnt(buffer, "[%s] bad option while using /auth command, try '/help auth' for more info" % (NAME))
    elif list_args[0] == "cmd":
        if len(list_args[1:]) == 1 and weechat.hdata_search(h_servers, l_servers, "${irc_server.name} == "+list_args[1], 1):
            auth_cmd("", list_args[1])
        elif len(list_args[1:]) == 1:
            auth_cmd(list_args[1], server)
        elif len(list_args[1:]) >= 2:
            if weechat.hdata_search(h_servers, l_servers, "${irc_server.name} == "+list_args[-1], 1):
                auth_cmd(" ".join(list_args[1:-1]), list_args[-1])
            else:
                auth_cmd(" ".join(list_args[1:]), server)
        else:
            auth_cmd(" ".join(list_args[1:]), server)
    elif list_args[0] == "list":
        auth_list()
    elif list_args[0] == "add":
        if len(list_args) < 3 or (len(list_args) == 3 and server == ''):
            weechat.prnt(buffer, "[%s] bad option while using /auth command, try '/help auth' for more info" % (NAME))
        else:
            if len(list_args) == 3:
                auth_add(list_args[1], list_args[2], server)
            else:
                auth_add(list_args[1], list_args[2], list_args[3])
    elif list_args[0] == "del":
       if len(list_args) < 2:
           weechat.prnt(buffer, "[%s] bad option while using /auth command, try '/help auth' for more info" % (NAME))
       else:
            if len(list_args) == 2:
                auth_del(list_args[1], server)
            else:
                auth_del(list_args[1], list_args[2])
    else:
        pass
    return weechat.WEECHAT_RC_OK
Beispiel #12
0
    def refresh_buffers(self):
        self.buffers.clear()
        hdata = weechat.hdata_get("buffer")
        buffer = weechat.hdata_get_list(hdata, "gui_buffers")

        if not hdata or not buffer:
            return weechat.WEECHAT_RC_OK
        while True:
            buffer = weechat.hdata_move(hdata, buffer, 1)
            if not buffer:
                break
            else:
                buf = self.buffers[full_name(buffer)] = Buffer(buffer, self.opts)
                logging.debug("Hideable: {}".format(buf.is_hideable()))
                self.try_hide(self.buffers[full_name(buffer)])
Beispiel #13
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))
def exclude_server(server):
    global OPTIONS
    for server_exclude in OPTIONS['server_exclude'].split(','):
        if server_exclude == '*':                                               # show buffer for all server
            weechat.command('','/buffer unhide -all')                           # simply unload script, no!? :-)
            break

        # search exclude server in list of servers
        hdata = weechat.hdata_get('irc_server')
        servers = weechat.hdata_get_list(hdata, 'irc_servers')
        server = weechat.hdata_search(hdata, servers, '${irc_server.name} =* %s' % server_exclude, 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')
            weechat.command(buffer_ptr,'/allchan -current /buffer unhide')
    return
Beispiel #15
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
Beispiel #16
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
Beispiel #17
0
def server_by_name(server_name):
    hdata = weechat.hdata_get("irc_server")
    server_list = weechat.hdata_get_list(hdata, "irc_servers")
    weechat_version = int(weechat.info_get("version_number", "") or 0)
    if weechat_version >= 0x03040000:
        return weechat.hdata_search(
            hdata,
            server_list,
            "${irc_server.name} == ${name}",
            {},
            {"name": server_name},
            {},
            1,
        )
    else:
        return weechat.hdata_search(
            hdata,
            server_list,
            "${irc_server.name} == " + server_name,
            1,
        )
Beispiel #18
0
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
Beispiel #19
0
def buffer_open_full_name_irc_cb(data, signal, hashtable):
    full_name = hashtable["full_name"]
    noswitch = bool(int(hashtable.get("noswitch", "0")))

    m = IRC_SERVER_RE.match(full_name)
    if m:
        server = m.group(1)
        irc_server_open(server, noswitch)
        return weechat.WEECHAT_RC_OK_EAT

    m = IRC_BUFFER_RE.match(full_name)
    if m:
        server = m.group(1)
        name = m.group(2)

        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)
        if irc_server:
            is_connected = bool(
                weechat.hdata_integer(hdata_irc_server, irc_server,
                                      "is_connected"))
            is_connecting = bool(
                weechat.hdata_pointer(hdata_irc_server, irc_server,
                                      "hook_connect"))
            if is_connected:
                irc_buffer_open(server, name, noswitch)
            else:
                irc_server_connected_opens[server].add((name, noswitch))
                if not is_connecting:
                    irc_server_open(server, noswitch)
        else:
            error("unknown server {}".format(server))

        return weechat.WEECHAT_RC_OK_EAT

    return weechat.WEECHAT_RC_OK
Beispiel #20
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
Beispiel #21
0
def auth_command(data, buffer, args):
    list_args = args.split(" ")
    server, channel = get_channel_from_buffer_args(buffer, args)
    # strip spaces
    while "" in list_args:
        list_args.remove("")
    while " " in list_args:
        list_args.remove(" ")

    h_servers = weechat.hdata_get("irc_server")
    l_servers = weechat.hdata_get_list(h_servers, "irc_servers")

    if len(list_args) == 0:
        weechat.command(buffer, "/help autoauth")
    elif list_args[0] not in ["add", "del", "list", "cmd", "ns"]:
        weechat.prnt(
            buffer,
            "[%s] bad option while using /autoauth command, "
            "try '/help autoauth' for more info" % (NAME),
        )
    elif list_args[0] == "cmd":
        if len(list_args[1:]) == 1 and search_server(h_servers, l_servers,
                                                     list_args[1]):
            auth_cmd("", list_args[1])
        elif len(list_args[1:]) == 1:
            auth_cmd(list_args[1], server)
        elif len(list_args[1:]) >= 2:
            if search_server(h_servers, l_servers, list_args[-1]):
                auth_cmd(" ".join(list_args[1:-1]), list_args[-1])
            else:
                auth_cmd(" ".join(list_args[1:]), server)
        else:
            auth_cmd(" ".join(list_args[1:]), server)
    elif list_args[0] == "ns":
        if len(list_args[1:]) == 1 and search_server(h_servers, l_servers,
                                                     list_args[1]):
            auth_ns("", list_args[1])
        elif len(list_args[1:]) == 1:
            auth_ns(list_args[1], server)
        elif len(list_args[1:]) == 2:
            if search_server(h_servers, l_servers, list_args[-1]):
                auth_ns(" ".join(list_args[1:-1]), list_args[-1])
            else:
                auth_ns(" ".join(list_args[1:]), server)
        else:
            auth_ns(" ".join(list_args[1:]), server)
    elif list_args[0] == "list":
        auth_list()
    elif list_args[0] == "add":
        if len(list_args) < 3 or (len(list_args) == 3 and server == ""):
            weechat.prnt(
                buffer,
                "[%s] bad option while using /autoauth command, try '/help autoauth' for more info"
                % (NAME),
            )
        else:
            if len(list_args) == 3:
                auth_add(list_args[1], list_args[2], server)
            else:
                auth_add(list_args[1], list_args[2], list_args[3])
    elif list_args[0] == "del":
        if len(list_args) < 2:
            weechat.prnt(
                buffer,
                "[%s] bad option while using /autoauth command, try '/help autoauth' for more info"
                % (NAME),
            )
        else:
            if len(list_args) == 2:
                auth_del(list_args[1], server)
            else:
                auth_del(list_args[1], list_args[2])
    else:
        pass
    return weechat.WEECHAT_RC_OK
Beispiel #22
0
    time = Timer("list(find_urls(string))", "import re; from __main__ import find_urls, string").timeit(ITERATIONS)
    print "%s lookups on a %s character long string with %s urls took %s seconds (%s seconds per iteration)" % \
          (ITERATIONS, len(string), len(urls), time, time/ITERATIONS)
else:
    if not weechat.register(SCRIPT_NAME, "oakkitten", SCRIPT_VERSION, "MIT", "Display hints for urls and open them with keyboard shortcuts", "exit_function", ""):
        raise Exception("Could not register script")

    WEECHAT_VERSION = int(weechat.info_get('version_number', '') or 0)
    if WEECHAT_VERSION <= 0x00040000:
        raise Exception("Need Weechat 0.4 or higher")

    H_BUFFER = weechat.hdata_get("buffer")
    H_LINES = weechat.hdata_get("lines")
    H_LINE = weechat.hdata_get("line")
    H_LINE_DATA = weechat.hdata_get("line_data")
    HL_GUI_BUFFERS = weechat.hdata_get_list(H_BUFFER, "gui_buffers")

    load_config()

    weechat.hook_print("", "", "", 0, "on_print", "")
    weechat.hook_signal("buffer_switch", "on_buffer_switch", "")
    weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "load_config", "")

    if not weechat.hook_command("url_hint", __doc__.strip(), "", "", "", "url_hint", ""):
        print_error("could not hook command /url_hint")

    if not weechat.hook_command("url_hint_replace", """Replaces {url1} with url hinted with a 1, etc. Example usage:

Open url 1 in your default browser:

  /url_hint_replace /exec -bg xdg-open {url1}
Beispiel #23
0
else:
    if not weechat.register(
            SCRIPT_NAME, "oakkitten", SCRIPT_VERSION, "MIT",
            "Display hints for urls and open them with keyboard shortcuts",
            "exit_function", ""):
        raise Exception("Could not register script")

    WEECHAT_VERSION = int(weechat.info_get('version_number', '') or 0)
    if WEECHAT_VERSION <= 0x00040000:
        raise Exception("Need Weechat 0.4 or higher")

    H_BUFFER = weechat.hdata_get("buffer")
    H_LINES = weechat.hdata_get("lines")
    H_LINE = weechat.hdata_get("line")
    H_LINE_DATA = weechat.hdata_get("line_data")
    HL_GUI_BUFFERS = weechat.hdata_get_list(H_BUFFER, "gui_buffers")

    load_config()

    weechat.hook_print("", "", "", 0, "on_print", "")
    weechat.hook_signal("buffer_switch", "on_buffer_switch", "")
    weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*",
                        "load_config", "")

    if not weechat.hook_command("url_hint", __doc__.strip(), "", "", "",
                                "url_hint", ""):
        print_error("could not hook command /url_hint")

    if not weechat.hook_command(
            "url_hint_replace",
            """Replaces {url1} with url hinted with a 1, etc. Example usage: