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


Python weechat.hook_completion函数代码示例

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


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

示例1: main

def main():
    weechat.hook_modifier("irc_in_notice", "modifier_cb", "")
    weechat.hook_completion("bitlbee", "bitlbee completion",
                            "bitlbee_completion", "")

    weechat.hook_print('', 'irc_332', '', 1, 'print_332', '')
    weechat.hook_print('', 'irc_topic', '', 1, 'print_332', '')
    find_buffer()
开发者ID:DarkDefender,项目名称:scripts,代码行数:8,代码来源:bitlbee_completion.py

示例2: main

def main():
    """ Entry point, initializes everything  """

    weechat.register(
        SCRIPT_NAME,
        SCRIPT_AUTHOR,
        SCRIPT_VERSION,
        SCRIPT_LICENSE,
        SCRIPT_DESCRIPTION,
        "", # Shutdown callback function
        "", # Charset (blank for utf-8)
    )

    # Default values for settings
    default_settings = {
        'dbfile': os.path.join(
            weechat.info_get("weechat_dir", ""), "emojis-db.dat")
    }

    # Apply default configuration values if anything is unset
    for option, default in default_settings.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, default)

    # Hook callbacks
    weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*",
        "configuration_cb", "")
    weechat.hook_command_run("/input return", "transform_cb", "")
    weechat.hook_command_run("/input complete*", "complete_cb", "")
    #weechat.hook_modifier("input_text_display", "collapse_cb", "")

    # Command callbacks
    weechat.hook_command(  # command name
                           SCRIPT_NAME,
                           # description
                           " display :common_name: with its emoji equivalent",
                           # arguments
                           "reload"
                           " || add <name> <emoji>"
                           " || show <emoji>",
                           # description of arguments
                           " name: emoji name, sans colons\n"
                           "emoji: text that replaces :name:\n",
                           # completions
                           "reload || add || show %(emoji_name)", "emojis_cb", "")
    weechat.hook_completion("emoji_name", "Emoji name", "emoji_name_completion_cb", "")

    dbfile = weechat.config_get_plugin("dbfile")

    weechat.prnt("", "%s: Loading emojis from %s" % (SCRIPT_NAME, dbfile))

    try:
        load_emojis(dbfile)
    except IOError as e:
        weechat.prnt("",
            "%s%s: Database file %s is missing or inaccessible." \
                    % (weechat.prefix("error"), SCRIPT_NAME, dbfile))
        raise e # TODO: handle this better instead of brutally aborting
开发者ID:flowbish,项目名称:weechat-emojis,代码行数:58,代码来源:emojis.py

示例3: main

def main():
    """Main entry"""

    weechat.register(NAME, AUTHOR, VERSION, LICENSE, DESC, '', '')
    weechat.hook_completion('replacer_plugin', 'Try to match last word with '
                            'those in replacement map keys, and replace it '
                            'with value.', 'replace_cb', '')
    weechat.hook_completion('completion_cb', 'Complete replacement map keys',
                            'completion_cb', '')

    weechat.hook_command(COMMAND, DESC, "[add <word> <text>|del <word>]",
                         __doc__ % {"command": COMMAND},
                         'add|del %(completion_cb)', 'replace_cmd', '')
开发者ID:gryf,项目名称:weechat-replacer,代码行数:13,代码来源:replacer.py

示例4: main

def main():
    at_config('load')
    # hook our config
    weechat.hook_config(STRIP_VAR+'*','at_config','')
    # hook the nick complete
    weechat.hook_command_run('/input complete_next', 'at_completion', '')
    # hook the /atcomplete
    weechat.hook_command('atcomplete','manage @nick completion plugin',
        '[enable|disable|toggle] '
        ' | [servers [list | add name | del name]]'
        ' | [buffers [list | add name | del name]]',
        'args desc',
        'status %-'
        ' || enable %-'
        ' || disable %-'
        ' || toggle %-'
        ' || server list|add|del %(buffers_names)'
        ' || buffer list|add|del %(buffers_names)'
        ,
        'at_control','')
    # hook the completetion for /atcomplete
    weechat.hook_completion('plugin_at_completion','@nick completion','at_complete','')
