• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python weechat.infolist_free函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中weechat.infolist_free函数的典型用法代码示例。如果您正苦于以下问题:Python infolist_free函数的具体用法?Python infolist_free怎么用?Python infolist_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了infolist_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_nicklist

def get_nicklist(server, channel):
    global options

    regex_flags = 0
    if options['ignore_case']:
        regex_flags = re.IGNORECASE
    ignore_list = w.config_get_plugin('ignore_list')
    if ignore_list == '':
        ignore_match = lambda x: False
    else:
        ignore_match = re.compile('(%s)$' % ignore_list.replace(',', '|'), regex_flags).match

    server = w.buffer_get_string(w.current_buffer(), 'localvar_server')
    my_nick = w.info_get('irc_nick', server)
    nicklist = {}
    infolist_nicklist = w.infolist_get('nicklist', w.current_buffer(), '')
    while w.infolist_next(infolist_nicklist):
        nick = w.infolist_string(infolist_nicklist, 'name')
        prefix = w.infolist_string(infolist_nicklist, 'prefix')
        nick_type = w.infolist_string(infolist_nicklist, 'type')
        if nick_type != 'nick' or (options['ignore_self'] and nick == my_nick) or ignore_match(nick):
            pass
        else:
            if not nicklist.has_key(prefix):
                nicklist[prefix]=[]
            nicklist[prefix].append(nick)
    w.infolist_free(infolist_nicklist)
    return nicklist
开发者ID:DarkDefender,项目名称:scripts,代码行数:28,代码来源:hl_nicks.py


示例2: match_against_nicklist

def match_against_nicklist(server, channel, hostmask):
    """Compare the hostmask against all users in the channel"""

    infolist = w.infolist_get("irc_nick", "", "{},{}".format(server, channel))

    if "$a:" in hostmask or "$~a" in hostmask:
        field = "account"
        hostmask = hostmask.replace("$a:", "")
        hostfield = False
    else:
        field = "host"
        hostfield = True

    extban_unreg = hostmask == "$~a"
    matches = []

    while w.infolist_next(infolist):
        name = w.infolist_string(infolist, "name")

        if hostfield:
            host = name + "!" + w.infolist_string(infolist, field)
        else:
            host = w.infolist_string(infolist, field)

        if ((extban_unreg and host == "*") or
            (not extban_unreg and w.string_match(host, hostmask, 0))):
            matches.append(name)

    w.infolist_free(infolist)
    return matches
开发者ID:DarkDefender,项目名称:scripts,代码行数:30,代码来源:maskmatch.py


示例3: update_user_count

def update_user_count(server=None, channel=None):
    if isinstance(channel, str):
        channel = set((channel, ))
    elif channel:
        channel = set(channel)

    def update_channel(server, channel=None):
        channel_infolist = weechat.infolist_get('irc_channel', '', server)
        while weechat.infolist_next(channel_infolist):
            _channel = weechat.infolist_string(channel_infolist, 'name')
            if channel:
                _channel = caseInsensibleKey(_channel)
                if _channel not in channel:
                    continue
            channel_stats[server, _channel] = weechat.infolist_integer(channel_infolist, 'nicks_count')
        weechat.infolist_free(channel_infolist)

    if not server:
        server_infolist = weechat.infolist_get('irc_server', '', '')
        while weechat.infolist_next(server_infolist):
            server = weechat.infolist_string(server_infolist, 'name')
            update_channel(server)
        weechat.infolist_free(server_infolist)
    else:
        update_channel(server, channel)
开发者ID:NuclearW,项目名称:weechat-scripts,代码行数:25,代码来源:chanstat.py


示例4: allquery_command_cb

