def setup_hooks(): global description global help_text w.hook_print('', '', '', 1, 'message_hook', '') w.hook_command('weepushover', description, '[command]', help_text, '', 'show_help', '')
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', '')
def setup_hooks(): global description global help_text w.hook_print('', '', '', 1, 'message_hook', '') w.hook_command('weebullet', description, '[command]', help_text, '', 'process_command', '')
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)
def __init__(self): """Weenotifier - initialization.""" self.options = { 'url': 'https://irssinotifier.appspot.com/API/Message', 'token': '', 'password': '******' } for option, value in self.options.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, value) self.url = weechat.config_get_plugin('url') if self.url is None or len(self.url) <= 0: raise NameError('weenotifier: url not configured') self.token = weechat.config_get_plugin('token') if self.token is None or len(self.token) <= 0: raise NameError('weenotifier: token not configured') self.password = weechat.config_get_plugin('password') if self.password is None or len(self.password) <= 0: raise NameError('weenotifier: password not configured') self.version = weechat.info_get('version_number', '') or '0' weechat.hook_print('', '', '', 1, 'message_cb', '')
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', '')
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()
def setup_hooks(): global SCRIPT_NAME global SCRIPT_DESC global help_text w.hook_print('', '', '', 1, 'message_hook', '') w.hook_command(SCRIPT_NAME, SCRIPT_DESC, '[command] show_config/test', help_text, '', 'handle_argument', '')
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', '')
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', '')
def main(): check_config() weechat.hook_modifier("irc_in_notice", "modifier_cb", "") weechat.hook_completion(TEMPLATE_NAME, "TAB completion to bitlbee", "completion_cb", "") weechat.hook_print('', 'irc_332', '', 1, 'print_cb', '') weechat.hook_print('', 'irc_topic', '', 1, 'print_cb', '') find_buffer()
def script_main(): if not weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESCRIPTION, "", ""): return 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_print("", "irc_privmsg", "", 1, "message_cb", "")
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) # 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', '')
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", "")
def update_hook(*args): global the_print_hook if the_print_hook: weechat.unhook(the_print_hook) value = weechat.config_get_plugin('tags') the_print_hook = weechat.hook_print('', value, '', 0, 'on_print', '') return weechat.WEECHAT_RC_OK
def client(): """ Method to register the plugin and hook into weechat """ settings = { 'enable': { 'description': 'Enable/Disable notifications.', 'values': ['off', 'on'], 'default': 'off' }, 'mode': { 'description': 'Set whether notifications need to be' 'sent locally or to an external server.', 'values': ['local', 'remote'], 'default': 'local' }, 'host': { 'description': 'Set the server host to send notifications to.', 'values': None, 'default': 'localhost' }, 'port': { 'description': 'Set the server port to use to send notifcation.', 'values': None, 'default': '5431' }, 'notify_for': { 'description': 'A comma-separated list of buffers for which you want to receive notifications.', 'values': None, 'default': '' }, 'ignore_nicks': { 'description': 'A comma-separated list of nicks from which no notifications should be shown.', 'values': None, 'default': '-,--,-->,<--,===,*,* , *,,' } } if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESCRIPTION, '', ''): for option, value in settings.items(): if not w.config_is_set_plugin(option): w.config_set_plugin(option, value['default']) if value.get('values', None): w.config_set_desc_plugin( option, '{} (values: [{}], default: {})'.format( value['description'], '/'.join(value['values']), value['default'])) else: w.config_set_desc_plugin( option, '{} (default: {})'.format(value['description'], value['default'])) w.hook_print('', '', '', 1, 'on_notify', 'IRC') w.hook_print('', 'notify_message', '', 1, 'on_notify', 'MSG') w.hook_print('', 'notify_private', '', 1, 'on_notify', 'PRIVMSG') w.hook_print('', 'irc_notice', '', 1, 'on_notify', 'NOTICE')
def config_cb(data, option, value): global hook if value == 'on': hook = w.hook_print("", "", "", 1, "my_print_cb", "") else: w.unhook(hook) return w.WEECHAT_RC_OK
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
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', '')
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", "")
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', '') sending_thread.start()
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', '') weechat.hook_command('alibnotify', ALIBNOTIFY_COMMAND_HELP, '', '', ALIBNOTIFY_COMMAND_COMPLETION, 'alibnotify_cb', '') # Create bar item alibnotify_bar_item = weechat.bar_item_new(SCRIPT_NAME, 'bar_item_build_cb', '') weechat.prnt('', 'alibnotify bar item: %s' % alibnotify_bar_item) STATE['bar_item'] = alibnotify_bar_item
def config(): try: global pb API_Key = weechat.config_get_plugin('api_key') if API_Key == '': raise Exception() pb = Pushbullet(API_Key) print_hook = weechat.hook_print('', '', '', 1, 'handle_msg', '') except: weechat.config_set_plugin('api_key', '') prnt( 'Please `/set plugins.var.python.weebullet.api_key <API_KEY>` to use this plugin.' )
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
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", "")
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
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
def weechat_script(): settings = { 'notify_command': "", 'host': "localhost", 'port': "4321", 'icon': "utilities-terminal", 'pm-icon': "emblem-favorite", 'urgency_default': 'normal', 'display_time_default': '10000', 'display_time_highlight': '30000', 'display_time_private_highlight': '0', 'display_errors': 'on' } 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
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", "")
if return_code == weechat.WEECHAT_HOOK_PROCESS_ERROR: weechat.prnt("", "Error with command '%s'" % command) elif return_code != 0: weechat.prnt("", "return_code = %d" % return_code) weechat.prnt("", "notify-send has an error") return weechat.WEECHAT_RC_OK def notify_user(origin, message): hook = weechat.hook_process_hashtable( "notify-send", { "arg1": "-i", "arg2": cfg["icon"], "arg3": "-a", "arg4": "WeeChat", "arg5": origin, "arg6": message }, 20000, "process_cb", "") return weechat.WEECHAT_RC_OK # execute initializations in order if __name__ == "__main__": weechat.register( lnotify_name, "kevr", lnotify_version, lnotify_license, "{} - A libnotify script for weechat".format(lnotify_name), "", "") cfg = config() print_hook = weechat.hook_print("", "", "", 1, "handle_msg", "")
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", "")
def show_notification(chan, message): """Our handler to print highlighted messages""" notify2.init("weechat") wn = notify2.Notification(chan, message, weechat.config_get_plugin('icon')) wn.set_urgency(urgencies[weechat.config_get_plugin('urgency')] or notify2.URGENCY_NORMAL) # now try to show notification try: wn.show() return None except Exception as e: return "Exception trying to show notification: {0}".format(e) if __name__ == "__main__": if import_ok and weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): # Init everything for option, default_value in list(settings.items()): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) # Hook privmsg/hilights weechat.hook_print("", "irc_privmsg", "", 1, "notify_show", "") # w.hook_info('%s_buffer' %SCRIPT_NAME, '', '', 'info_hook_cb', '') # vim:set shiftwidth=4 tabstop=4 softtabstop=4 expandtab textwidth=250:
elif buffer_type == "channel" and highlight: notify_user("{} @ {}".format(prefix, buffer_name), message) return weechat.WEECHAT_RC_OK def process_cb(data, command, return_code, out, err): if return_code == weechat.WEECHAT_HOOK_PROCESS_ERROR: weechat.prnt("", "Error with command '%s'" % command) elif return_code != 0: weechat.prnt("", "return_code = %d" % return_code) weechat.prnt("", "notify-send has an error") return weechat.WEECHAT_RC_OK def notify_user(origin, message): hook = weechat.hook_process_hashtable("notify-send", { "arg1": "-i", "arg2": cfg["icon"], "arg3": "-a", "arg4": "WeeChat", "arg5": origin, "arg6": message }, 20000, "process_cb", "") return weechat.WEECHAT_RC_OK # execute initializations in order if __name__ == "__main__": weechat.register(lnotify_name, "kevr", lnotify_version, lnotify_license, "{} - A libnotify script for weechat".format(lnotify_name), "", "") cfg = config() print_hook = weechat.hook_print("", "", "", 1, "handle_msg", "")
# script options settings = { "show_hilights": "on", "show_priv_msg": "on", "icon": "/usr/share/pixmaps/weechat.xpm", "urgency": "normal", "smart_notification": "off", } # Init everything for option, default_value in settings.items(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) # Hook privmsg/hilights weechat.hook_print("", "", "", 1, "nofify_show_hi", "") # Functions def nofify_show_hi(data, bufferp, uber_empty, tagsn, isdisplayed, ishilight, prefix, message): """Sends highlighted message to be printed on notification""" if bufferp != weechat.current_buffer() or weechat.config_get_plugin( 'smart_notification') == "off": if weechat.buffer_get_string( bufferp, "localvar_type" ) == "private" and weechat.config_get_plugin('show_priv_msg') == "on": show_notification("Private message: ", message) else: if ishilight == "1" and weechat.config_get_plugin( 'show_hilights') == "on":
label = r'[0-9a-z][-0-9a-z]*[0-9a-z]?' domain = r'%s(?:\.%s)*\.[a-z][-0-9a-z]*[a-z]?' % (label, label) urlRe = re.compile( r'(\w+://(?:%s|%s)(?::\d+)?(?:/[^\])>\s]*)?)' % (domain, ipAddr), re.I ) if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): for option, default_value in settings.iteritems(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) weechat.hook_print('', 'irc_privmsg', '', 1, 'notify', '') weechat.hook_modifier('irc_out_privmsg', 'outgoing_hook', '') def notify(data, buf, date, tags, displayed, hilight, prefix, msg): color = weechat.color(weechat.config_get_plugin('color')) reset = weechat.color('reset') my_nick = weechat.buffer_get_string(buf, 'localvar_nick') if prefix != my_nick: urls = find_and_process_urls(msg) for url, short_url in urls: weechat.prnt(buf, '%(color)s[ %(url)s ]%(reset)s' % dict( color=color, url=short_url,
# Hope you guys like it :O import weechat, string, subprocess weechat.register("lnotify", "kevr", "0.1.1", "GPL3", "lnotify - A libnotify script for weechat", "", "") # Set up here, go no further! settings = {"show_highlight": "on", "show_priv_msg": "on"} # Init everything for option, default_value in settings.items(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) # Hook privmsg/hilights weechat.hook_print("", "irc_privmsg", "", 1, "get_notified", "") # Functions def get_notified(data, bufferp, uber_empty, tagsn, isdisplayed, ishilight, prefix, message): if ( weechat.buffer_get_string(bufferp, "localvar_type") == "private" and weechat.config_get_plugin("show_priv_msg") == "on" ): buffer = weechat.buffer_get_string(bufferp, "short_name") or weechat.buffer_get_string(bufferp, "name") if buffer == prefix: subprocess.call(["/usr/bin/notify-send", "In Private Message %s: %s" % (prefix, message)], shell=False) elif ishilight == "1" and weechat.config_get_plugin("show_highlight") == "on": buffer = weechat.buffer_get_string(bufferp, "short_name") or weechat.buffer_get_string(bufferp, "name") subprocess.call(["/usr/bin/notify-send", "In %s %s: %s" % (buffer, prefix, message)], shell=False)
"normal_fg": "#CCCCCC", "normal_bg": "#1C1C1C", "normal_timeout": "5", "private_fg": "#5FD700", "private_bg": "#1C1C1C", "private_timeout": "5", "hilite_fg": "#D7005F", "hilite_bg": "#1C1C1C", "hilite_timeout": "-1", } import weechat, sys, pipes, shlex weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", "") weechat.hook_print("", "irc_privmsg", "", 1, "receive", "") for opt, val in settings.items(): if not weechat.config_is_set_plugin(opt): weechat.config_set_plugin(opt, val) def config(key): value = weechat.config_get_plugin(key) if value is None: value = settings[key] return value def ok(*args, **kwargs): return weechat.WEECHAT_RC_OK
with open(os.devnull, 'wb') as devnull: subprocess.check_call( notify_cmd, stderr=subprocess.STDOUT, stdout=devnull, ) if __name__ == '__main__': # Registration. weechat.register( SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, SCRIPT_SHUTDOWN_FUNC, SCRIPT_CHARSET ) # Initialization. for option, (default_value, description) in OPTIONS.items(): description = add_default_value_to(description, default_value) weechat.config_set_desc_plugin(option, description) if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) # Catch all messages on all buffers and strip colors from them before # passing them into the callback. weechat.hook_print('', '', '', 1, 'message_printed_callback', '')
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()]
return weechat.WEECHAT_RC_OK # ignore messages older than 4 seconds if weechat.config_get_plugin('ignore_old_messages') == 'on': message_time = datetime.datetime.utcfromtimestamp(int(date)) now_time = datetime.datetime.utcnow() if (now_time - message_time).seconds > 4: return weechat.WEECHAT_RC_OK # pass lambda to avoid playing default sound sound = (weechat.config_get_plugin('sound_name') if weechat.config_get_plugin('sound') == 'on' else lambda: _) activate_bundle_id = weechat.config_get_plugin('activate_bundle_id') pync.notify(message, title='%s [private]' % prefix, sound=sound, activate=activate_bundle_id) return weechat.WEECHAT_RC_OK if __name__ == '__main__': if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): # set default settings for key, val in wcnc_settings_default.items(): if not weechat.config_is_set_plugin(key): weechat.config_set_plugin(key, val) weechat.hook_print('', 'irc_privmsg', '', 1, 'notify', '')
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", "")
ignore_nick and ignore_text in plugins.var.python.%(script)s Each config option accepts a comma separated list of patterns. Wildcards '*', '?' and char groups [..] can be used. An ignore exception can be added by prefixing '!' in the pattern. Examples: Setting 'ignore_nick' to 'troll,b[0o]t': will ignore notifications from troll, bot and b0t. Setting 'ignore_channel' to '*ubuntu*,!#ubuntu-offtopic': will ignore notifications from any channel with the word 'ubuntu' except from #ubuntu-offtopic. Daemon: %(script)s script needs to connect to an external daemon for send notifications, which can be used in localhost or remotely. Download the daemon from: %(daemon_url)s and check its help with ./%(daemon)s --help. See also help in script file. """ %dict(script=SCRIPT_NAME, daemon_url=DAEMON_URL, daemon=DAEMON) ,'test|notify|restart|quit', 'cmd_notify', '') weechat.hook_config('plugins.var.python.%s.ignore_*' %SCRIPT_NAME, 'ignore_update', '') weechat.hook_config('plugins.var.python.%s.server_*' %SCRIPT_NAME, 'server_update', '') weechat.hook_print('', 'notify_message', '', 1, 'notify_msg', workaround) weechat.hook_print('', 'notify_private', '', 1, 'notify_msg', workaround) # vim:set shiftwidth=4 tabstop=4 softtabstop=4 expandtab textwidth=100:
options = {} for option in settings.keys(): if option in boolean_options : options[option] = booleans[w.config_get_plugin(option)] else: options[option] = w.config_get_plugin(option) def my_config_cb(data, option, value): global options for boolean_option in boolean_options : if option.endswith(boolean_option): if value in booleans.keys(): options[boolean_option] = booleans[w.config_get_plugin(boolean_option)] else: w.prnt('', 'Error: "%s" is not a boolean, please use "on" or "off"' % w.config_get_plugin(boolean_option)) w.config_set_plugin(boolean_option, invertdict(booleans)[options[boolean_option]]) write_file() return w.WEECHAT_RC_OK for option in settings.keys(): w.hook_config("plugins.var.python.%s.%s" % (name, option), "my_config_cb", "") ### HOOKS ### w.hook_command("hl2file_clear", "", "", "", "", "clear_file_cb", "") w.hook_signal("buffer_switch","buffer_switch_cb","") w.hook_signal("window_switch","buffer_switch_cb","") w.hook_print("", "", "", 1, "my_print_cb", "")
' - don\'t like the built-in HTTP server to start automatically? ' 'Disable it:\n' ' /set plugins.var.python.urlserver.http_autostart "off"\n' ' - have external port 80 or 443 (https) forwarded to your ' 'internal server port? Remove :port with:\n' ' /set plugins.var.python.urlserver.http_port_display "80" ' 'or "443" respectively\n' '\n' 'Tip: use URL without key at the end to display list of all URLs ' 'in your browser.', 'start|restart|stop|status|clear', 'urlserver_cmd_cb', '') if urlserver_settings['http_autostart'] == 'on': # start mini HTTP server urlserver_server_start() # load urls from file urlserver_read_urls() # catch URLs in buffers weechat.hook_print('', '', '://', 1, 'urlserver_print_cb', '') # modify URLS in irc messages (for relay) weechat.hook_modifier('irc_in2_privmsg', 'urlserver_modifier_irc_cb', '') weechat.hook_modifier('irc_in2_notice', 'urlserver_modifier_irc_cb', '') # search buffer urlserver['buffer'] = weechat.buffer_search('python', SCRIPT_BUFFER)
# 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):
# 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 <*****@*****.**>: # v0.1: Initial release SCRIPT_NAME = "autopong" SCRIPT_AUTHOR = "Wil Clouser <*****@*****.**>" 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", "")
# Prevent notify-send from messing up the WeeChat screen when occasionally # emitting assertion messages by redirecting the output to /dev/null (you # would need to run /redraw to fix the screen). # In Python < 3.3, there is no subprocess.DEVNULL, so we have to use a # workaround. with open(os.devnull, 'wb') as devnull: subprocess.check_call( notify_cmd, stderr=subprocess.STDOUT, stdout=devnull, ) if __name__ == '__main__': # Registration. weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, SCRIPT_SHUTDOWN_FUNC, SCRIPT_CHARSET) # Initialization. for option, (default_value, description) in OPTIONS.items(): description = add_default_value_to(description, default_value) weechat.config_set_desc_plugin(option, description) if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) # Catch all messages on all buffers and strip colors from them before # passing them into the callback. weechat.hook_print('', '', '', 1, 'message_printed_callback', '')
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): # Set default settings for option, default_value in settings.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) weechat.hook_command( SCRIPT_COMMAND, "URL bar control", "[list | hide | show | toggle | url URL]", " list: list all URL and show URL bar\n" " hide: hide URL bar\n" " show: show URL bar\n" " toggle: toggle showing of URL bar\n", "list || hide || show || toggle || url %(urlbar_urls)", "urlbar_cmd", "") weechat.hook_completion("urlbar_urls", "list of URLs", "urlbar_completion_urls_cb", "") weechat.bar_item_new("urlbar_urls", "urlbar_item_cb", "") version = int(weechat.info_get('version_number', '')) or 0 if version >= 0x02090000: weechat.bar_new("urlbar", "on", "0", "root", "", "top", "horizontal", "vertical", "0", "0", "default", "default", "default", "default", "0", "urlbar_urls") else: weechat.bar_new("urlbar", "on", "0", "root", "", "top", "horizontal", "vertical", "0", "0", "default", "default", "default", "0", "urlbar_urls") weechat.hook_print("", "", "://", 1, "urlbar_print_cb", "")
from email.mime.text import MIMEText from StringIO import StringIO import smtplib import weechat weechat.register("emailme", "asadoughi", "0.0.1", "GPL", "Send e-mail " "based on private messages and highlights.", "", "") weechat.hook_print("", "irc_privmsg", "", 1, "notify_show", "") SMTP_SERVER = "smtp.gmail.com" SMTP_PORT = 587 SENDER = "*****@*****.**" PASSWORD = "******" RECIPIENTS = ["*****@*****.**"] class EmailNotifier(object): def __init__(self, server, port, sender, password): self.smtp_server = server self.smtp_port = port self.sender = sender self.password = password def notify(self, recipients, subject, body=""): session = smtplib.SMTP(self.smtp_server, self.smtp_port) session.ehlo() session.starttls() session.login(self.sender, self.password) for recipient in recipients: msg = MIMEText(StringIO().read())
def ug_unload_script(): """ Function called when script is unloaded. """ global urlGrabSettings weechat.config_write(urlGrabSettings.config_file) return weechat.WEECHAT_RC_OK #Main stuff if ( import_ok and weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,SCRIPT_DESC, "ug_unload_script", "") ): urlgrab_buffer = None current_line = 0 max_buffer_length = 0 urlGrabSettings = UrlGrabSettings() urlGrab = UrlGrabber( urlGrabSettings['historysize']) weechat.hook_print("", "", "", 1, "urlGrabCheck", "") weechat.hook_command(SCRIPT_COMMAND, "Url Grabber", "[open <url> | <url> | show | copy [n] | [n] | list]", "open or <url>: opens the url\n" "show: Opens the select buffer to allow for url selection\n" "copy: Copies the nth url to the system clipboard\n" "list: Lists the urls in the current buffer\n", "open %(urlgrab_urls) || %(urlgrab_urls) || " "copy || show || list", "urlGrabMain", "") weechat.hook_completion("urlgrab_urls", "list of URLs", "completion_urls_cb", "") else: print "failed to load weechat"
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", "")
if (weechat.buffer_get_string(buffer, 'short_name') == "weechat"): return weechat.WEECHAT_RC_OK if (weechat.buffer_get_string(buffer, 'short_name') == "freenode"): return weechat.WEECHAT_RC_OK # if change is made to chat such as topic or name if (prefix == "-"): return weechat.WEECHAT_RC_OK # Checking if message came from yourself from device or terminal # Handles space issue if (prefix.startswith(" ")): nameToCheck = prefix[1:] if (weechat.buffer_get_string(buffer, 'localvar_nick') == nameToCheck): return weechat.WEECHAT_RC_OK # if message is older than 5 seconds (otherwise notifier displays all buffer messages each time) if (now_time - message_time).seconds > 5: return weechat.WEECHAT_RC_OK # Send notification with sender name, buffer name, and message notify(title=prefix, subtitle=weechat.buffer_get_string(buffer, 'short_name'), message=message) return weechat.WEECHAT_RC_OK # Call to the get_message function; needs to be hooked for weechat to call it weechat.hook_print('', '', '', 1, 'get_message', '')
"osc_notify", "ulhume", "0.1.3", "GPL3", "osc_notify - Terminal OSC notification", "", "", ) settings = {"notify_highlights": "on", "notify_private_messages": "on"} for option, default_value in settings.items(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) weechat.hook_print("", "irc_privmsg", "", 1, "oscn_irc_privmsg", "") def notify(name, message): subprocess.check_output( [ "/home/rr-/.local/bin/notify-urxvt", "weechat", "[%s] %s" % (name, message), ] ) def oscn_irc_privmsg( data, buffer, date, tags, displayed, highlight, prefix, message ):