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


Python weechat.config_string_to_boolean函数代码示例

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


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

示例1: screen_away_timer_cb

def screen_away_timer_cb(buffer, args):
    '''Check if screen is attached, update awayness'''

    global AWAY, SOCK, CONNECTED_RELAY

    def mosh_state():
        try:
            with open(MOSH_STATE) as f:
                return f.read()
        except IOError:
            return

    set_away = w.config_string_to_boolean(w.config_get_plugin('set_away'))
    check_relays = not w.config_string_to_boolean(w.config_get_plugin('ignore_relays'))
    suffix = w.config_get_plugin('away_suffix')
    attached = os.access(SOCK, os.X_OK) # X bit indicates attached
    mosh_state = mosh_state()
    if attached and mosh_state is not None:
        attached = mosh_state == 'connected'

    # Check wether a client is connected on relay or not
    CONNECTED_RELAY = False
    if check_relays:
        infolist = w.infolist_get('relay', '', '')
        if infolist:
            while w.infolist_next(infolist):
                status = w.infolist_string(infolist, 'status_string')
                if status == 'connected':
                    CONNECTED_RELAY = True
                    break
            w.infolist_free(infolist)

    if (attached and AWAY) or (check_relays and CONNECTED_RELAY and not attached and AWAY):
        w.prnt('', '%s: Screen attached. Clearing away status' % SCRIPT_NAME)
        for server, nick in get_servers():
            if set_away:
                w.command(server,  "/away")
            if suffix and nick.endswith(suffix):
                nick = nick[:-len(suffix)]
                w.command(server,  "/nick %s" % nick)
        AWAY = False
        for cmd in w.config_get_plugin("command_on_attach").split(";"):
            w.command("", cmd)

    elif not attached and not AWAY:
        if not CONNECTED_RELAY:
            w.prnt('', '%s: Screen detached. Setting away status' % SCRIPT_NAME)
            for server, nick in get_servers():
                if suffix and not nick.endswith(suffix):
                    w.command(server, "/nick %s%s" % (nick, suffix));
                if set_away:
                    w.command(server, "/away %s %s" % (w.config_get_plugin('message'), time.strftime(w.config_get_plugin('time_format'))))
            AWAY = True
            for cmd in w.config_get_plugin("command_on_detach").split(";"):
                w.command("", cmd)

    return w.WEECHAT_RC_OK
开发者ID:tr3buchet,项目名称:weechat_scripts,代码行数:57,代码来源:screen_away_mosh.py

示例2: screen_away_timer_cb

def screen_away_timer_cb(buffer, args):
    '''Check if screen is attached and update awayness.'''
    global AWAY, SOCK, CONNECTED_RELAY

    set_away = w.config_string_to_boolean(w.config_get_plugin('set_away'))
    check_relays = not w.config_string_to_boolean(
        w.config_get_plugin('ignore_relays'))
    suffix = w.config_get_plugin('away_suffix')
    attached = os.access(SOCK, os.X_OK)  # X bit indicates attached.

    # Check wether a client is connected on relay or not.
    CONNECTED_RELAY = False
    if check_relays:
        infolist = w.infolist_get('relay', '', '')
        if infolist:
            while w.infolist_next(infolist):
                status = w.infolist_string(infolist, 'status_string')
                if status == 'connected':
                    CONNECTED_RELAY = True
                    break
            w.infolist_free(infolist)

    if ((attached and AWAY) or
            (check_relays and CONNECTED_RELAY and not attached and AWAY)):
        if not w.config_string_to_boolean(w.config_get_plugin('no_output')):
            w.prnt('', '{}: Screen attached. Clearing away status'.format(
                SCRIPT_NAME))
        for server, nick in get_servers():
            if set_away:
                w.command(server, '/away')
            if suffix and nick.endswith(suffix):
                nick = nick[:-len(suffix)]
                w.command(server, '/nick {}'.format(nick))
        AWAY = False
        if w.config_get_plugin('command_on_attach'):
            for cmd in w.config_get_plugin('command_on_attach').split(';'):
                w.command('', cmd)

    elif not attached and not AWAY:
        if not CONNECTED_RELAY:
            if (not w.config_string_to_boolean(
                    w.config_get_plugin('no_output'))):
                w.prnt('', '{}: Screen detached. Setting away status'.format(
                    SCRIPT_NAME))
            for server, nick in get_servers():
                if suffix and not nick.endswith(suffix):
                    w.command(server, '/nick {}{}'.format(nick, suffix))
                if set_away:
                    w.command(server, '/away {} {}'.format(
                        w.config_get_plugin('message'),
                        time.strftime(w.config_get_plugin('time_format'))))
            AWAY = True
            if w.config_get_plugin('command_on_detach'):
                for cmd in w.config_get_plugin('command_on_detach').split(';'):
                    w.command('', cmd)

    return w.WEECHAT_RC_OK
