当前位置: 首页>>代码示例>>Python>>正文


Python weechat.buffer_get_string函数代码示例

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


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

示例1: priv_msg_cb

def priv_msg_cb(data, bufferp, uber_empty, tagsn, isdisplayed,
        ishilight, prefix, message):
    """Sends highlighted message to be printed on notification"""

    am_away = w.buffer_get_string(bufferp, 'localvar_away')

    if not am_away:
	w.prnt("", "[weebullet] Not away, skipping notification")
	return w.WEECHAT_RC_OK

    notif_body = u"<%s> %s" % (
        prefix.decode('utf-8'),
	message.decode('utf-8')
    )

    # Check that it's in a "/q" buffer and that I'm not the one writing the msg
    is_pm = w.buffer_get_string(bufferp, "localvar_type") == "private"
    is_notify_private = re.search(r'(^|,)notify_private(,|$)', tagsn) is not None
    # PM (query)
    if (is_pm and is_notify_private):
	send_push(
		title="Privmsg from %s" % prefix.decode('utf-8'),
		body=notif_body
	)

    # Highlight (your nick is quoted)
    elif (ishilight == "1"):
        bufname = (w.buffer_get_string(bufferp, "short_name") or
                w.buffer_get_string(bufferp, "name"))
	send_push(
		title="Highlight in %s" % bufname.decode('utf-8'),
		body=notif_body
	)

    return w.WEECHAT_RC_OK
开发者ID:halkeye,项目名称:weebullet,代码行数:35,代码来源:weebullet.py

示例2: buffer_opened_cb

def buffer_opened_cb(data, signal, signal_data):
    ptr_buffer = signal_data
    plugin = weechat.buffer_get_string(ptr_buffer, 'localvar_plugin')
    name = weechat.buffer_get_string(ptr_buffer, 'localvar_name')
    filename = get_filename_with_path('%s.%s' % (plugin,name))
    read_history(filename,ptr_buffer)
    return weechat.WEECHAT_RC_OK
开发者ID:weechatter,项目名称:weechat-scripts,代码行数:7,代码来源:histman.py

示例3: unread_cb

def unread_cb(data, buffer, command):
    global all_channels
    channels = []
    if command.find("set_unread_current_buffer") >= 0:
        if w.buffer_get_string(buffer, "localvar_server") == "slack" and \
           w.buffer_get_string(buffer, "localvar_type") in ["channel", "private"]:
            channels.append(w.buffer_get_string(buffer, "localvar_channel"))
    else:
        channels = _channels()

    for c in channels:
        cs = c.lstrip("#")
        if cs in all_channels:
            try:
                if c.startswith("#"):
                    if cs in private_groups:
                        r = slack.groups.mark(all_channels[cs], time.time())
                    else:
                        r = slack.channels.mark(all_channels[cs], time.time())
                else:
                    r = slack.im.mark(all_channels[cs], time.time())
                #w.prnt("", "%s: %s" % (c, r.body["ok"] and "ok" or "not ok"))
            except:
                w.prnt("", "Error while setting unread marker on %s" % c)
    w.prnt("", "%d channels marked as read" % len(channels))

    return w.WEECHAT_RC_OK
开发者ID:palbo,项目名称:dotfiles,代码行数:27,代码来源:slack.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: notification_callback

def notification_callback(data, bufferp, uber_empty, tagsn, isdisplayed, ishilight, prefix, message):

    is_away = weechat.buffer_get_string(bufferp, 'localvar_away')
    is_focused = bufferp == weechat.current_buffer()
    do_prowl = True # If set to False depending on state and settings, no Prowl notification will be sent

    if (is_away):
        if (is_focused and weechat.config_get_plugin('notify_focused_away') != 'on'):
            do_prowl = False
        elif (not is_focused and weechat.config_get_plugin('notify_unfocused_away') != 'on'):
            do_prowl = False
    else:
        if (is_focused and weechat.config_get_plugin('notify_focused_active') != 'on'):
            do_prowl = False
        elif (not is_focused and weechat.config_get_plugin('notify_unfocused_active') != 'on'):
            do_prowl = False

    if (do_prowl):
        if (weechat.buffer_get_string(bufferp, 'localvar_type') == 'private' and weechat.config_get_plugin('show_priv_msg') == 'on' and prefix != weechat.buffer_get_string(bufferp, 'localvar_nick')):
            send_prowl_notification(prefix, message, True)
        elif (ishilight == '1' and weechat.config_get_plugin('show_hilights') == 'on'):
            buffer = (weechat.buffer_get_string(bufferp, 'short_name') or weechat.buffer_get_string(bufferp, 'name'))
            send_prowl_notification(buffer, prefix + weechat.config_get_plugin('nick_separator') + message, False)

    return weechat.WEECHAT_RC_OK
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:25,代码来源:weeprowl.py

示例6: prepare_notification

