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


Python weechat.register函数代码示例

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


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

示例1: main

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

    # Setup the translation table, mapping latin characters to their Unicode
    #  fullwidth equivalents.
    global FW_TABLE
    FW_TABLE = dict(zip(range(0x21, 0x7F),
                        range(0xFF01, 0xFF5F)))
    # Handle space specially.
    FW_TABLE[0x20] = 0x3000

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

    # Command callbacks
    weechat.hook_command(  # command name
                           "fw",
                           # description
                           "Translates latin characters to their fullwidth equivalents.",
                           # arguments
                           "text",
                           # description of arguments
                           " text: text to be full-width'd",
                           # completions
                           "",
                           "fw_cb", "")
开发者ID:flowbish,项目名称:weechat-fullwidth,代码行数:33,代码来源:fullwidth.py

示例2: Register

def Register():
    weechat.register(TRIV['register']['script_name'],
                     TRIV['register']['author'],
                     TRIV['register']['version'],
                     TRIV['register']['license'],
                     TRIV['register']['description'],
                     TRIV['register']['shutdown_function'],
                     TRIV['register']['charset'])
开发者ID:manuelalcocer,项目名称:trivial,代码行数:8,代码来源:trivial.py

示例3: register

def register():
    weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
        SCRIPT_LICENSE, SCRIPT_DESC, '', '')

    weechat.hook_print('', 'irc_332', '', 1, 'print_332', '')
    weechat.hook_print('', 'irc_topic', '', 1, 'print_topic', '')
    weechat.hook_signal('*,irc_in2_332', 'irc_in2_332', '')
    weechat.hook_signal('*,irc_in2_topic', 'irc_in2_topic', '')
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:8,代码来源:topicdiff.py

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

示例5: __init__

    def __init__(self):
        ''' Creates the script instance and add hook, unfortunately it is
        not possible to use mathods as callbacks.
        '''
        weechat.register("SystrayIcon",
                         "Ziviani",
                         "0.1",
                         "GPLv2",
                         "Systray icon for weechat.",
                         "_shutdown_plugin",
                         "")

        weechat.hook_print("", "irc_privmsg", "", 1, "_highlight_msg_cb", "")
开发者ID:jrziviani,项目名称:laboratory,代码行数:13,代码来源:blinkicon.py

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

示例7: 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", "")

    # Command callbacks
    weechat.hook_command(
        "reloademojis", "reload emojis from file",
        "", "", "", "reload_emojis_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:OliverUv,项目名称:weechat-emojis,代码行数:48,代码来源:emojis.py

示例8: main

def main():
    if not weechat.register("edit", "Keith Smiley", "1.0.0", "MIT",
                            "Open your $EDITOR to compose a message", "", ""):
        return weechat.WEECHAT_RC_ERROR

    weechat.hook_command("edit", "Open your $EDITOR to compose a message", "",
                         "", "", "edit", "")
开发者ID:keith,项目名称:edit-weechat,代码行数:7,代码来源:edit.py

示例9: go_main

def go_main():
    """Entry point."""
    if not weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                            SCRIPT_LICENSE, SCRIPT_DESC,
                            'go_unload_script', ''):
        return
    weechat.hook_command(
        SCRIPT_COMMAND,
        'Quick jump to buffers', '[term(s)]',
        'term(s): directly jump to buffer matching the provided term(s) single'
        'or space dilimited list (without argument, list is displayed)\n\n'
        'You can bind command to a key, for example:\n'
        '  /key bind meta-g /go\n\n'
        'You can use completion key (commonly Tab and shift-Tab) to select '
        'next/previous buffer in list.',
        '%(buffers_names)',
        'go_cmd', '')

    # set default settings
    version = weechat.info_get('version_number', '') or 0
    for option, value in SETTINGS.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, value[0])
        if int(version) >= 0x00030500:
            weechat.config_set_desc_plugin(
                option, '%s (default: "%s")' % (value[1], value[0]))
    weechat.hook_info('go_running',
                      'Return "1" if go is running, otherwise "0"',
                      '',
                      'go_info_running', '')
开发者ID:gilbertw1,项目名称:scripts,代码行数:30,代码来源:go.py

示例10: main