开发者ID:WarheadsSE,项目名称:weechat-atcompletion,代码行数:22,代码来源:at_completion.py

示例5: jmh_hook_commands_and_completions

def jmh_hook_commands_and_completions():
    """ Hook commands and completions. """
    # prototype: hook = weechat.hook_command(command, description, args, args_description,
    #   completion, callback, callback_data)
    weechat.hook_command(SCRIPT_COMMAND, SCRIPT_DESC,
        "[ on | off | log | verbose [on|off]",
        "     on: enable jabber_message_handler\n"
        "    off: disable jabber_message_handler\n"
        "    log: name of events log file\n"
        "verbose: toggle verbose on/off\n"
        "\n"
        "Without an argument, current settings are displayed.\n"
        "\n"
        "Examples:\n"
        "List settings: /jabber_message_handler\n"
        "      Enable : /jabber_message_handler on\n"
        "     Disable : /jabber_message_handler off\n"
        "      Set log: /jabber_message_handler log /path/to/events.log\n"
        "   Verbose on: /jabber_message_handler verbose on\n"
        "  Verbose off: /jabber_message_handler verbose off\n",
        "log "
        " || off"
        " || on"
        " || verbose on|off",
        "jmh_cmd", "")

    weechat.hook_command('clr', 'Clear jabber events log.',
            '', "Usage: /clr", '', 'jmh_cmd_clr', '');

    weechat.hook_command('jabber_echo_message',
            'Echo message in jabber buffer.',
            '', "Usage: /jabber_echo_message server message",
            '%(jabber_servers)', 'jmh_cmd_jabber_echo_message', '');

    weechat.hook_completion("jabber_servers", "list of jabber servers",
                            "jmh_completion_servers", "")
开发者ID:zsw,项目名称:dotfiles,代码行数:36,代码来源:jabber_message_handler.py

示例6: main

def main():
    if not weechat.register('hipchat', 'Joakim Recht <[email protected]>', '1.0',
                            'MIT', 'Hipchat utilities',
                            '', ''):
        return

    rooms_set_default_settings()
    rooms_reset_stored_sort_order()
    get_token()

    weechat.hook_command(
        'hipchat', 'Hipchat utilities',
        '[rooms | autojoin | whois <user> | fullnames | nicks [<pattern>]]',
        'rooms: List rooms\nautojoin: List autojoin rooms\nwhois <user>: Get information '
        'about a specific user - either @mention or email\nfullnames: Force populate full '
        'names in nicklists in all channels\nnicks <pattern>: List users, optionally by pattern. '
        'Use * in pattern as wildcard match.\n',
        'rooms|autojoin|whois|fullnames|nicks', 'hipchat_cmd', '')
    weechat.hook_completion('hipchat_mentions', 'Mentions', 'complete_mention', '')

    if weechat.config_get_plugin('enable_fullnames') == 'on':
        nicklist_download()
    weechat.hook_signal('nicklist_nick_added', 'update_fullname_join', '')
    weechat.hook_signal('hipchat_nicks_downloaded', 'show_nicks_cb', '')
开发者ID:recht,项目名称:weechat-plugins,代码行数:24,代码来源:hipchat.py

示例7: test_hooks

def test_hooks():
    """Test function hook_command."""
    # hook_completion / hook_completion_args / and hook_command
    hook_cmplt = weechat.hook_completion('SCRIPT_NAME', 'description',
                                         'completion_cb', 'completion_data')
    hook_cmd = weechat.hook_command('cmd' + 'SCRIPT_NAME', 'description',
                                    'arguments', 'description arguments',
                                    '%(' + 'SCRIPT_NAME' + ')',
                                    'command_cb', 'command_data')
    weechat.command('', '/input insert /cmd' + 'SCRIPT_NAME' + ' w')
    weechat.command('', '/input complete_next')
    # hook_command_run
    hook_cmd_run = weechat.hook_command_run('/cmd' + 'SCRIPT_NAME' + '*',
                                            'command_run_cb', 'command_run_data')
    weechat.command('', '/input return')
    weechat.unhook(hook_cmd_run)
    weechat.unhook(hook_cmd)
    weechat.unhook(hook_cmplt)
