本文整理汇总了Python中weechat.hook_print函数的典型用法代码示例。如果您正苦于以下问题:Python hook_print函数的具体用法?Python hook_print怎么用?Python hook_print使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hook_print函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: __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
示例8: postgre_log_enable_cb
def postgre_log_enable_cb(data, buffer, args):
global _connection
global _msg_hook
global _join_hook
global _part_hook
try:
_connection = psycopg2.connect(args)
except psycopg2.OperationalError as ex:
weechat.prnt('', 'Valid connection string is required.')
return weechat.WEECHAT_RC_ERROR
create_map_table_if_not_exists()
_msg_hook = weechat.hook_print('', 'irc_privmsg', '', 1, 'msg_cb',
'PRIVMSG')
_join_hook = weechat.hook_print('', 'irc_join', '', 1, 'log_cb', 'JOIN')
_part_hook = weechat.hook_print('', 'irc_part', '', 1, 'log_cb', 'PART')
return weechat.WEECHAT_RC_OK
开发者ID:sgkim126,项目名称:weechat_postgre,代码行数:18,代码来源:postgre_log.py
示例9: 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.
icon = "/usr/share/pixmaps/weechat.xpm"
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:justone,项目名称:weechat-config,代码行数:20,代码来源:pmb_notify.py
示例10: 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 = "file://{0}".format(os.path.join(weechat.info_get("weechat_dir", ""), weechat.config_get_plugin("icon")))
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:webvictim,项目名称:weechat-growl,代码行数:41,代码来源:growl.py
示例11: 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
示例12: 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:de-vri-es,项目名称:scripts,代码行数:24,代码来源:mnotify.py
示例13: weechat_script
def weechat_script():
settings = {'host' : "localhost",
'port' : "4321",
'icon' : "utilities-terminal",
'pm-icon' : "emblem-favorite",
'urgency_default' : 'critical',
'display_time_default' : '10000',
'display_time_highlight' : '30000',
'display_time_private_highlight' : '0'}
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:zeltak,项目名称:dotfiles,代码行数:17,代码来源:weechat-remote-notify.py
示例14: is_abstract_noun
if (evaluate_after_less is True) and (tag == 'NN' or tag == 'NNS'):
if is_abstract_noun(word) is False:
return True
evaluate_after_less = False
return False
def is_abstract_noun(word):
return True if word in abstract_nouns else False
def is_concrete_noun(word):
return True if word in concrete_nouns else False
if __name__ == "__main__":
logging.basicConfig(filename='/tmp/stannisbotout.log', level=logging.DEBUG)
w.register(STANNISBOT_NAME, STANNISBOT_AUTHOR, STANNISBOT_VERSION, STANNISBOT_LICENSE, STANNISBOT_DESC, STANNISBOT_CLOSE, "")
logging.debug('STARTING UP STANNISBOT!! YEAH!!! BEND THE KNEE!!')
w.hook_print("", "", "", 1, "catch_message", "")
#Hrmmm.... Weechat's not letting this import.
with open(abstract_nouns_file) as f:
abstract_nouns = [x.strip('\n') for x in f.readlines()]
with open(concrete_nouns_file) as f:
concrete_nouns = [x.strip('\n') for x in f.readlines()]
开发者ID:shuchow,项目名称:stannisbot,代码行数:30,代码来源:stannisbot.py
示例15: banchans
cursor.execute("INSERT INTO banchans(ignored) VALUES (?)", (command[1],))
except:
weechat.prnt("", "Could not add channel to ignored list.")
weechat.prnt("", "Usage: /triggerreply ignore server.#channel")
weechat.prnt("", "Example: /triggerreply ignore freenode.#mychan")
else:
database.commit()
weechat.prnt("", "Channel successfully added to ignore list!")
elif command[0] == "parse":
try:
cursor.execute("DELETE FROM banchans WHERE ignored = ?", (command[1],))
except:
weechat.prnt("", "Could not remove channel from ignored.")
weechat.prnt("", "Usage: /triggerreply parse server.#channel")
weechat.prnt("", "Example: /triggerreply parse freenode.#mychan")
else:
database.commit()
weechat.prnt("", "Channel successfully removed from ignored.")
return weechat.WEECHAT_RC_OK
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
if import_error:
weechat.prnt("", "You need sqlite3 to run this plugin.")
dbfile = "%s/trigge.rs" % weechat.info_get("weechat_dir", "")
if not os.path.isfile(dbfile):
create_db()
weechat.hook_print("", "", "", 1, "search_trig_cb", "")
weechat.hook_command(SCRIPT_NAME, SCRIPT_DESC, "See `/triggerreply' for more information.", "", "", "command_input_callback", "")
开发者ID:Ratler,项目名称:weechat-scripts,代码行数:30,代码来源:triggerreply.py
示例16: hook_callback
def hook_callback(data, bufferp, uber_empty, tagsn, isdisplayed, ishighlight, prefix, message):
if bufferp == weechat.current_buffer() and FORCE_ENABLED:
pass
## highlight
elif ishighlight == "1" and (weechat.buffer_get_string(bufferp, "localvar_away") or FORCE_ENABLED):
if flood_check():
buffer = weechat.buffer_get_string(bufferp, "short_name") or weechat.buffer_get_string(bufferp, "name")
if prefix == buffer: # treat as pm if user mentions your nick in a pm
post_prowl("WeeChat", "Private Message from " + prefix, message)
elif prefix != buffer: # otherwise, treat as highlight
post_prowl("WeeChat", prefix + " mentioned you on " + buffer, message)
## privmsg
elif weechat.buffer_get_string(bufferp, "localvar_type") == "private" and (
weechat.buffer_get_string(bufferp, "localvar_away") or FORCE_ENABLED
):
if flood_check():
post_prowl("WeeChat", "Private Message from " + prefix, message)
return weechat.WEECHAT_RC_OK
# Hooks
weechat.hook_print("", "notify_message", "", 1, "hook_callback", "")
weechat.hook_print("", "notify_private", "", 1, "hook_callback", "")
开发者ID:kidchunks,项目名称:weechat-prowl-notify,代码行数:28,代码来源:prowl_notify.py
示例17: show_config_help
# Plugin settings
settings = {
'prowl_api_key': '',
'prowl_priority': '0', # An integer value ranging [-2, 2] per http://www.prowlapp.com/api.php#add
'show_hilights': 'on',
'show_priv_msg': 'on',
'nick_separator': ': ',
'notify_focused_active': 'on', # If 'on', send Prowl notifications for the currently-focused buffer when not away
'notify_focused_away': 'on', # If 'on', send Prowl notifications for the currently-focused buffer when away
'notify_unfocused_active': 'on', # If 'on', send Prowl notifications for non-focused buffers when not away
'notify_unfocused_away': 'on' # If 'on', send Prowl notifications for non-focused buffers when away
}
# Hook for private messages/hilights
weechat.hook_print('', 'irc_privmsg', '', 1, 'notification_callback', '')
# Shows an error/help message if prowl_api_key is not set
def show_config_help():
weechat.prnt('', '%sweeprowl - Error: Your Prowl API key is not set!' % weechat.prefix('error'))
weechat.prnt('', '%sweeprowl - To obtain a Prowl API key, visit <http://prowlapp.com>.' % weechat.prefix('error'))
weechat.prnt('', '%sweeprowl - Once you have a Prowl API key, configure weeprowl to use it by running:' % weechat.prefix('error'))
weechat.prnt('', '%sweeprowl - /set plugins.var.python.weeprowl.prowl_api_key "your_prowl_api_key_here"' % weechat.prefix('error'))
# Shows an error when there was a problem sending a Prowl notification.
def show_notification_error():
weechat.prnt('', '%sweeprowl - Could not send Prowl notification.' % weechat.prefix('error'))
# Triggered by the weechat hook above
def notification_callback(data, bufferp, uber_empty, tagsn, isdisplayed, ishilight, prefix, message):
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:29,代码来源:weeprowl.py
示例18: int
urlsave_buffer = None
return weechat.WEECHAT_RC_OK
if __name__ == "__main__" and import_ok:
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
version = weechat.info_get('version_number', '') or 0
# Set default settings
for option, default_value in urlsave_settings.iteritems():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, default_value[0])
if int(version) >= 0x00030500:
weechat.config_set_desc_plugin(option, default_value[1])
urlsave_buffer = weechat.buffer_search("python", "urlsave")
if not urlsave_buffer:
# Create urlsave. Sets notify to 0 as this buffer does not need to
# be in hotlist.
urlsave_buffer = weechat.buffer_new("urlsave", "urlsave_input_cb", \
"", "urlsave_close_cb", "")
weechat.buffer_set(urlsave_buffer, "title", "URL buffer")
weechat.buffer_set(urlsave_buffer, "notify", "0")
weechat.buffer_set(urlsave_buffer, "nicklist", "0")
# Hook all public and private messages (some may think this is too limiting)
weechat.hook_print("", "notify_message", "", 1, "urlsave_print_cb", "")
weechat.hook_print("", "notify_private", "", 1, "urlsave_print_cb", "")
开发者ID:tienfuc,项目名称:weechat_scripts,代码行数:29,代码来源:urlsave.py
示例19: privmsg
# Passive aggressively auto-replies to private messages which say only the word
# 'ping' thus escalating the unwinnable war of people pinging without saying anything
# else.
#
# History:
#
# 2013-01-11, Wil Clouser <[email protected]>:
# v0.1: Initial release
SCRIPT_NAME = "autopong"
SCRIPT_AUTHOR = "Wil Clouser <[email protected]>"
SCRIPT_VERSION = "0.1"
SCRIPT_LICENSE = "MIT"
SCRIPT_DESC = "Auto-replies to 'ping' queries"
try:
import weechat as w
except:
print "Script must be run under weechat. http://www.weechat.org"
def privmsg(data, buffer, date, tags, displayed, is_hilight, prefix, msg):
if w.buffer_get_string(buffer, "localvar_type") == "private":
if msg == "ping":
w.command(buffer, "pong")
return w.WEECHAT_RC_OK
if __name__ == "__main__" and import_ok:
if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
SCRIPT_DESC, "", ""):
w.hook_print("", "", "", 1, "privmsg", "")
开发者ID:kjseefried,项目名称:scripts,代码行数:30,代码来源:autopong.py
示例20: int
SCRIPT_DESC,
"weechat_script_end",
""):
version = weechat.info_get('version_number', '') or 0
# Init everything
for option, default_desc in settings.items():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, default_desc[0])
if int(version) >= 0x00030500:
weechat.config_set_desc_plugin(option, default_desc[1])
# Perform some sanity checks to make sure we have everything we need to run
sanity = True
weechat_windowid = os.environ.get('WINDOWID')
if weechat_windowid == None:
weechat.prnt("", "%sEnvironment variable WINDOWID not set. This script requires an X environment to run." % weechat.prefix("error"))
sanity = False
fifo_filename = weechat.info_get("fifo_filename", "")
if fifo_filename == "":
weechat.prnt("", "%sWeechat variable fifo_filename is not set. Is the fifo plugin enabled?" % weechat.prefix("error"))
sanity = False
if sanity:
Subprocess.start(fifo_filename, weechat_windowid)
# Hook privmsg/hilights
weechat.hook_print("", "", "", 1, "notify_msg", "")
weechat.hook_signal("buffer_switch", "buffer_switched", "")
开发者ID:DarkDefender,项目名称:scripts,代码行数:30,代码来源:windicate.py
注:本文中的weechat.hook_print函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论