def allquery_command_cb(data, buffer, args):
    """ Callback for /allquery command """
    args = args.strip()
    if args == "":
        weechat.command("", "/help %s" % SCRIPT_COMMAND)
        return weechat.WEECHAT_RC_OK
    argv = args.split(" ")

    exclude_nick = None

    if argv[0].startswith("-exclude="):
        exclude_nick = make_list(argv[0])
        command = " ".join(argv[1::])
    else:
        command = args
    if not command.startswith("/"):
        weechat.command("", "/help %s" % SCRIPT_COMMAND)
        return weechat.WEECHAT_RC_OK

    infolist = weechat.infolist_get("buffer", "", "")
    while weechat.infolist_next(infolist):
        if weechat.infolist_string(infolist, "plugin_name") == "irc":
            ptr = weechat.infolist_pointer(infolist, "pointer")
            server = weechat.buffer_get_string(ptr, "localvar_server")
            query = weechat.buffer_get_string(ptr, "localvar_channel")
            execute_command = re.sub(r'\b\$nick\b', query, command)
            if weechat.buffer_get_string(ptr, "localvar_type") == "private":
                if exclude_nick is not None:
                    if not query in exclude_nick:
                        weechat.command(ptr, execute_command)
                else:
                    weechat.command(ptr, execute_command)
    weechat.infolist_free(infolist)
    return weechat.WEECHAT_RC_OK
开发者ID:fbesser,项目名称:weechat_scripts,代码行数:34,代码来源:allquery.py


示例5: get_help_command

def get_help_command(plugin, input_cmd, input_args):
    """Get help for command in input."""
    global cmdhelp_settings
    if input_cmd == 'set' and input_args:
        return get_help_option(input_args)
    infolist = weechat.infolist_get('hook', '', 'command,%s' % input_cmd)
    cmd_plugin_name = ''
    cmd_command = ''
    cmd_args = ''
    cmd_desc = ''
    while weechat.infolist_next(infolist):
        cmd_plugin_name = (weechat.infolist_string(infolist, 'plugin_name') or
                           'core')
        cmd_command = weechat.infolist_string(infolist, 'command')
        cmd_args = weechat.infolist_string(infolist, 'args_nls')
        cmd_desc = weechat.infolist_string(infolist, 'description')
        if weechat.infolist_pointer(infolist, 'plugin') == plugin:
            break
    weechat.infolist_free(infolist)
    if cmd_plugin_name == 'alias':
        return '%sAlias %s%s%s => %s%s' % (
            weechat.color(cmdhelp_settings['color_alias']),
            weechat.color(cmdhelp_settings['color_alias_name']),
            cmd_command,
            weechat.color(cmdhelp_settings['color_alias']),
            weechat.color(cmdhelp_settings['color_alias_value']),
            cmd_desc,
        )
    if input_args:
        cmd_args = get_command_arguments(input_args, cmd_args)
    if not cmd_args:
        return None
    return '%s%s' % (weechat.color(cmdhelp_settings['color_arguments']),
                     cmd_args)
开发者ID:DarkDefender,项目名称:scripts,代码行数:34,代码来源:cmd_help.py


示例6: get_matching_buffers

def get_matching_buffers(input):
    """ Return list with buffers matching user input """
    global buffers_pos
    list = []
    if len(input) == 0:
        buffers_pos = 0
    input = input.lower()
    infolist = weechat.infolist_get("buffer", "", "")
    while weechat.infolist_next(infolist):
        if weechat.config_get_plugin("short_name") == "on":
            name = weechat.infolist_string(infolist, "short_name")
        else:
            name = weechat.infolist_string(infolist, "name")
        number = weechat.infolist_integer(infolist, "number")
        matching = name.lower().find(input) >= 0
        if not matching and input[-1] == ' ':
            matching = name.lower().endswith(input.strip())
        if not matching and input.isdigit():
            matching = str(number).startswith(input)
        if len(input) == 0 or matching:
            list.append({"number": number, "name": name})
            if len(input) == 0 and weechat.infolist_pointer(infolist, "pointer") == weechat.current_buffer():
                buffers_pos = len(list) - 1
    weechat.infolist_free(infolist)
    return list
开发者ID:GGLucas,项目名称:configs,代码行数:25,代码来源:go.py


示例7: gen_infolist_get