开发者ID:weechat,项目名称:weechat,代码行数:18,代码来源:testapi.py

示例8: len

    elif len(args) == 2:
        msg = u": ".join((args[1], ftext))
    else:
        msg = ftext
    weechat.command(buffer, msg.encode("utf-8"))
    return weechat.WEECHAT_RC_OK


def command_factreload(data, buffer, args):
    """Reload factoids."""
    return load_factoids()


def kwfactoids_completion_cb(data, completion_item, buffer, completion):
    """Add completion for factoids."""
    for factoid in FACTOIDS:
        weechat.hook_completion_list_add(completion, factoid, 0, weechat.WEECHAT_LIST_POS_SORT)
    return weechat.WEECHAT_RC_OK

load_factoids()

weechat.hook_command("factoid", "Send a factoid to channel.", "[factoid] [user]",
                     "factoid is name of factoid, user (optional) is user to direct the factoid at.",
                     "%(kwfactoidsc) %(nicks)", "command_factoid", "")
weechat.hook_command("f", "Send a factoid to channel.", "[factoid] [user]",
                     "factoid is name of factoid, user (optional) is user to direct the factoid at.",
                     "%(kwfactoidsc) %(nicks)", "command_factoid", "")
weechat.hook_command("factreload", "Reload factoids.", "", "", "", "command_factreload", "")
weechat.hook_completion("kwfactoidsc", "Factoid completion", "kwfactoids_completion_cb", "")
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")
开发者ID:Kwpolska,项目名称:scripts,代码行数:30,代码来源:kwfactoids.py

示例9: init_options

        weechat.hook_command(SCRIPT_NAME,SCRIPT_DESC,
                             'add <server> [<channel1>[ <channel2>...]] | [-key <channelkey> [<channelkey>...]] ||'
                             'del <server> [<channel1>[ <channel2>...]]',
                             'add <server> <channel>: add channel to irc.server.<servername>.autojoin\n'
                             '     -key <channelkey>: name of channelkey\n'
                             'del <server> <channel>: del channel from irc.server.<servername>.autojoin\n'
                             '\n'
                             'Examples:\n'
                             ' add current channel to corresponding server option:\n'
                             '  /' + SCRIPT_NAME + ' add\n'
                             ' add all channels from all server to corresponding server option:\n'
                             '  /allchan /' + SCRIPT_NAME + ' add\n'
                             ' add channel #weechat to autojoin option on server freenode:\n'
                             '  /' + SCRIPT_NAME + ' add freenode #weechat\n'
                             ' add channel #weechat and #weechat-de to autojoin option on server freenode, with channel key for channel #weechat:\n'
                             '  /' + SCRIPT_NAME + ' add freenode #weechat #weechat-de -key my_channel_key\n'
                             ' del channels #weechat and #weechat-de from autojoin option on server freenode:\n'
                             '  /' + SCRIPT_NAME + ' del freenode #weechat #weechat-de',
                             'add %(irc_servers) %(irc_server_channels)|%*||'
                             'del %(irc_servers) %(plugin_autojoinem)|%*',
                             'add_autojoin_cmd_cb', '')

        init_options()
        weechat.hook_completion('plugin_autojoinem', 'autojoin_completion', 'autojoinem_completion_cb', '')
        weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '')

#        if int(version) >= 0x00030600:
#        else:
#            weechat.prnt("","%s%s %s" % (weechat.prefix("error"),SCRIPT_NAME,": needs version 0.3.6 or higher"))
#            weechat.command("","/wait 1ms /python unload %s" % SCRIPT_NAME)
开发者ID:DarkDefender,项目名称:scripts,代码行数:30,代码来源:autojoinem.py

示例10: replace_emoji

    return weechat.WEECHAT_RC_OK


def replace_emoji(match):
    text = match.group(0)
    codepoint = EMOJI.get(text[1:-1])
    if codepoint:
        raw = "\\U%08x" % int(codepoint, 16)
        return raw.decode("unicode-escape").encode("utf-8")
    return text


