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


Python weechat.hook_signal函数代码示例

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


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

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

示例2: signal_irc_pv_opened

def signal_irc_pv_opened(data, signal, signal_data):
    global irc_pv_hook, irc_out_hook
    if weechat.buffer_get_string(signal_data, "plugin") == "irc":
        nick = weechat.buffer_get_string(signal_data, "localvar_channel")
        if weechat.info_get("irc_is_nick", nick) == "1":
            # query open, wait for a msg to come (query was open by user) or if we send a msg out
            # (query was open by us)
            unhook_all()
            server = weechat.buffer_get_string(signal_data, "localvar_server")
            irc_pv_hook = weechat.hook_signal("irc_pv", "signal_irc_pv", "%s,%s" % (signal_data, nick))
            irc_out_hook = weechat.hook_signal(server + ",irc_out_PRIVMSG", "signal_irc_out", "")
    return weechat.WEECHAT_RC_OK
开发者ID:sitaktif,项目名称:weechat-scripts,代码行数:12,代码来源:whois_on_query.py

示例3: main

def main():
    if not weechat.register("terminal_notifier", "Keith Smiley", "1.1.0", "MIT",
                            "Get OS X notifications for messages", "", ""):
        return weechat.WEECHAT_RC_ERROR

    if distutils.spawn.find_executable("osascript") is None:
        return weechat.WEECHAT_RC_OK

    weechat.hook_signal("weechat_pv", "notify", "")
    weechat.hook_signal("weechat_highlight", "notify", "")

    return weechat.WEECHAT_RC_OK
开发者ID:keith,项目名称:terminal-notifier-weechat,代码行数:12,代码来源:terminal_notifier.py

示例4: create_hooks

def create_hooks():
    # create hooks
    weechat.hook_signal('quit', 'quit_signal_cb', '')
    weechat.hook_signal('upgrade_ended', 'upgrade_ended_cb', '')
    weechat.hook_signal('buffer_opened', 'buffer_opened_cb', '')
    weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '' )
    weechat.hook_signal('buffer_closing', 'buffer_closing_cb', '')
开发者ID:FiXato,项目名称:weechat-scripts,代码行数:7,代码来源:histman.py

示例5: _highlight_msg_cb

def _highlight_msg_cb(data, buffer, date, tags, displayed,
                      highlight, prefix, message):
    '''Weechat message highlight callback. This is called when a message
    arrives with user's nick in it.

    https://weechat.org/files/doc/stable/weechat_plugin_api.en.html
    '''
    if not int(highlight) and 'notify_private' not in tags:
        return weechat.WEECHAT_RC_OK

    global g_pipe_write_fd
    global g_buffer_hook
    try:
        os.write(g_pipe_write_fd, 'SET')

    except OSError as e:
        weechat.unhook_all()
        weechat.prnt('', 'problem on using pipe fd, unhooking msg' %
                     str(e))

    if g_buffer_hook is None:
        g_buffer_hook = weechat.hook_signal('key_pressed',
                                            '_key_pressed_cb',
                                            '')

    return weechat.WEECHAT_RC_OK
开发者ID:jrziviani,项目名称:laboratory,代码行数:26,代码来源:blinkicon.py

示例6: insert_word

def insert_word(buffer, word, prev_word):
    input_line = w.buffer_get_string(buffer, 'input')
    input_pos = w.buffer_get_integer(buffer, 'input_pos')

    strip_len = len(prev_word)
    left = input_line[0:input_pos - strip_len]
    new_pos = input_pos + len(word) - strip_len
    right = input_line[input_pos:]
    result = left + word + right

    # If we don't deactivate the hook temporarily it is triggered
    global hooks
    map(w.unhook, hooks)
    w.buffer_set(buffer, 'input', result)
    w.buffer_set(buffer, 'input_pos', str(new_pos))
    hooks = (w.hook_signal("input_text_*", "finish_hook", ""),
             w.hook_signal("*_switch", "finish_hook", ""))
开发者ID:Osse,项目名称:complete_words,代码行数:17,代码来源:complete_words.py

示例7: add_hooks