def gen_infolist_get(infolist_name, arguments, pointer=""):
    """
    Same as infolist_get(), but yields it's elements.
    Be sure to iterate through the whole list, to ensure
    weechat.infolist_free() is called.
    """
    infolist = weechat.infolist_get(infolist_name, pointer, arguments)
    if infolist:
        while weechat.infolist_next(infolist):
            fields = weechat.infolist_fields(infolist).split(',')
            field_names = []
            list_element = {}
            for field in fields:
                field_type, field_name = field.split(':')
                field_names.append(field_name)

                # decide which function to use
                info_func = {
                    'i': weechat.infolist_integer,
                    's': weechat.infolist_string,
                    'p': weechat.infolist_pointer,
                    # 'b': weechat.infolist_buffer,
                    't': weechat.infolist_time,
                }[field_type]
                value = info_func(infolist, field_name)
                list_element[field_name] = value
            # create a temporary namedtuple type using field_names
            item_tpl = namedtuple('InfolistItem', field_names)
            yield item_tpl(**list_element)
        weechat.infolist_free(infolist)
开发者ID:FichteForks,项目名称:knitori-tools,代码行数:30,代码来源:__init__.py


示例8: keydict_update

def keydict_update(*args):
    '''Populate a python dictionary with relevant key=>buffer mappings.'''

    global keydict

    keylist = w.infolist_get('key', '', '')
    if w.config_get_plugin('use_keybindings') == 'on':
        while w.infolist_next(keylist):
            key = w.infolist_string(keylist, 'key')
            # we dont want jump sequences
            if 'j' in key:
                continue
            key = key.replace('meta-', '')
            key = key.replace('ctrl-', '^')
            if w.config_get_plugin('skip_number_binds') == 'on':
                # skip entries where buffer number = key, typically entries below 11
                if key.isdigit():
                    continue
            command = w.infolist_string(keylist, 'command')
            # we only care about commands that leads to buffers
            if command.startswith('/buffer'):
                command = command.replace('/buffer ', '')
                buffer = command.lstrip('*')
                keydict[buffer] = key
    w.infolist_free(keylist)
    return w.WEECHAT_RC_OK
开发者ID:DarkDefender,项目名称:scripts,代码行数:26,代码来源:chanact.py


示例9: reorder_buffers

def reorder_buffers():
    """Reorders the buffers once the whitelist has changed
    """

    count = 2
    chan = ""

    ilist = weechat.infolist_get("buffer", "", "")

    for chan in whitelist:
        if -1 == chan.find(".#"): #network name is not set, matching by short_name
            weechat.infolist_reset_item_cursor(ilist)

            while weechat.infolist_next(ilist):
                if weechat.infolist_string(ilist, "short_name") == chan:
                    chan = weechat.infolist_string(ilist, "name")
                    break

        buff = weechat.buffer_search("irc", chan)

        if buff:
            weechat.buffer_set(buff, "number", str(count))
            count += 1

    weechat.infolist_free(ilist)

    return weechat.WEECHAT_RC_OK
开发者ID:DarkDefender,项目名称:scripts,代码行数:27,代码来源:chanpriority.py


示例10: disable_logging

    def disable_logging(self):
        """Return the previous logger level and set the buffer logger level
        to 0. If it was already 0, return None."""
        # If previous_log_level has not been previously set, return the level
        # we detect now.
        if not hasattr(self, 'previous_log_level'):
            infolist = weechat.infolist_get('logger_buffer', '', '')

            buf = self.buffer()
            previous_log_level = 0

            while weechat.infolist_next(infolist):
                if weechat.infolist_pointer(infolist, 'buffer') == buf:
                    previous_log_level = weechat.infolist_integer(
                        infolist, 'log_level')
                    if self.is_logged():
                        weechat.command(buf, '/mute logger disable')
                        self.print_buffer(
                            'Logs have been temporarily disabled for the session. They will be restored upon finishing the OTR session.')
                        break

            weechat.infolist_free(infolist)

            return previous_log_level

        # If previous_log_level was already set, it means we already altered it
        # and that we just detected an already modified logging level.
        # Return the pre-existing value so it doesn't get lost, and we can
        # restore it later.
        else:
            return self.previous_log_level
