本文整理汇总了Python中weechat.hook_print函数的典型用法代码示例。如果您正苦于以下问题:Python hook_print函数的具体用法?Python hook_print怎么用?Python hook_print使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hook_print函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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', '')
示例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)
示例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', '')
示例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', '')
示例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()
示例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', '')
示例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", "")
示例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
示例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', '')
示例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", "")
示例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
示例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", "")
示例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
示例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()]
示例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", "")