def add_hooks():
  global hooks
  hooked_servers = OPTIONS['hooks.explicit_servers'].split(',')
  for server_name in hooked_servers:
    signal = "%s,irc_in2_join" % server_name
    # weechat.prnt('', "Adding hook on %s" % signal)
    hook = weechat.hook_signal(signal, "on_join_scan_cb", "")
    hooks.add(hook)
开发者ID:DarkDefender,项目名称:scripts,代码行数:8,代码来源:clone_scanner.py

示例8: apply_config

def apply_config():
	# Unhook all signals and hook the new ones.
	for hook in hooks:
		weechat.unhook(hook)
	for signal in config.signals:
		hooks.append(weechat.hook_signal(signal, 'on_signal', ''))

	if config.sort_on_config:
		do_sort()
开发者ID:ASKobayashi,项目名称:dotFiles,代码行数:9,代码来源:autosort.py

示例9: hook_all

def hook_all(server):
    global HOOKS

    notice = server + '.notice'
    modifier = server + '.modifier'

    if notice not in HOOKS:
        HOOKS[notice]   = weechat.hook_signal("%s,irc_raw_in_notice" % server, "auth_success_cb", server)
    if modifier not in HOOKS:
        HOOKS[modifier] = weechat.hook_modifier("irc_out_privmsg", "totp_login_modifier_cb", "")
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:10,代码来源:undernet_totp.py

示例10: apply_config

def apply_config():
	# Unhook all signals and hook the new ones.
	for hook in hooks:
		weechat.unhook(hook)
	for signal in config.signals:
		hooks.append(weechat.hook_signal(signal, 'on_signal', ''))

	if config.sort_on_config:
		debug('Sorting because configuration changed.')
		do_sort()
开发者ID:MatthewCox,项目名称:dotfiles,代码行数:10,代码来源:autosort.py

示例11: imap_cmd

def imap_cmd(data, buffer, args):
    ''' Callback for /imap command '''

    global active_folder_line, active_message_line, active_folder_name, active_message_uid

    if not args:
        buffer_create()
        #print_messages()
        w.bar_item_update('imap_folders')
        w.command('', '/bar show imap')
        w.hook_signal('buffer_switch', 'toggle_imap_bar', '')
        w.command('', '/buffer %s' %SCRIPT_COMMAND)
    if args == 'folder_down':
        active_folder_line += 1
        w.bar_item_update('imap_folders')
    if args == 'folder_up':
        if active_folder_line > 0:
            active_folder_line -= 1
            w.bar_item_update('imap_folders')
    if args == 'message_down':
        active_message_line += 1
        print_messages(active_folder_name)
    if args == 'message_up':
        if active_message_line > 0:
            active_message_line -= 1
            print_messages(active_folder_name)
    if args == 'message_mark_read':
        if active_message_uid:
            imap = Imap()
            imap.mark_read(active_folder_name, active_message_uid)
            imap.logout()
            w.bar_item_update('imap_folders')
    if args == 'message_delete':
        if active_message_uid:
            imap = Imap()
            imap.delete(active_folder_name, active_message_uid)
            imap.logout()
            w.bar_item_update('imap_folders')
    if args == 'message_fetch':
        if active_message_uid:
            print_message()
    return w.WEECHAT_RC_OK
开发者ID:FiXato,项目名称:weechat-scripts-xt,代码行数:42,代码来源:imap.py

示例12: install_hooks

def install_hooks():
    global HOOK,OPTIONS

    # Should never happen
    if any([HOOK[k] != '' for k in HOOK]):
        return

    if not OPTIONS['delay'] or not OPTIONS['timeout']:
        return

    debug_print("Installing timer with delay %s seconds" % OPTIONS['delay'])
    HOOK['timer'] = weechat.hook_timer(int(OPTIONS['delay']) * 1000, 0, 0, 'check_nicks', '')
    HOOK['redirect'] = weechat.hook_hsignal('irc_redirection_%s_ison' % SCRIPT_NAME, 'redirect_isonhandler', '' )
    HOOK['quit'] = weechat.hook_signal('*,irc_raw_in_quit', 'check_quit', '')
    HOOK['nick'] = weechat.hook_signal('*,irc_raw_in_nick', 'check_nick_change', '')

    for k in HOOK:
        if HOOK[k] == 0:
            weechat.prnt('', "%s: can't enable %s, hook_timer() failed" %
                         (weechat.prefix('error'), SCRIPT_NAME))