开发者ID:LogicalDash,项目名称:weechat-otr,代码行数:31,代码来源:weechat_otr.py


示例11: find_channels

def find_channels():
    """Return list of servers and channels"""
    #@TODO: make it return a dict with more options like "nicks_count etc."
    items = {}
    infolist = w.infolist_get('irc_server', '', '')
    # populate servers
    while w.infolist_next(infolist):
        items[w.infolist_string(infolist, 'name')] = ''

    w.infolist_free(infolist)

    # populate channels per server
    for server in items.keys():
        items[server] = '' #init if connected but no channels
        infolist = w.infolist_get('irc_channel', '',  server)
        while w.infolist_next(infolist):
            if w.infolist_integer(infolist, 'nicks_count') == 0:
                #parted but still open in a buffer: bit hackish
                continue
            if w.infolist_integer(infolist, 'type') == 0:
                channel = w.infolist_string(infolist, "buffer_short_name")
                items[server] += '%s,' %channel
        w.infolist_free(infolist)

    return items
开发者ID:sitaktif,项目名称:weechat-scripts,代码行数:25,代码来源:autojoin.py


示例12: buffer_opened_closed_cb

def buffer_opened_closed_cb(data, signal, signal_data):
    global OPTIONS

    # localvar not set in this moment? :-(
#    server = weechat.buffer_get_string(signal_data, 'localvar_server')          # get internal servername
    infolist = weechat.infolist_get('buffer', signal_data, '')
    weechat.infolist_next(infolist)
    plugin_name = weechat.infolist_string(infolist, 'plugin_name')
    name = weechat.infolist_string(infolist, 'name')
    weechat.infolist_free(infolist)

    # TODO how about matrix script or other non-irc channel buffer? no idea! help is welcome
    if plugin_name != "irc":                                                    # for example /fset, /color etc.pp buffer
        return weechat.WEECHAT_RC_OK

    if OPTIONS['activity'].lower() == 'no' or OPTIONS['activity'].lower() == 'off' or OPTIONS['activity'].lower() == '0':
        weechat.command('','/allchan -exclude=%s /buffer hide' % OPTIONS['channel_exclude'])
        if not signal_data:                                                     # signal_data available?
            weechat.command(signal_data,'/allchan -current /buffer unhide')
        else:                                                                   # signal_data empty!
            weechat.command('','/allchan /buffer hide')
        exclude_server('')
        single_channel_exclude()
    else:
        weechat.command('','/allchan /buffer hide')
    exclude_hotlist()
    return weechat.WEECHAT_RC_OK
开发者ID:weechatter,项目名称:weechat-scripts,代码行数:27,代码来源:collapse_channel.py


示例13: find_channels

def find_channels():
    """Return list of servers and channels"""
    #@TODO: make it return a dict with more options like "nicks_count etc."
    items = {}
    infolist = w.infolist_get('irc_server', '', '')
    # populate servers
    while w.infolist_next(infolist):
        items[w.infolist_string(infolist, 'name')] = ''

    w.infolist_free(infolist)

    # populate channels per server
    for server in items.keys():
        keys = []
        keyed_channels = []
        unkeyed_channels = []
        items[server] = '' #init if connected but no channels
        infolist = w.infolist_get('irc_channel', '',  server)
        while w.infolist_next(infolist):
            if w.infolist_integer(infolist, 'nicks_count') == 0:
                #parted but still open in a buffer: bit hackish
                continue
            if w.infolist_integer(infolist, 'type') == 0:
                key = w.infolist_string(infolist, "key")
                if len(key) > 0:
                    keys.append(key)
                    keyed_channels.append(w.infolist_string(infolist, "name"))
                else :
                    unkeyed_channels.append(w.infolist_string(infolist, "name"))
        items[server] = ','.join(keyed_channels + unkeyed_channels)
        if len(keys) > 0:
            items[server] += ' %s' % ','.join(keys)
        w.infolist_free(infolist)

    return items