def main():
    if not weechat.register("giphy", "Keith Smiley", "1.0.0", "MIT",
                            "Insert a random giphy URL", "", ""):
        return weechat.WEECHAT_RC_ERROR

    weechat.hook_command("giphy", "Insert a random giphy URL", "",
                         "", "", "giphy", "")
开发者ID:keith,项目名称:giphy-weechat,代码行数:7,代码来源:giphy.py

示例11: main

def main():
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        version = int(weechat.info_get("version_number", "")) or 0

        # unset unused setting from older versions of script
        if weechat.config_is_set_plugin("display_unit"):
            weechat.prnt("", "Option plugins.var.python.bandwidth.display_unit no longer used, removing.")
            weechat.config_unset_plugin("display_unit")

        # set default settings
        for option in SCRIPT_SETTINGS.iterkeys():
            if not weechat.config_is_set_plugin(option):
                weechat.config_set_plugin(option, SCRIPT_SETTINGS[option][0])
            if version >= 0x00030500:
                weechat.config_set_desc_plugin(option, SCRIPT_SETTINGS[option][1])

        # ensure sane refresh_rate setting
        if int(weechat.config_get_plugin("refresh_rate")) < 1:
            weechat.prnt(
                "",
                "{}Invalid value for option plugins.var.python.bandwidth.refresh_rate, setting to default of {}".format(
                    weechat.prefix("error"), SCRIPT_SETTINGS["refresh_rate"][0]
                ),
            )
            weechat.config_set_plugin("refresh_rate", SCRIPT_SETTINGS["refresh_rate"][0])

        # create the bandwidth monitor bar item
        weechat.bar_item_new("bandwidth", "bandwidth_item_cb", "")
        # update it every plugins.var.python.bandwidth.refresh_rate seconds
        weechat.hook_timer(int(weechat.config_get_plugin("refresh_rate")) * 1000, 0, 0, "bandwidth_timer_cb", "")
开发者ID:Shrews,项目名称:scripts,代码行数:30,代码来源:bandwidth.py

示例12: main

def main():
    if not weechat.register("emote", "Keith Smiley", "1.0.0", "MIT",
                            "Paste awesome unicode!", "", ""):
        return weechat.WEECHAT_RC_ERROR

    weechat.hook_command("emote", "Paste awesome unicode!", "", "",
                         "|".join(mappings.keys()), "emote", "")
开发者ID:keith,项目名称:emote-weechat,代码行数:7,代码来源:emote.py

示例13: weechat_script

def weechat_script():
    settings = {"host": "localhost", "port": "4321", "icon": "utilities-terminal", "pm-icon": "emblem-favorite"}
    if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        for (kw, v) in settings.items():
            if not w.config_get_plugin(kw):
                w.config_set_plugin(kw, v)
        w.hook_print("", "notify_message", "", 1, "on_msg", "")
        w.hook_print("", "notify_private", "", 1, "on_msg", "private")
        w.hook_print("", "notify_highlight", "", 1, "on_msg", "")  # Not sure if this is needed
开发者ID:norrs,项目名称:weechat-plugins,代码行数:9,代码来源:pyrnotify.py

示例14: main

def main():
    if not weechat.register("imgur", "Keith Smiley", "1.0.0", "MIT",
                            "Upload an image to imgur", "", ""):
        return weechat.WEECHAT_RC_ERROR

    if not weechat.config_get_plugin(CLIENT_ID):
        weechat.config_set_plugin(CLIENT_ID, "Set imgur client ID")

    weechat.hook_command("imgur", "Pass the current buffer to urlview", "",
                         "", "filename", "imgur", "")
开发者ID:keith,项目名称:imgur-weechat,代码行数:10,代码来源:imgur.py

示例15: main

def main():
    if distutils.spawn.find_executable("urlview") is None:
        return weechat.WEECHAT_RC_ERROR

    if not weechat.register("urlview", "Keith Smiley", "1.0.2", "MIT",
                            "Use urlview on the current buffer", "", ""):
        return weechat.WEECHAT_RC_ERROR

    weechat.hook_command("urlview", "Pass the current buffer to urlview", "",
                         "", "", "urlview", "")
开发者ID:keith,项目名称:urlview-weechat,代码行数:10,代码来源:urlview.py


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