def prepare_notification(buffer, is_highlight, nick, message):
    """Prepares a notification from the given data."""
    if is_highlight:
        source = (weechat.buffer_get_string(buffer, 'short_name') or
                  weechat.buffer_get_string(buffer, 'name'))
        message = nick + nick_separator() + message
    else:
        # A private message.
        source = nick

    max_length = int(weechat.config_get_plugin('max_length'))
    if max_length > 0:
        ellipsis = weechat.config_get_plugin('ellipsis')
        message = shorten_message(message, max_length, ellipsis)

    if weechat.config_get_plugin('escape_html') == 'on':
        message = escape_html(message)

    message = escape_slashes(message)

    icon = weechat.config_get_plugin('icon')
    timeout = weechat.config_get_plugin('timeout')
    urgency = weechat.config_get_plugin('urgency')

    return Notification(source, message, icon, timeout, urgency)
开发者ID:craigcabrey,项目名称:dotfiles,代码行数:25,代码来源:notify_send.py

示例7: twitch_buffer_switch

def twitch_buffer_switch(data, signal, signal_data):
    server = weechat.buffer_get_string(signal_data, 'localvar_server')
    type = weechat.buffer_get_string(signal_data, 'localvar_type')
    if not (server in OPTIONS['servers'].split() and type == 'channel'):
        return weechat.WEECHAT_RC_OK
    twitch_main('', signal_data, 'bs')
    return weechat.WEECHAT_RC_OK
开发者ID:MatthewCox,项目名称:dotfiles,代码行数:7,代码来源:twitch.py

示例8: show_item

def show_item(data, item, window):
    bufpointer = weechat.window_get_pointer(window, "buffer")
    if bufpointer == "":
        return ""

    if weechat.buffer_get_string(bufpointer, "name") != "weechat":  # not weechat core buffer
        if weechat.buffer_get_string(bufpointer, "localvar_type") == "":  # buffer with free content?
            return ""

    lines_after, lines_count, percent, current_line = count_lines(window, bufpointer)

    if lines_count == 0:  # buffer empty?
        return ""

    tags = {"%C": str(current_line), "%A": str(lines_after), "%L": str(lines_count), "%P": str(percent) + "%"}

    bufsize_item = substitute_colors(OPTIONS["format"])

    # replace mandatory tags
    for tag in list(tags.keys()):
        #    for tag in tags.keys():
        bufsize_item = bufsize_item.replace(tag, tags[tag])

    # replace optional tags
    # %{…} only if lines after (e.g. %A > 0)
    if lines_after > 0:
        for regex_tag in regex_optional_tags.findall(bufsize_item):
            bufsize_item = bufsize_item.replace(regex_tag, regex_tag.lstrip("%{").rstrip("}"))
    else:
        bufsize_item = regex_optional_tags.sub("", bufsize_item)

    return bufsize_item
开发者ID:Ratler,项目名称:weechatter-weechat-scripts,代码行数:32,代码来源:bufsize.py

示例9: notify_show

def notify_show(data, bufferp, uber_empty, tagsn, isdisplayed,
        ishilight, prefix, message):

    #are we away?
    away = weechat.buffer_get_string(bufferp,"localvar_away")
    if (away == "" and weechat.config_get_plugin("only_away") == "on"):
        return weechat.WEECHAT_RC_OK
        
    #get local nick for buffer
    mynick = weechat.buffer_get_string(bufferp,"localvar_nick")

    # get name of buffer
    name = weechat.buffer_get_string(bufferp,"name")

    # ignore buffers on ignorelist
    if not name in weechat.config_get_plugin("ignore").split(","):
        # only notify if the message was not sent by myself
        if (weechat.buffer_get_string(bufferp, "localvar_type") == "private") and (prefix!=mynick):
            show_notification(prefix, prefix, message)

        elif ishilight == "1":
            buffer = (weechat.buffer_get_string(bufferp, "short_name") or name)
            show_notification(buffer, prefix, message)

    return weechat.WEECHAT_RC_OK
开发者ID:balu-,项目名称:weechat-irssinotifier,代码行数:25,代码来源:irssinotifier.py

示例10: get_buffer_info

def get_buffer_info(buf):
    server = weechat.buffer_get_string(buf, b'localvar_server').decode(
        'utf-8', 'replace')
    channel = weechat.buffer_get_string(buf, b'localvar_channel').decode(
        'utf-8', 'replace')

    return server, channel
开发者ID:mutantmonkey,项目名称:weesodium,代码行数:7,代码来源:weesodium.py

示例11: word_magic