开发者ID:MatthewCox,项目名称:dotfiles,代码行数:57,代码来源:screen_away.py

示例3: priv_msg_cb

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

    if not w.config_string_to_boolean(w.config_get_plugin('activated')):
        _debug('Plugin not activated. Not sending.')
        return w.WEECHAT_RC_OK

    if (w.config_string_to_boolean(w.config_get_plugin('smart_notification')) and
            bufferp == w.current_buffer()):
        _debug('"smart_notification" option set but you are on this buffer already. Not sending.')
        return w.WEECHAT_RC_OK

    if (w.config_string_to_boolean(w.config_get_plugin('only_away')) and not
            w.buffer_get_string(bufferp, 'localvar_away')):
        _debug('"only_away" option set but you are not away. Not sending.')
        return w.WEECHAT_RC_OK

    ret = None

    notif_body = u"%s%s%s%s" % (
            w.config_get_plugin('nick_separator_left').decode('utf-8'),
            prefix.decode('utf-8'),
            w.config_get_plugin('nick_separator_right').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 and
            w.config_string_to_boolean(w.config_get_plugin('notify_priv_msg'))):
        ret = send_notification("IRC private message",
        notif_body, int(w.config_get_plugin("emergency_priv_msg")))
        _debug("Message sent: %s. Return: %s." % (notif_body, ret))


    # Highlight (your nick is quoted)
    elif (ishilight == "1" and
            w.config_string_to_boolean(w.config_get_plugin('notify_hilights'))):
        bufname = (w.buffer_get_string(bufferp, "short_name") or
                w.buffer_get_string(bufferp, "name"))
        ret = send_notification(bufname.decode('utf-8'), notif_body,
                int(w.config_get_plugin("emergency_hilights")))
        _debug("Message sent: %s. Return: %s." % (notif_body, ret))

    if ret is not None:
        _debug(str(ret))

    return w.WEECHAT_RC_OK
开发者ID:ainmosni,项目名称:weechat_plugins_nma,代码行数:51,代码来源:nma.py

示例4: run_notify

def run_notify(mtype,urgency,icon,time,nick,chan,message):
    data  = str(mtype) + "\n"
    data += str(urgency) + "\n"
    data += str(icon) + "\n"
    data += str(time) + "\n"    #time to display TODO
    data += str(nick) + "\n"
    data += str(chan) + "\n"
    data += str(message)

    transport = w.config_get_plugin('transport')
    command = w.config_get_plugin('notify_command'),
    host = w.config_get_plugin('host')

    try:
        if command:
            p = subprocess.Popen(command, shell=True,
                                 stdin=subprocess.PIPE,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.STDOUT)
            (output, _) = p.communicate(data)
            if p.returncode != 0:
                raise Exception("Notify command failed with return code " + str(p.returncode) + "\r\n" + output)
        else:
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.connect((host, int(w.config_get_plugin('port'))))
            s.send(str(data))
            s.close()
    except Exception as e:
        if w.config_string_to_boolean(w.config_get_plugin("display_errors")):
            w.prnt("", "Could not send notification: %s" % str(e))
            w.prnt("", "To hide errors, run: /set plugins.var.python.remote-notify.display_errors off")
开发者ID:ObiWahn,项目名称:weechat-remote-notify,代码行数:31,代码来源:weechat-remote-notify.py

示例5: channel_block

def channel_block(server, channel):
    fail = None
    config_cycle = lambda opt: weechat.config_string_to_boolean(weechat.config_get_plugin("cycle_%s" % opt))

    channels = weechat.infolist_get("irc_channel", "", "%s,%s" % (server, channel))
    if weechat.infolist_next(channels):
        modes = weechat.infolist_string(channels, "modes")
        if " " in modes:
            modes, modes_args = modes.split(" ", 1)

        if not config_cycle("key") and weechat.infolist_string(channels, "key") != "":
            fail = "cycle_key"
        elif not config_cycle("invite") and "i" in modes:
            fail = "cycle_invite"
    elif not config_cycle("detach"):
        fail = "cycle_detach"

    weechat.infolist_free(channels)

    if fail:
        weechat.prnt("", "%s: won't automatically cycle %s.%s: %s" % (SCRIPT_NAME, server, channel, fail))
    else:
        servers[server]["channels"].append(channel)
        buffer = weechat.buffer_search("irc", server)
        weechat.command(buffer, "/part %s" % channel)
        weechat.command(buffer, "/nick %s" % servers[server]["nick"])
开发者ID:DarkDefender,项目名称:scripts,代码行数:26,代码来源:force_nick.py

示例6: conversation_cb