if __name__ == "__main__" and import_ok:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        weechat.hook_modifier("weechat_print", "interpolate_emoji_cb", "")
        weechat.hook_completion("emoji_names", "complete colon :emoji:", "emoji_completion_cb", "")


# Emoji mapping is modified from
# https://github.com/iamcal/emoji-data/blob/master/emoji.json
#
# The MIT License (MIT)
#
# Copyright (c) 2013 Cal Henderson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
开发者ID:kattrali,项目名称:weemoji,代码行数:31,代码来源:weemoji.py

示例11: docgen_completion_cb

                               num_files_updated['hdata'],
                               num_files_updated['completions']))
    weechat.prnt('',
                 'docgen: total: {0} files, {1} updated'
                 ''.format(num_files['total2'], num_files_updated['total2']))
    return weechat.WEECHAT_RC_OK


def docgen_completion_cb(data, completion_item, buf, completion):
    """Callback for completion."""
    for locale in LOCALE_LIST:
        weechat.hook_completion_list_add(completion, locale, 0,
                                         weechat.WEECHAT_LIST_POS_SORT)
    return weechat.WEECHAT_RC_OK


if __name__ == '__main__' and IMPORT_OK:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENSE, SCRIPT_DESC, '', ''):
        weechat.hook_command(SCRIPT_COMMAND,
                             'Documentation generator.',
                             '[locales]',
                             'locales: list of locales to build (by default '
                             'build all locales)',
                             '%(docgen_locales)|%*',
                             'docgen_cmd_cb', '')
        weechat.hook_completion('docgen_locales', 'locales for docgen',
                                'docgen_completion_cb', '')
        if not weechat.config_is_set_plugin('path'):
            weechat.config_set_plugin('path', DEFAULT_PATH)
开发者ID:Georgiy-Tugai,项目名称:weechat,代码行数:30,代码来源:docgen.py

示例12: init_options

            "add <server> [<channel1>[ <channel2>...]] | [-key <channelkey> [<channelkey>...]] ||"
            "del <server> [<channel1>[ <channel2>...]]",
            "add <server> <channel>: add channel to irc.server.<servername>.autojoin\n"
            "     -key <channelkey>: name of channelkey\n"
            "del <server> <channel>: del channel from irc.server.<servername>.autojoin\n"
            "\n"
            "Examples:\n"
            " add current channel to corresponding server option:\n"
            "  /" + SCRIPT_NAME + " add\n"
            " add all channels from all server to corresponding server option:\n"
            "  /allchan /" + SCRIPT_NAME + " add\n"
            " add channel #weechat to autojoin option on server freenode:\n"
            "  /" + SCRIPT_NAME + " add freenode #weechat\n"
            " add channel #weechat and #weechat-de to autojoin option on server freenode, with channel key for channel #weechat:\n"
            "  /" + SCRIPT_NAME + " add freenode #weechat #weechat-de -key my_channel_key\n"
            " del channels #weechat and #weechat-de from autojoin option on server freenode:\n"
            "  /" + SCRIPT_NAME + " del freenode #weechat #weechat-de",
            "add %(irc_servers) %(irc_server_channels)|%*||" "del %(irc_servers) %(plugin_autojoinem)|%*",
            "add_autojoin_cmd_cb",
            "",
        )

        init_options()
        weechat.hook_completion("plugin_autojoinem", "autojoin_completion", "autojoinem_completion_cb", "")
        weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "toggle_refresh", "")

#        if int(version) >= 0x00030600:
#        else:
#            weechat.prnt("","%s%s %s" % (weechat.prefix("error"),SCRIPT_NAME,": needs version 0.3.6 or higher"))
#            weechat.command("","/wait 1ms /python unload %s" % SCRIPT_NAME)
开发者ID:weechatter,项目名称:weechat-scripts,代码行数:30,代码来源:autojoinem.py

示例13: cmd_cb