开发者ID:AlanSherman,项目名称:.weechat,代码行数:35,代码来源:autojoin.py


示例14: save_query_buffer_to_file

def save_query_buffer_to_file():
    global query_buffer_list

    ptr_infolist_buffer = weechat.infolist_get("buffer", "", "")

    while weechat.infolist_next(ptr_infolist_buffer):
        ptr_buffer = weechat.infolist_pointer(ptr_infolist_buffer, "pointer")

        type = weechat.buffer_get_string(ptr_buffer, "localvar_type")
        if type == "private":
            server = weechat.buffer_get_string(ptr_buffer, "localvar_server")
            channel = weechat.buffer_get_string(ptr_buffer, "localvar_channel")
            query_buffer_list.insert(0, "%s %s" % (server, channel))

    weechat.infolist_free(ptr_infolist_buffer)

    filename = get_filename_with_path()

    if len(query_buffer_list):
        try:
            f = open(filename, "w")
            i = 0
            while i < len(query_buffer_list):
                f.write("%s\n" % query_buffer_list[i])
                i = i + 1
            f.close()
        except:
            weechat.prnt(
                "", '%s%s: Error writing query buffer to "%s"' % (weechat.prefix("error"), SCRIPT_NAME, filename)
            )
            raise
    else:  # no query buffer(s). remove file
        if os.path.isfile(filename):
            os.remove(filename)
    return
开发者ID:Shrews,项目名称:scripts,代码行数:35,代码来源:queryman.py


示例15: get_patterns_in_config

def get_patterns_in_config(filter):
    d = {}
    infolist = weechat.infolist_get('option', '', 'plugins.var.python.%s.%s' %(SCRIPT_NAME, filter))
    while weechat.infolist_next(infolist):
        name = weechat.infolist_string(infolist, 'option_name')
        name = name[len('python.%s.' %SCRIPT_NAME):]
        # channels might have dots in their names, so we'll strip type from right and server
        # from left. Lets hope that users doesn't use dots in server names.
        name, _, type = name.rpartition('.')
        if type not in ('op', 'halfop', 'voice'):
            # invalid option
            continue
        server, _, channel = name.partition('.')
        value = weechat.infolist_string(infolist, 'value')
        if not value:
            continue
        else:
            value = value.split(',')
        key = (server, channel)
        if key not in d:
            d[key] = {type:value}
        else:
            d[key][type] = value
    weechat.infolist_free(infolist)
    return d
开发者ID:qguv,项目名称:config,代码行数:25,代码来源:automode.py


示例16: hotlist_dict

def hotlist_dict():
    """Return the contents of the hotlist as a dictionary.

    The returned dictionary has the following structure:
    >>> hotlist = {
    ...     "0x0": {                    # string representation of the buffer pointer
    ...         "count_low": 0,
    ...         "count_message": 0,
    ...         "count_private": 0,
    ...         "count_highlight": 0,
    ...     }
    ... }
    """
    hotlist = {}
    infolist = weechat.infolist_get("hotlist", "", "")
    while weechat.infolist_next(infolist):
        buffer_pointer = weechat.infolist_pointer(infolist, "buffer_pointer")
        hotlist[buffer_pointer] = {}
        hotlist[buffer_pointer]["count_low"] = weechat.infolist_integer(
            infolist, "count_00")
        hotlist[buffer_pointer]["count_message"] = weechat.infolist_integer(
            infolist, "count_01")
        hotlist[buffer_pointer]["count_private"] = weechat.infolist_integer(
            infolist, "count_02")
        hotlist[buffer_pointer]["count_highlight"] = weechat.infolist_integer(
            infolist, "count_03")
    weechat.infolist_free(infolist)
    return hotlist
开发者ID:DarkDefender,项目名称:scripts,代码行数:28,代码来源:buffer_autohide.py