def conversation_cb(data, buffer, args):
    """
    Follows the reply trail until the original was found.
    NOTE: This might block for a while.
    """
    global twitter
    conversation = []
    reply_id = args
    # Loop as long as there was a reply_id.
    while reply_id:
        try:
            conversation.append(twitter.get_tweet(reply_id))
            reply_id = conversation[-1].in_reply_to_status_id
        except TwitterError as error:
            print_error(error)
            break
    if conversation:
        # Reverse the conversation to get the oldest first.
        conversation.reverse()
        # Now display the conversation.
        print_to_current("%s-------------------" % wc.color("magenta"))
        for tweet in conversation:
            nick_color = wc.info_get("irc_nick_color", tweet.screen_name)
            screen_name = nick_color + tweet.screen_name
            expand_urls = wc.config_string_to_boolean(wc.config_get_plugin("expand_urls"))
            text = tweet.txt_unescaped
            if expand_urls:
                text = tweet.txt
            output = "%s\t%s" % (screen_name, text)
            if tweet.is_retweet:
                output += " (RT by @%s)" % tweet.rtscreen_name
            output += "\n[#STATUSID: %s]" % tweet.id
            print_to_current(output)
        print_to_current("%s-------------------" % wc.color("magenta"))
    return wc.WEECHAT_RC_OK
开发者ID:ainmosni,项目名称:weetwit,代码行数:35,代码来源:weetwit.py

示例7: show_favorites_cb

def show_favorites_cb(data, buffer, args):
    """
    Show all the tweets that are favourited by the user.
    """
    global twitter
    try:
        favs = twitter.get_favorites()
    except TwitterError as error:
        print_error(error)
        return wc.WEECHAT_RC_OK
    if favs:
        print_to_current("%sFAVOURITES\t%s-------------------" %
                (wc.color("yellow"), wc.color("magenta")))
        for fav in favs:
            nick_color = wc.info_get("irc_nick_color", fav.screen_name)
            screen_name = nick_color + fav.screen_name
            expand_urls = wc.config_string_to_boolean(wc.config_get_plugin("expand_urls"))
            text = fav.text_unescaped
            if expand_urls:
                text = fav.text
            output = "%s\t%s" % (screen_name, text)
            if fav.is_retweet:
                output += " (RT by @%s)" % fav.rtscreen_name
            output += "\n[#STATUSID: %s]" % fav.id
            print_to_current(output)
        print_to_current("%s-------------------" % wc.color("magenta"))
    return wc.WEECHAT_RC_OK
开发者ID:ainmosni,项目名称:weetwit,代码行数:27,代码来源:weetwit.py

示例8: screen_away_timer_cb

def screen_away_timer_cb(buffer, args):
    """Check if screen is attached, update awayness"""

    global AWAY, SOCK, CONNECTED_RELAY

    set_away = w.config_string_to_boolean(w.config_get_plugin("set_away"))
    check_relays = not w.config_string_to_boolean(w.config_get_plugin("ignore_relays"))
    suffix = w.config_get_plugin("away_suffix")
    attached = os.access(SOCK, os.X_OK)  # X bit indicates attached

    # Check wether a client is connected on relay or not
    CONNECTED_RELAY = False
    if check_relays:
        infolist = w.infolist_get("relay", "", "")
        if infolist:
            while w.infolist_next(infolist):
                status = w.infolist_string(infolist, "status_string")
                if status == "connected":
                    CONNECTED_RELAY = True
                    break
            w.infolist_free(infolist)

    if (attached and AWAY) or (check_relays and CONNECTED_RELAY and not attached and AWAY):
        w.prnt("", "%s: Screen attached. Clearing away status" % SCRIPT_NAME)
        for server, nick in get_servers():
            if set_away:
                w.command(server, "/away")
            if suffix and nick.endswith(suffix):
                nick = nick[: -len(suffix)]
                w.command(server, "/nick %s" % nick)
        AWAY = False
        for cmd in w.config_get_plugin("command_on_attach").split(";"):
            w.command("", cmd)

    elif not attached and not AWAY:
        if not CONNECTED_RELAY:
            w.prnt("", "%s: Screen detached. Setting away status" % SCRIPT_NAME)
            for server, nick in get_servers():
                if suffix and not nick.endswith(suffix):
                    w.command(server, "/nick %s%s" % (nick, suffix))
                if set_away:
                    w.command(server, "/away %s" % w.config_get_plugin("message"))
            AWAY = True
            for cmd in w.config_get_plugin("command_on_detach").split(";"):
                w.command("", cmd)

    return w.WEECHAT_RC_OK
开发者ID:x-itec,项目名称:dotfiles-6,代码行数:47,代码来源:screen_away.py

示例9: send_notification

def send_notification(chan, message, priority):
    global p
    if w.config_string_to_boolean(w.config_get_plugin('use_push_if_possible')):
        # So far, the length is hardcoded in pynma.py...
        if len(chan) + len(message) < 1021:
            chan = "%s - %s" % (chan, message)
            message = ""
    return p.push("[IRC]", chan, message, '', priority, batch_mode=False)
