本文整理汇总了Python中weechat.hook_signal函数的典型用法代码示例。如果您正苦于以下问题:Python hook_signal函数的具体用法?Python hook_signal怎么用?Python hook_signal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hook_signal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: main
def main():
'''Sets up WeeChat Growl notifications.'''
# Initialize options.
for option, value in SETTINGS.items():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, value)
# Initialize Growl.
name = "WeeChat"
hostname = weechat.config_get_plugin('hostname')
password = weechat.config_get_plugin('password')
icon_path = os.path.join(weechat.info_get("weechat_dir", ""),
weechat.config_get_plugin('icon'))
try:
icon = open(icon_path, "rb").read()
except IOError:
weechat.prnt('',
'Weechat-Growl: {0} could not be opened. '.format(icon_path) +
'Please make sure it exists.')
icon = None
notifications = [
'Public',
'Private',
'Action',
'Notice',
'Invite',
'Highlight',
'Server',
'Channel',
'DCC',
'WeeChat'
]
if len(hostname) == 0:
hostname = ''
if len(password) == 0:
password = ''
growl = GrowlNotifier(
applicationName=name,
hostname=hostname,
password=password,
notifications=notifications,
applicationIcon=icon)
try:
growl.register()
except Exception as error:
weechat.prnt('', 'growl: {0}'.format(error))
STATE['growl'] = growl
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', '')
开发者ID:sorin-ionescu,项目名称:weechat-growl,代码行数:59,代码来源:growl.py
示例17: jmh_set_hooks
def jmh_set_hooks():
# prototype: hook = weechat.hook_signal(signal, callback, callback_data)
weechat.hook_signal('weechat_highlight', 'message_highlight', '')
weechat.hook_signal('irc_pv', 'message_private_irc', '')
weechat.hook_signal('weechat_pv', 'message_private_weechat', '')
# prototype: hook = weechat.hook_print(buffer, tags, message, strip_colors,
# callback, callback_data)
weechat.hook_print('', 'notify_message', '', 1, 'message_weechat_print', '')
开发者ID:zsw,项目名称:dotfiles,代码行数:8,代码来源:jabber_message_handler.py
示例18: on_config_changed
def on_config_changed(*args, **kwargs):
''' Called whenever the configuration changes. '''
config.reload()
# 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_buffers_changed', ''))
if config.sort_on_config:
on_buffers_changed()
return weechat.WEECHAT_RC_OK
开发者ID:0xdkay,项目名称:dotfiles,代码行数:14,代码来源:autosort.py
示例19: 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
示例20: signal_irc_pv_opened
def signal_irc_pv_opened(data, signal, signal_data):
"""Callback for signal 'irc_pv_opened'."""
global irc_pv_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':
unhook_irc_pv()
if weechat.config_get_plugin('self_query') == 'on':
exec_command(signal_data, nick)
else:
# 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)
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))
return weechat.WEECHAT_RC_OK
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:16,代码来源:whois_on_query.py
注:本文中的weechat.hook_signal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论