def cmd_cb(data, buffer, args):
    args = args.split()
    if not args:
        return weechat.WEECHAT_RC_ERROR
    changes = get_config_json('changes')
    if args[0] == 'set':
        changes[args[1]] = args[2]
        set_config_json('changes', changes)
        weechat.prnt('', 'replacement for %s set' % args[1])
    elif args[0] == 'unset':
        del changes[args[1]]
    elif args[0] == 'list':
        weechat.prnt('', '%d replacements set:' % len(changes))
        for old, new in changes.items():
            weechat.prnt('', "  %s    %s" % (old, new))
    else:
        weechat.prnt('', 'Invalid subcommand: %s' % args[0])
        return weechat.WEECHAT_RC_ERROR
    return weechat.WEECHAT_RC_OK

weechat.hook_modifier('irc_in_privmsg', 'change_nick', '')
weechat.hook_command('nickreplacer', "Set replacement for nick",
                     '[list] | [set old new] | [unset old]',
                     'Use any subcommand',
                     'set old new'
                     'unset old',
                     'cmd_cb', '')
weechat.hook_completion('replacednicks', "Words in completion list.",
                        'complete', '')
开发者ID:boyska,项目名称:weechat-nickreplacer,代码行数:29,代码来源:nickreplacer.py

示例14:

                "highlight_words_add weechat\n"
                "  disable highlights from nick \"mike\" on freenode server, "
                "channel #weechat (requires WeeChat >= 0.3.4):\n"
                "    /" + SCRIPT_COMMAND + " add irc.freenode.#weechat "
                "hotlist_max_level_nicks_add mike:2\n"
                "  disable hotlist changes for nick \"bot\" on freenode "
                "server (all channels) (requires WeeChat >= 0.3.4):\n"
                "    /" + SCRIPT_COMMAND + " add irc.freenode.* "
                "hotlist_max_level_nicks_add bot:-1",
                "add %(buffers_plugins_names)|"
                "%(buffer_autoset_current_buffer) "
                "%(buffer_properties_set)"
                " || del %(buffer_autoset_options)",
                "bas_cmd", "")
            weechat.hook_completion(
                "buffer_autoset_current_buffer",
                "current buffer name for buffer_autoset",
                "bas_completion_current_buffer_cb", "")
            weechat.hook_completion(
                "buffer_autoset_options",
                "list of options for buffer_autoset",
                "bas_completion_options_cb", "")
            weechat.hook_signal("9000|buffer_opened",
                                "bas_signal_buffer_opened_cb", "")
            weechat.hook_config("%s.buffer.*" % CONFIG_FILE_NAME,
                                "bas_config_option_cb", "")

            # apply settings to all already opened buffers
            buffers = weechat.infolist_get("buffer", "", "")
            if buffers:
                while weechat.infolist_next(buffers):
                    buffer = weechat.infolist_pointer(buffers, "pointer")
开发者ID:AndyHoang,项目名称:dotfiles,代码行数:32,代码来源:buffer_autoset.py

示例15:

    weechat.hook_modifier('irc_in_privmsg', 'message_in_cb', '')
    weechat.hook_modifier('irc_out_privmsg', 'message_out_cb', '')

    weechat.hook_command(
        SCRIPT_NAME, SCRIPT_HELP,
        'start [NICK SERVER] || '
        'finish [NICK SERVER] || '
        'smp ask NICK SERVER SECRET [QUESTION] || '
        'smp respond NICK SERVER SECRET || '
        'trust [NICK SERVER] || '
        'policy [POLICY on|off]',
        '',
        'start %(nick) %(irc_servers) %-||'
        'finish %(nick) %(irc_servers) %-||'
        'smp ask|respond %(nick) %(irc_servers) %-||'
        'trust %(nick) %(irc_servers) %-||'
        'policy %(otr_policy) on|off %-||',
        'command_cb',
        '')

    weechat.hook_completion(
        'otr_policy', 'OTR policies', 'policy_completion_cb', '')

    weechat.hook_config('logger.level.irc.*', 'logger_level_update_cb', '')

    weechat.hook_signal('buffer_switch', 'buffer_switch_cb', '')

    OTR_STATUSBAR = weechat.bar_item_new(SCRIPT_NAME, 'otr_statusbar_cb', '')
    weechat.bar_item_update(SCRIPT_NAME)
开发者ID:frumiousbandersnatch,项目名称:weechat-scripts,代码行数:29,代码来源:otr.py


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