def word_magic(data, buffer, command):
    # get the input string
    uinput = w.buffer_get_string(buffer, "input")

    # if the buffer is blacklisted, do nothing
    if w.buffer_get_string(buffer, "short_name") in w.config_get_plugin(
            "blacklist_buffers").split(","):
        return w.WEECHAT_RC_OK

    if command == "/input return":
        # in case the line's empty, do nothing
        if uinput == "":
            return w.WEECHAT_RC_OK
        # bypass this using a backslash as the first character
        elif uinput.startswith("\\"):
            uinput = uinput.replace("\\", "", 1)
        # we don't want to capitalize basic URLs
        elif uinput[:4] == "http": # I'M TOO LAZY FOR REGEX MATCHING
            return w.WEECHAT_RC_OK
        # if we point to a user, don't capitalise this
        elif isnick(buffer, uinput.split()[0][:-1]):
            return w.WEECHAT_RC_OK
        # if everything else is fine, replace the first char with its capital
        else:
            uinput = uinput.replace(uinput[0], uinput[0].upper(), 1)
        # set the new string into the input
        w.buffer_set(buffer, "input", uinput)
    return w.WEECHAT_RC_OK
开发者ID:vlad-s,项目名称:weechat-plugins,代码行数:28,代码来源:auto_capital.py

示例12: check_buffer_type

def check_buffer_type(window, data, value):
    bufpointer = weechat.window_get_pointer(window,"buffer")
    if bufpointer == "":
        return ""

    value = value.split(' ', 1)
    if len(value) <= 1:
        return ""

    # format is : buffer_type (channel,server,private,all) | signal (e.g: buffer_switch)
    channel_type_and_signal = value[0]
    if channel_type_and_signal.find('|') >= 0:
        channel_type = channel_type_and_signal[0:channel_type_and_signal.find("|")]
        signal_type = channel_type_and_signal[channel_type_and_signal.find("|")+1:]
        unhook(data)
        add_hook(signal_type, data)
    else:
        channel_type = value[0]

    value = value[1]

    if channel_type == 'all' or weechat.buffer_get_string(bufpointer,'localvar_type') == channel_type:
        return value
    if channel_type == '!all':
        a = ["channel","server","private"]
        if weechat.buffer_get_string(bufpointer,'localvar_type') in a:
            return value
    return ""
开发者ID:weechatter,项目名称:weechat-scripts,代码行数:28,代码来源:text_item.py

示例13: notify_show

def notify_show(data, bufferp, uber_empty, tagsn, isdisplayed,
                ishighlight, prefix, message):

    if weechat.config_get_plugin("enabled") == "off":
        return weechat.WEECHAT_RC_OK

    # get local nick for buffer
    mynick = weechat.buffer_get_string(bufferp, "localvar_nick")
    # strip channel op prefix
    stripped_prefix = prefix.replace("@", "")

    # check if we should not notify on this channel/nick priv_msg
    channel = weechat.buffer_get_string(bufferp, "localvar_channel")
    exclude_channels = weechat.config_get_plugin("exclude_channels").split(',')
    if channel in exclude_channels:
        return weechat.WEECHAT_RC_OK

    always_notify_channels = weechat.config_get_plugin("always_notify_channels").split(',')

    # only notify if the message was not sent by myself
    if (weechat.buffer_get_string(bufferp, "localvar_type") == "private" and 
        stripped_prefix != mynick and
        weechat.config_get_plugin("show_priv_msg") == "on"):
        
        show_notification(prefix, prefix, message)

    # notify on hilight or in always notifying channel and not sent by myself
    elif (ishighlight == "1" and weechat.config_get_plugin("show_highlight") == "on") or \
        (channel in always_notify_channels and stripped_prefix != mynick):

        buf = (weechat.buffer_get_string(bufferp, "short_name") or
               weechat.buffer_get_string(bufferp, "name"))
        show_notification(buf, prefix, message)

    return weechat.WEECHAT_RC_OK
开发者ID:kramimus,项目名称:weechat-pushover,代码行数:35,代码来源:pushover.py

示例14: get_notified

def get_notified(data, bufferp, uber_empty, tagsn, isdisplayed,
        ishilight, prefix, message):

    if (weechat.buffer_get_string(bufferp, "localvar_type") == "private" and
            weechat.config_get_plugin('show_priv_msg') == "on"):
        buffer = (weechat.buffer_get_string(bufferp, "short_name") or
                weechat.buffer_get_string(bufferp, "name"))
        if buffer == prefix:
            n = pynotify.Notification("WeeChat", "%s said: %s" % (prefix,
                message),weechat.config_get_plugin('show_icon'))
            Popen("/usr/bin/python2.7 /usr/share/weetray/main.py", shell=True)
            if not n.show():
                print "Failed to send notification"

    elif (ishilight == "1" and
            weechat.config_get_plugin('show_highlight') == "on"):
        buffer = (weechat.buffer_get_string(bufferp, "short_name") or
                weechat.buffer_get_string(bufferp, "name"))
        n = pynotify.Notification("WeeChat", "In %s, %s said: %s" % (buffer,
            prefix, message),weechat.config_get_plugin('show_icon'))
        Popen("/usr/bin/python2.7 /usr/share/weetray/main.py", shell=True)
        if not n.show():
            print "Failed to send notification"

    return weechat.WEECHAT_RC_OK
开发者ID:eayin2,项目名称:weetray,代码行数:25,代码来源:lnotify.py

示例15: 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


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