开发者ID:DarkDefender,项目名称:scripts,代码行数:20,代码来源:keepnick.py

示例13: enable_logging

def enable_logging():
    """ Connect to MongoDB and add our IRC hooks """

    global mongo_collection, logging_hooks

    # Attempt to connect to our configured MongoDB instance
    # TODO -- assert that mongo connection worked
    mongo_host = weechat.config_get_plugin('mongo_host')
    mongo_port = weechat.config_get_plugin('mongo_port')
    mongo_database_name = weechat.config_get_plugin('mongo_database')
    mongo_collection_name = weechat.config_get_plugin('mongo_collection')
    mongo_user = weechat.config_get_plugin('mongo_user')
    mongo_password = weechat.config_get_plugin('mongo_password')

    mongoclient_arguments = {
        'connectTimeoutMS': 1
    }

    if len(mongo_host) > 0:
        mongoclient_arguments['host'] = mongo_host

    if len(mongo_port) > 0:
        mongoclient_arguments['port'] = int(mongo_port)

    mongo_client = pymongo.MongoClient(**mongoclient_arguments)
    mongo_database = mongo_client[mongo_database_name]
    mongo_collection = mongo_database[mongo_collection_name]

    # Authenticate if we have a configured user
    if len(mongo_user) > 0:
        try:
            mongo_database.authenticate(mongo_user, password=mongo_password)
        except pymongo.errors.OperationFailure as e:
            weechat.prnt('', 'Couldn\'t authenticate to MongoDB DB {}: {}'.format(mongo_database_name, e.details['errmsg']))
            weechat.config_set_plugin('enabled', DISABLED)
            return

    # Set up our logging hooks
    hooks = [
        'irc_raw_in2_privmsg',
        'irc_raw_in2_join',
        'irc_raw_in2_part',
        'irc_raw_in2_mode',
        'irc_raw_in2_quit',
        'irc_out1_privmsg',
        'irc_out1_join',
        'irc_out1_part',
        'irc_out1_mode',
        'irc_out1_quit'
    ]

    for hook in hooks:
        logging_hooks.append(weechat.hook_signal('*,{}'.format(hook), 'log_to_mongo', ''))
开发者ID:kaiju,项目名称:mongologger,代码行数:53,代码来源:mongologger.py

示例14: main

def main():
    '''Sets up WeeChat notifications.'''
    # Initialize options.
    for option, value in SETTINGS.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, value)
    # Initialize.
    notifications = [
        'Public',
        'Private',
        'Action',
        'Notice',
        'Invite',
        'Highlight',
        'Server',
        'Channel',
        'DCC',
        'WeeChat'
    ]
    # Register hooks.
    weechat.hook_signal(
        'irc_server_connected',
        'cb_irc_server_connected',
        '')
    weechat.hook_signal(
        'irc_server_disconnected',
        'cb_irc_server_disconnected',
        '')
    weechat.hook_signal('upgrade_ended', 'cb_upgrade_ended', '')
    weechat.hook_print('', '', '', 1, 'cb_process_message', '')
开发者ID:mmaker,项目名称:mnotify,代码行数:30,代码来源:mnotify.py

示例15: main

def main():
    '''Sets up WeeChat notifications.'''
    # Initialize options.
    for option, value in SETTINGS.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, value)
    # Initialize.
    name = "WeeChat"
    icon = "/usr/share/pixmaps/weechat.xpm"
    notifications = [
        'Public',
        'Private',
        'Action',
        'Notice',
        'Invite',
        'Highlight',
        'Server',
        'Channel',
        'DCC',
        'WeeChat'
    ]
    STATE['icon'] = icon
    # Register hooks.
    weechat.hook_signal(
        'irc_server_connected',
        'cb_irc_server_connected',
        '')
    weechat.hook_signal(
        'irc_server_disconnected',
        'cb_irc_server_disconnected',
        '')
    weechat.hook_signal('upgrade_ended', 'cb_upgrade_ended', '')
    weechat.hook_print('', '', '', 1, 'cb_process_message', '')
    weechat.hook_timer(1000, 1, 65535, "cb_buffer_tick", "")
    pynotify.init(name)
开发者ID:kilogram,项目名称:weechat-anotify,代码行数:35,代码来源:anotify.py


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