开发者ID:ainmosni,项目名称:weechat_plugins_nma,代码行数:8,代码来源:nma.py

示例10: nma_cmd_cb

def nma_cmd_cb(data, buffer, args):
    bool_arg = w.config_string_to_boolean(args)
    status = "%sactivated" % ("" if bool_arg else "de")
    ret = w.config_set_plugin('activated', args)
    if ret == w.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
        w.prnt("", "...NMA was already %s" % status)
    elif ret == w.WEECHAT_CONFIG_OPTION_SET_ERROR:
        w.prnt("", "Error while setting the config.")
        return w.WEECHAT_RC_ERROR
    else:
        w.prnt("", "Notify My Android notifications %s." % status)
    return w.WEECHAT_RC_OK
开发者ID:ainmosni,项目名称:weechat_plugins_nma,代码行数:12,代码来源:nma.py

示例11: config_setup

def config_setup():
    for option,value in OPTIONS.items():
        weechat.config_set_desc_plugin(option, '%s' % value[1])
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, value[0])
            OPTIONS[option] = value[0]
        else:
            if option == 'prefix_nicks' or option == 'debug':
                OPTIONS[option] = weechat.config_string_to_boolean(
                    weechat.config_get_plugin(option))
            else:
                OPTIONS[option] = weechat.config_get_plugin(option)
开发者ID:alyptik,项目名称:scripts,代码行数:12,代码来源:twitch.py

示例12: hook_modifiers

def hook_modifiers():
	"""Update modifier hooks to match settings."""

	# remove existing modifier hooks
	global hooks
	for hook in hooks:
		weechat.unhook(hook)
	hooks = []

	# add hooks according to settings

	input_option = weechat.config_get_plugin("input")
	if weechat.config_string_to_boolean(input_option):
		hooks.append(weechat.hook_modifier("input_text_display", "modifier_cb", ""))

	send_option = weechat.config_get_plugin("send")
	if weechat.config_string_to_boolean(send_option):
		hooks.append(weechat.hook_modifier("input_text_for_buffer", "modifier_cb", ""))

	buffer_option = weechat.config_get_plugin("buffer")
	if weechat.config_string_to_boolean(buffer_option):
		hooks.append(weechat.hook_modifier("weechat_print", "modifier_cb", ""))
开发者ID:DarkDefender,项目名称:scripts,代码行数:22,代码来源:latex_unicode.py

示例13: join

def join(server, channel):
    key = None

    if w.config_string_to_boolean(w.config_get_plugin('autojoin_key')):
        autojoin = w.config_string(w.config_get('irc.server.%s.autojoin' % server)).split(' ', 1)

        if len(autojoin) > 1: # any keys specified
            autojoin_keys = dict(zip(autojoin[0].split(','), autojoin[1].split(',')))
            key = autojoin_keys.get(channel) # defaults to None when not set

    if key:
        w.command('', '/quote -server %s JOIN %s %s' % (server, channel, key))
    else:
        w.command('', '/quote -server %s JOIN %s' % (server, channel))
开发者ID:oakkitten,项目名称:scripts,代码行数:14,代码来源:autojoin_on_invite.py

示例14: tweet_share_cb

def tweet_share_cb(data, buffer, args):
    """Share tweet with current IRC channel."""
    global twitter
    try:
        tweet = twitter.get_tweet(args)
    except TwitterError as error:
        print_error(error)
        return wc.WEECHAT_RC_OK
    expand_urls = wc.config_string_to_boolean(wc.config_get_plugin("expand_urls"))
    text = tweet.txt_unescaped
    if expand_urls:
        text = tweet.txt
    message = '<@%s> %s [%s]' % \
        (tweet.screen_name, text, tweet.url)
    wc.command(wc.current_buffer(), '/say %s' % message)
    return wc.WEECHAT_RC_OK
开发者ID:ainmosni,项目名称:weetwit,代码行数:16,代码来源:weetwit.py

示例15: send_notification

def send_notification(chan, message, priority):
    p = nma_get_instance()
    if not(p):
        w.prnt("", "[nma] - Problem with NMA instance. Not sending notification")
        return None

    _debug("Sending notif with chan '%s', message '%s' and priority '%s'." %
            (chan, message, priority))
    if w.config_string_to_boolean(w.config_get_plugin('use_push_if_possible')):
        # So far, the length is hardcoded in pynma.py...
        if len(chan) + len(message) < 1021:
            chan = "%s - %s" % (chan, message)
            message = ""
    ret = p.push("[IRC]", chan, message, '', priority, batch_mode=False)
    if ret is not None:
        _debug("Message sent: %s. Return: %s." % (message, ret))
开发者ID:DarkDefender,项目名称:scripts,代码行数:16,代码来源:nma.py


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