示例17: get_options

def get_options():
    """
    Get list of config options in a dict with 4 indexes: config,
    section, option, xxx.
    """
    global plugin_list, ignore_options
    options = \
        defaultdict(lambda: defaultdict(lambda: defaultdict(defaultdict)))
    infolist = weechat.infolist_get('option', '', '')
    while weechat.infolist_next(infolist):
        full_name = weechat.infolist_string(infolist, 'full_name')
        if not re.search('|'.join(ignore_options), full_name):
            config = weechat.infolist_string(infolist, 'config_name')
            if config in plugin_list and 'o' in plugin_list[config]:
                section = weechat.infolist_string(infolist, 'section_name')
                option = weechat.infolist_string(infolist, 'option_name')
                for key in ('type', 'string_values', 'default_value',
                            'description'):
                    options[config][section][option][key] = \
                        weechat.infolist_string(infolist, key)
                for key in ('min', 'max', 'null_value_allowed'):
                    options[config][section][option][key] = \
                        weechat.infolist_integer(infolist, key)
    weechat.infolist_free(infolist)
    return options
开发者ID:stfnm,项目名称:weechat_old,代码行数:25,代码来源:docgen.py


示例18: bufsave_cmd

def bufsave_cmd(data, buffer, args):
    ''' Callback for /bufsave command '''

    filename = args

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

    if exists(filename):
        w.prnt('', "Error: target file already exists!")
        return w.WEECHAT_RC_OK
        
    infolist = w.infolist_get('buffer_lines', buffer, '')
    channel =  w.buffer_get_string(buffer, 'name')
    try:
        fp = file(filename, 'w')
    except:
        w.prnt('', "Error writing to target file!")
        return w.WEECHAT_RC_OK

    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)

    return w.WEECHAT_RC_OK
开发者ID:FiXato,项目名称:weechat-scripts-xt,代码行数:31,代码来源:bufsave.py


示例19: check_buffer_timer_cb

def check_buffer_timer_cb(data, remaining_calls):
    global WEECHAT_VERSION,whitelist

    # search for buffers in hotlist
    ptr_infolist = weechat.infolist_get("hotlist", "", "")
    while weechat.infolist_next(ptr_infolist):
        ptr_buffer = weechat.infolist_pointer(ptr_infolist, "buffer_pointer")
        localvar_name = weechat.buffer_get_string(ptr_buffer, 'localvar_name')
        # buffer in whitelist? go to next buffer
        buf_type = weechat.buffer_get_string(ptr_buffer,'localvar_type')
        # buffer is a query buffer?
        if OPTIONS['ignore_query'].lower() == 'on' and buf_type == 'private':
            continue
        # buffer in whitelist?
        if localvar_name in whitelist:
            continue
        if ptr_buffer:
            if get_time_from_line(ptr_buffer):
                if OPTIONS['clear'].lower() == 'hotlist' or OPTIONS['clear'].lower() == 'all':
                    weechat.buffer_set(ptr_buffer, "hotlist", '-1')
                if OPTIONS['clear'].lower() == 'unread' or OPTIONS['clear'].lower() == 'all':
                    weechat.command(ptr_buffer,"/input set_unread_current_buffer")

    weechat.infolist_free(ptr_infolist)
    return weechat.WEECHAT_RC_OK
开发者ID:DarkDefender,项目名称:scripts,代码行数:25,代码来源:automarkbuffer.py


示例20: servernicks

def servernicks(servername):
    infolist = weechat.infolist_get('irc_server','',servername)
    weechat.infolist_next(infolist)
    nicks = weechat.infolist_string(infolist, 'nicks')
    weechat.infolist_free(infolist)
    servernicks = nicks.split(',')
    return servernicks
开发者ID:megalithic,项目名称:dotfiles,代码行数:7,代码来源:keepnick.py



注:本文中的weechat.infolist_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python weechat.infolist_get函数代码示例发布时间:2022-05-26
下一篇:
Python weechat.info_get_hashtable函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap