def main(): if not weechat.register("edit", "Keith Smiley", "1.0.0", "MIT", "Open your $EDITOR to compose a message", "", ""): return weechat.WEECHAT_RC_ERROR weechat.hook_command("edit", "Open your $EDITOR to compose a message", "", "", "", "edit", "")
def hook_commands_and_completions(): compl_list = [] com_list = [] desc_list = [] for command in sorted(command_dict): compl_list.append(command) com_list.append(command + weechat.color("*red") + " or " + weechat.color('reset') + command_dict[command] + "\n") desc_list.append(weechat.color("chat_nick_other") + command + ": \n" + desc_dict[command]) weechat.hook_command("twitter", "Command to interact with the twitter api/plugin", " | ".join(com_list), "You can type all of these command in the twitter buffer if you add a ':' before the command, IE:\n" ":limits\n\n" "If you don't type a command in the twitter buffer you will tweet that instead,\n" "text after 140 chars will turn red to let you know were twitter will cut off your tweet.\n\n" + weechat.color("*red") + "NOTE:\n" "There are limits on how many twitter api calls you can do, some calls are _quite_ restricted.\n" "So if you get HTML errors from the twitter lib you probably exceeded the limit\n" "you can check out your limits with the rate_limits/limits command.\n" "_Most_ commands in this plugin only uses one call. If you want to check old tweets\n" "in your home timeline it's better to request many tweets in one go.\n" "That way you don't have to request new tweets as often to go further back in the timeline.\n" "And thus you are less likely to hit the limit of requests you can do in the 15 min time window.\n" "\nYou can write newlines in your tweet with html newline ' ' (you can autocomplete it)\n" "\nThe 'number' next to the nicks in the chat window is the <id> of the tweet it's used\n" "in the some of the twitter plugin commands.\n\n" "Command desc:\n"+ "\n".join(desc_list), " || ".join(compl_list), "my_command_cb", "")
def go_main(): """Entry point.""" if not weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, 'go_unload_script', ''): return weechat.hook_command( SCRIPT_COMMAND, 'Quick jump to buffers', '[term(s)]', 'term(s): directly jump to buffer matching the provided term(s) single' 'or space dilimited list (without argument, list is displayed)\n\n' 'You can bind command to a key, for example:\n' ' /key bind meta-g /go\n\n' 'You can use completion key (commonly Tab and shift-Tab) to select ' 'next/previous buffer in list.', '%(buffers_names)', 'go_cmd', '') # set default settings 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_info('go_running', 'Return "1" if go is running, otherwise "0"', '', 'go_info_running', '')
def main(): hook = weechat.hook_modifier('weechat_print', 'unhighlight_cb', '') description = """ {script_name} lets you set up a regex for things to never highlight. To use this, set the localvar 'unhighlight_regex' on a buffer. Lines in that buffer which match will never be highlighted, even if they have your nick or match highlight_words or highlight_regex. You will need the script 'buffer_autoset.py' installed to make local variables persistent; see the examples below. Examples: Temporarily block highlights in the current buffer for lines matching 'banana': /buffer set localvar_set_unhighlight_regex banana Unhighlight SASL authentication messages for double logins: /buffer weechat /buffer set localvar_set_unhighlight_regex SaslServ /autosetbuffer add core.weechat localvar_set_unhighlight_regex SaslServ List buffers with autoset unhighlights: /{script_name} list Show this help: /{script_name} Display local variables for current buffer: /buffer localvar """.format(script_name = SCRIPT_NAME) weechat.hook_command(SCRIPT_NAME, SCRIPT_DESC, 'list', description, 'list %-', 'command_cb', '')
def main(): if not weechat.register("emote", "Keith Smiley", "1.0.0", "MIT", "Paste awesome unicode!", "", ""): return weechat.WEECHAT_RC_ERROR weechat.hook_command("emote", "Paste awesome unicode!", "", "", "|".join(mappings.keys()), "emote", "")
def main(): if not weechat.register("giphy", "Keith Smiley", "1.0.0", "MIT", "Insert a random giphy URL", "", ""): return weechat.WEECHAT_RC_ERROR weechat.hook_command("giphy", "Insert a random giphy URL", "", "", "", "giphy", "")
def main(): """ Entry point, initializes everything """ # Setup the translation table, mapping latin characters to their Unicode # fullwidth equivalents. global FW_TABLE FW_TABLE = dict(zip(range(0x21, 0x7F), range(0xFF01, 0xFF5F))) # Handle space specially. FW_TABLE[0x20] = 0x3000 weechat.register( SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESCRIPTION, "", # Shutdown callback function "", # Charset (blank for utf-8) ) # Command callbacks weechat.hook_command( # command name "fw", # description "Translates latin characters to their fullwidth equivalents.", # arguments "text", # description of arguments " text: text to be full-width'd", # completions "", "fw_cb", "")
def main(): """ Entry point, initializes everything """ weechat.register( SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESCRIPTION, "", # Shutdown callback function "", # Charset (blank for utf-8) ) # Default values for settings default_settings = { 'dbfile': os.path.join( weechat.info_get("weechat_dir", ""), "emojis-db.dat") } # Apply default configuration values if anything is unset for option, default in default_settings.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default) # Hook callbacks weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "configuration_cb", "") weechat.hook_command_run("/input return", "transform_cb", "") weechat.hook_command_run("/input complete*", "complete_cb", "") #weechat.hook_modifier("input_text_display", "collapse_cb", "") # Command callbacks weechat.hook_command( # command name SCRIPT_NAME, # description " display :common_name: with its emoji equivalent", # arguments "reload" " || add <name> <emoji>" " || show <emoji>", # description of arguments " name: emoji name, sans colons\n" "emoji: text that replaces :name:\n", # completions "reload || add || show %(emoji_name)", "emojis_cb", "") weechat.hook_completion("emoji_name", "Emoji name", "emoji_name_completion_cb", "") dbfile = weechat.config_get_plugin("dbfile") weechat.prnt("", "%s: Loading emojis from %s" % (SCRIPT_NAME, dbfile)) try: load_emojis(dbfile) except IOError as e: weechat.prnt("", "%s%s: Database file %s is missing or inaccessible." \ % (weechat.prefix("error"), SCRIPT_NAME, dbfile)) raise e # TODO: handle this better instead of brutally aborting
def init_script(): weechat.hook_command( "weecat", "open a new buffer reading a given file", "", "", "", "weecat_command_cb", "" )
def main(): if distutils.spawn.find_executable("urlview") is None: return weechat.WEECHAT_RC_ERROR if not weechat.register("urlview", "Keith Smiley", "1.0.2", "MIT", "Use urlview on the current buffer", "", ""): return weechat.WEECHAT_RC_ERROR weechat.hook_command("urlview", "Pass the current buffer to urlview", "", "", "", "urlview", "")
def main(): if not weechat.register("imgur", "Keith Smiley", "1.0.0", "MIT", "Upload an image to imgur", "", ""): return weechat.WEECHAT_RC_ERROR if not weechat.config_get_plugin(CLIENT_ID): weechat.config_set_plugin(CLIENT_ID, "Set imgur client ID") weechat.hook_command("imgur", "Pass the current buffer to urlview", "", "", "filename", "imgur", "")
def main(): """Main entry""" weechat.register(NAME, AUTHOR, VERSION, LICENSE, DESC, '', '') weechat.hook_completion('replacer_plugin', 'Try to match last word with ' 'those in replacement map keys, and replace it ' 'with value.', 'replace_cb', '') weechat.hook_completion('completion_cb', 'Complete replacement map keys', 'completion_cb', '') weechat.hook_command(COMMAND, DESC, "[add <word> <text>|del <word>]", __doc__ % {"command": COMMAND}, 'add|del %(completion_cb)', 'replace_cmd', '')
def main(): """Main""" if not weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC,'', ''): return for option, (default_value, description) in settings.items(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) if description: weechat.config_set_desc_plugin(option, description) weechat.hook_command(SCRIPT_COMMAND, SCRIPT_DESC, '', '', '%(buffers_names)', 'np_cb', '')
def main(): """ Entry point, initializes everything """ weechat.register( SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESCRIPTION, "", # Shutdown callback function "", # Charset (blank for utf-8) ) # Default values for settings default_settings = { 'dbfile': os.path.join( weechat.info_get("weechat_dir", ""), "emojis-db.dat") } # Apply default configuration values if anything is unset for option, default in default_settings.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default) # Hook callbacks weechat.hook_config( "plugins.var.python." + SCRIPT_NAME + ".*", "configuration_cb", "") weechat.hook_command_run("/input return", "transform_cb", "") weechat.hook_command_run("/input complete*", "complete_cb", "") # Command callbacks weechat.hook_command( "reloademojis", "reload emojis from file", "", "", "", "reload_emojis_cb", "") dbfile = weechat.config_get_plugin("dbfile") weechat.prnt("", "%s: Loading emojis from %s" % (SCRIPT_NAME, dbfile)) try: load_emojis(dbfile) except IOError as e: weechat.prnt( "", "%s%s: Database file %s is missing or inaccessible." % (weechat.prefix("error"), SCRIPT_NAME, dbfile)) raise e # TODO: handle this better instead of brutally aborting
def main(): if not init(): return weechat.hook_command(SCRIPT_COMMAND, SCRIPT_DESC, "[cmd1 | cmd2]", " cmd1: comand1\n" " cmd2: command2\n", "cmd1 example", "bee_cmd", "") weechat.bar_item_new(bar_item, "bee_item_cb", ""); weechat.bar_new(bar_name, "on", "0", "root", "", "top", "horizontal", "vertical", "0", "0", "default", "default", "default", "0", bar_item); return
def main_weechat(): """Main function, called only in WeeChat.""" if not weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): return theme_config_init() theme_config_read() theme_init() weechat.hook_command( SCRIPT_COMMAND, 'WeeChat theme manager', 'list [<text>] || info|show [<theme>] || install <theme>' ' || installfile <file> || update || undo || backup || save <file>' ' || restore || export [-white] <file>', ' list: list themes (search text if given)\n' ' info: show info about theme (without argument: for current ' 'theme)\n' ' show: show all options in theme (without argument: for ' 'current theme)\n' ' install: install a theme from repository\n' 'installfile: load theme from a file\n' ' update: download and unpack themes in themes directory\n' ' undo: undo last theme install\n' ' backup: backup current theme (by default in ' '~/.weechat/themes/_backup.theme); this is done the first time script ' 'is loaded\n' ' save: save current theme in a file\n' ' restore: restore theme backuped by script\n' ' export: save current theme as HTML in a file (with "-white": ' 'use white background in HTML)\n\n' 'Examples:\n' ' /' + SCRIPT_COMMAND + ' save /tmp/flashcode.theme => save current ' 'theme', 'list' ' || info %(filename)' ' || show %(filename)' ' || install %(themes)' ' || installfile %(filename)' ' || update' ' || undo' ' || save %(filename)' ' || backup' ' || restore' ' || export -white|%(filename) %(filename)', 'theme_cmd', '')
def AddCommand(): TRIV['commands']['main']['hook'] = weechat.hook_command(TRIV['commands']['main']['command'], TRIV['commands']['main']['description'], TRIV['commands']['main']['args'], TRIV['commands']['main']['args_description'], TRIV['commands']['main']['completion'], TRIV['commands']['main']['callback'], TRIV['commands']['main']['callback_data']) return weechat.WEECHAT_RC_OK
def init(self): if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): global SAVEPATH SAVEPATH = os.path.join(weechat.info_get('weechat_dir',''),'darktower','adfilter') if not os.path.exists(SAVEPATH): os.makedirs(SAVEPATH) self.saveFile = os.path.join(SAVEPATH,'adfilter.DT') self.exceptFile = os.path.join(SAVEPATH,'AFexceptions.DT') weechat.hook_command("adfilter", "Dark Tower AdFilter Commands", "[COMMANDS]", "[COMMANDS DETAIL]", "[COMPLETION]", "AdFilter", "command_cb:") weechat.hook_modifier("irc_in_PRIVMSG", "AdFilter","privmsg_event:") self.loadAds() self.loadExceptions()
def loadCommand(self,cmd): cmd.wc = self pointer = weechat.hook_command(cmd.name, cmd.title, cmd.usage, cmd.help, cmd.autocomplete, cmd._callback(), "") self.msg("Loaded Command: %s" % cmd.displayName())
def init_script(): global default_settings for option, default_value in default_settings.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) weechat.hook_command( "weemustfeed", "open/switch to weemustfeed buffer", "", "", "", "weemustfeed_command_cb", "" ) weechat.hook_config( "plugins.var.python.weemustfeed.interval", "weemustfeed_reset_timer_cb", "" )
def ircrypt_init(): # Initialize configuration ircrypt_config_init() ircrypt_config_read() # Look for GnuPG binary if weechat.config_string(weechat.config_get('ircrypt.general.binary')): # Initialize public key authentification ircrypt_gpg_init() # Register Hooks weechat.hook_modifier('irc_in_notice', 'ircrypt_notice_hook', '') weechat.hook_command('ircrypt-keyex', 'Commands of the Addon IRCrypt-keyex', '[list] ' '| remove-public-key [-server <server>] <nick> ' '| start [-server <server>] <nick> ', SCRIPT_HELP_TEXT, 'list ' '|| remove-public-key %(nicks)|-server %(irc_servers) %- ' '|| start %(nicks)|-server %(irc_servers) %- ', 'ircrypt_command', '') else: ircrypt.ircrypt_error('GnuPG not found', weechat.current_buffer())
def hook(self): assert not self._pointer, \ "There's already a hook pointer, unhook first (%s)" %self.command self._callback = callback(self.callback) pointer = weechat.hook_command(self.command, self.description, self.usage, self.help, self.completion, self._callback, '') if pointer == '': raise Exception, "hook_command failed: %s %s" %(SCRIPT_NAME, self.command) self._pointer = pointer
def main(): at_config('load') # hook our config weechat.hook_config(STRIP_VAR+'*','at_config','') # hook the nick complete weechat.hook_command_run('/input complete_next', 'at_completion', '') # hook the /atcomplete weechat.hook_command('atcomplete','manage @nick completion plugin', '[enable|disable|toggle] ' ' | [servers [list | add name | del name]]' ' | [buffers [list | add name | del name]]', 'args desc', 'status %-' ' || enable %-' ' || disable %-' ' || toggle %-' ' || server list|add|del %(buffers_names)' ' || buffer list|add|del %(buffers_names)' , 'at_control','') # hook the completetion for /atcomplete weechat.hook_completion('plugin_at_completion','@nick completion','at_complete','')
def main(): version = weechat.info_get('version_number', '') or 0 if int(version) < 0x00030600: print_error('script needs version 0.3.6 or higher') weechat.command('', "/wait 1ms /python unload %s" % SCRIPT_NAME) return init_config() description = """ {script_name} can make sure that when switching to a buffer it appears only in a particular window. To trigger this behaviour set the localvar 'stick_buffer_to_window' to the desired window number. You will need the script 'buffer_autoset.py' installed to make local variables persistent; see the examples below. Examples: Temporarily stick the current buffer to window 3: /buffer set localvar_set_stick_buffer_to_window 3 Stick buffer #weechat to window 2: /buffer #weechat /buffer set localvar_set_stick_buffer_to_window 2 /buffer_autoset add irc.freenode.#weechat stick_buffer_to_window 2 Set the default stick-to window to window 5: /set plugins.var.python.{script_name}.default_stick_window 5 List buffers with persistent stickiness: /{script_name} list Show this help: /{script_name} help Display local variables for current buffer: /buffer localvar """.format(script_name = SCRIPT_NAME) weechat.hook_command(SCRIPT_NAME, SCRIPT_DESC, 'list', description, 'list %-', 'cmd_cb', '') weechat.hook_command_run('/buffer *', 'buffer_switch_cb', '') weechat.hook_command_run('/input jump_smart', 'buffer_switch_cb', '')
def main(): if not weechat.register('hipchat', 'Joakim Recht <*****@*****.**>', '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', '')
def test_hooks(): """Test function hook_command.""" # hook_completion / hook_completion_args / and hook_command hook_cmplt = weechat.hook_completion('SCRIPT_NAME', 'description', 'completion_cb', 'completion_data') hook_cmd = weechat.hook_command('cmd' + 'SCRIPT_NAME', 'description', 'arguments', 'description arguments', '%(' + 'SCRIPT_NAME' + ')', 'command_cb', 'command_data') weechat.command('', '/input insert /cmd' + 'SCRIPT_NAME' + ' w') weechat.command('', '/input complete_next') # hook_command_run hook_cmd_run = weechat.hook_command_run('/cmd' + 'SCRIPT_NAME' + '*', 'command_run_cb', 'command_run_data') weechat.command('', '/input return') weechat.unhook(hook_cmd_run) weechat.unhook(hook_cmd) weechat.unhook(hook_cmplt)
def jmh_hook_commands_and_completions(): """ Hook commands and completions. """ # prototype: hook = weechat.hook_command(command, description, args, args_description, # completion, callback, callback_data) weechat.hook_command(SCRIPT_COMMAND, SCRIPT_DESC, "[ on | off | log | verbose [on|off]", " on: enable jabber_message_handler\n" " off: disable jabber_message_handler\n" " log: name of events log file\n" "verbose: toggle verbose on/off\n" "\n" "Without an argument, current settings are displayed.\n" "\n" "Examples:\n" "List settings: /jabber_message_handler\n" " Enable : /jabber_message_handler on\n" " Disable : /jabber_message_handler off\n" " Set log: /jabber_message_handler log /path/to/events.log\n" " Verbose on: /jabber_message_handler verbose on\n" " Verbose off: /jabber_message_handler verbose off\n", "log " " || off" " || on" " || verbose on|off", "jmh_cmd", "") weechat.hook_command('clr', 'Clear jabber events log.', '', "Usage: /clr", '', 'jmh_cmd_clr', ''); weechat.hook_command('jabber_echo_message', 'Echo message in jabber buffer.', '', "Usage: /jabber_echo_message server message", '%(jabber_servers)', 'jmh_cmd_jabber_echo_message', ''); weechat.hook_completion("jabber_servers", "list of jabber servers", "jmh_completion_servers", "")
def timer_cb(data, remaining_calls): split = data.split('[split]') weechat.command(split[0], split[1].replace('%n', nicks[0])) nicks.pop(0) return weechat.WEECHAT_RC_OK def masshl_cmd_cb(data, buffer, args): global nicks server = weechat.buffer_get_string(buffer, 'localvar_server') channel = weechat.buffer_get_string(buffer, 'localvar_channel') nicklist = weechat.infolist_get('irc_nick', '', server + ',' + channel) while weechat.infolist_next(nicklist): nicks.append(weechat.infolist_string(nicklist, 'name')) weechat.infolist_free(nicklist) del server, channel, nicklist nicks.pop(0) if args[:2] == '-1': weechat.command(buffer, ', '.join(nicks)) else: weechat.hook_timer(100, 0, len(nicks), 'timer_cb', '[split]'.join( (buffer, args))) return weechat.WEECHAT_RC_OK if weechat.register('masshl', 'acidvegas', '1.0', 'ISC', 'mass hilight all nicks in a channel', '', ''): weechat.hook_command('masshl', 'mass hilight all nicks in a channel', '', '', '', 'masshl_cmd_cb', '')
weechat.hook_command( SCRIPT_COMMAND, SCRIPT_DESC, 'start|restart|stop|status || clear', ' start: start server\n' 'restart: restart server\n' ' stop: stop server\n' ' status: display status of server\n' ' clear: remove all URLs from list\n\n' 'Without argument, this command opens new buffer with list of ' 'URLs.\n\n' 'Initial setup:\n' ' - by default, script will listen on a random free port, ' 'you can force a port with:\n' ' /set plugins.var.python.urlserver.http_port "1234"\n' ' - you can force an IP or custom hostname with:\n' ' /set plugins.var.python.urlserver.http_hostname ' '"111.22.33.44"\n' ' - it is strongly recommended to restrict IPs allowed and/or ' 'use auth, for example:\n' ' /set plugins.var.python.urlserver.http_allowed_ips ' '"^(123.45.67.89|192.160.*)$"\n' ' /set plugins.var.python.urlserver.http_auth ' '"user:password"\n' ' - if you do not like the default HTML formatting, you can ' 'override the CSS:\n' ' /set plugins.var.python.urlserver.http_css_url ' '"http://example.com/sample.css"\n' ' See https://raw.github.com/FiXato/weechat_scripts/master/' 'urlserver/sample.css\n' ' - 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', '')
# Set up script options. for option, value in vimode_settings.items(): if weechat.config_is_set_plugin(option): vimode_settings[option] = weechat.config_get_plugin(option) else: weechat.config_set_plugin(option, value[0]) vimode_settings[option] = value[0] weechat.config_set_desc_plugin( option, "%s (default: \"%s\")" % (value[1], value[0])) # Warn the user about possible problems if necessary. if not weechat.config_string_to_boolean(vimode_settings['no_warn']): check_warnings() # Create bar items and setup hooks. weechat.bar_item_new("mode_indicator", "cb_mode_indicator", '') weechat.bar_item_new("cmd_text", "cb_cmd_text", '') weechat.bar_item_new("vi_buffer", "cb_vi_buffer", '') vi_cmd = weechat.bar_new("vi_cmd", "off", "0", "root", '', "bottom", "vertical", "vertical", "0", "0", "default", "default", "default", "0", "cmd_text") weechat.hook_config('plugins.var.python.%s.*' % SCRIPT_NAME, 'cb_config', '') weechat.hook_signal("key_pressed", "cb_key_pressed", '') weechat.hook_signal("key_combo_default", "cb_key_combo_default", '') weechat.hook_command( "vimode", SCRIPT_DESC, "[help | bind_keys [--list]]", " help: show help\n" "bind_keys: unbind problematic keys, and bind" " recommended keys to use in WeeChat\n" " --list: only list changes", "help || bind_keys |--list", "cb_vimode_cmd", '')
if players: players.sort() err = 'running players: %s' % ', '.join(players) else: err = 'no MPRIS v2 players are running' v1_players = [p for p in list_players(BUS_NAME_PREFIX_V1) if '.' not in p] if v1_players: err += ' (I found "%s", but it only supports MPRIS v1)' \ % ('" and "'.join(v1_players)) if err: weechat.prnt(buffer, 'np: %s' % err) else: weechat.prnt(buffer, 'np: %s' % msg) weechat.command(buffer, 'np: %s' % msg) return weechat.WEECHAT_RC_OK if __name__ == '__main__': weechat.hook_command('np', 'Print information on the currently played song', '', '', '', 'print_info', '') if not weechat.config_is_set_plugin('default_player'): weechat.config_set_plugin('default_player', '') weechat.config_set_desc_plugin('default_player', 'Player name to use for "/np" (default: "", shows a list)')
# Check the config value for opt, def_val in settings.items(): if not w.config_is_set_plugin(opt): w.config_set_plugin(opt, def_val) else: # Move the saved config values into the dict configp = w.config_get('plugins.var.python.otc-auth.%s' % opt) config_val = w.config_string(configp) settings[opt] = config_val # Create the command w.hook_command( 'otc-auth' , 'Authenticate with gribble bot in #bitcoin-otc.' , '[username] [password timeout]' , 'Currently only supports gpg authentication.\n' 'Requires a username if the name you auth\n' 'with is different from your nick on freenode.\n\n' 'Password timeout is the number of seconds you\n' 'have to enter in your private key\'s password.\n' 'Requires the installation of shell.py:\n' ' /script install shell.py\n\n' 'After execution, use Ctrl+L to reset your screen.\n' , '' , 'otc_auth_cmd' , '' ) # Get notifications of gribble query w.hook_print('', 'irc_privmsg', 'http://bitcoin-otc.com', 1, 'priv_msg_cb', '')
# unhide all buffers when script unloads def shutdown_cb(): weechat.command('', '/buffer unhide -all') return weechat.WEECHAT_RC_OK # ================================[ main ]=============================== if __name__ == "__main__": global version if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, 'shutdown_cb', ''): weechat.hook_command( SCRIPT_NAME, SCRIPT_DESC, '', "Note: channels from disconnected server will be displayed and won't hidden automatically.\n" 'Use the /fset plugin to configure script: /fset collapse_channel', '', '', '') version = weechat.info_get('version_number', '') or 0 init_options() weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '') if OPTIONS['activity'].lower() == 'no' or OPTIONS['activity'].lower( ) == 'off' or OPTIONS['activity'].lower() == '0': # hide all channels weechat.command( '', '/allchan -exclude=%s /buffer hide' % OPTIONS['channel_exclude']) # show channel from current server
if args == "": # no args given. quit return weechat.WEECHAT_RC_OK argv = args.strip().split(" ") if argv[0].lower() == 'save': save_stored_query_buffers_to_file() return weechat.WEECHAT_RC_OK # ================================[ main ]=============================== if __name__ == '__main__': if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): version = weechat.info_get('version_number', '') or 0 if int(version) >= 0x00030700: weechat.hook_command(SCRIPT_NAME, SCRIPT_DESC, 'save', 'save : manual saving of the query list\n', '', 'hook_command_cb', '') stored_query_buffers_per_server = get_stored_list_of_query_buffers( ) for (server_name, channels) in get_current_query_buffers().items(): # Reopen the buffers for the channels in the servers we already have open: open_stored_query_buffers_for_server(server_name) stored_query_buffers_per_server.setdefault( server_name, set([])) debug_print( "Already have %s channels for server %s: %s" % (len(stored_query_buffers_per_server[server_name]), server_name, ','.join( stored_query_buffers_per_server[server_name])))
"import sys, requests\n" "r = requests.get('https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=%(username)s&api_key=618f9ef38b3d0fed172a88c45ae67f33&format=json&limit=1&extended=0')\n" "if not r.status_code == requests.codes.ok:\n" " print >>sys.stderr, 'Could not fetch Last.fm RSS feed.',\n" " exit()\n" "json = r.json()['recenttracks']['track'][0]\n" "print('{} – {}'.format(json['artist']['#text'], json['name'])),\n" "\"" % {"username" : weechat.config_get_plugin('lastfm_username')}, 10000, "lastfm_cb", "") return weechat.WEECHAT_RC_OK def lastfm_cb(data, command, rc, stdout, stderr): global cmd_hook_process, cmd_buffer, cmd_stdout, cmd_stderr cmd_stdout += stdout cmd_stderr += stderr if int(rc) >= 0: if cmd_stderr != "": weechat.prnt(cmd_buffer, "%s" % cmd_stderr) if cmd_stdout != "": weechat.command(cmd_buffer, weechat.config_get_plugin("command") % cmd_stdout.replace('\n','')) cmd_hook_process = "" return weechat.WEECHAT_RC_OK hook = weechat.hook_command( "lastfm", "Sends your latest Last.fm track to the current buffer. Before using /lastfm, set your Last.fm username like this:\n\n" " /set plugins.var.python.lastfm.lastfm_username yourusername\n\n" "You can also customize the command that will be sent to the buffer like this:\n\n" " /set plugins.var.python.lastfm.command Right now I'm listening to %s\n", "", "", "", "lastfm_cmd", "")
# write counters weechat.prnt( '', 'docgen: {0}: {1} files, {2} updated' ''.format(locale, num_files['total1'], num_files_updated['total1'])) weechat.prnt( '', 'docgen: total: {0} files, {1} updated' ''.format(num_files['total2'], num_files_updated['total2'])) return weechat.WEECHAT_RC_OK def docgen_completion_cb(data, completion_item, buf, completion): """Callback for completion.""" for locale in LOCALE_LIST: weechat.hook_completion_list_add(completion, locale, 0, weechat.WEECHAT_LIST_POS_SORT) return weechat.WEECHAT_RC_OK if __name__ == '__main__' and IMPORT_OK: if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): weechat.hook_command( SCRIPT_COMMAND, 'Documentation generator.', '[locales]', 'locales: list of locales to build (by default ' 'build all locales)', '%(docgen_locales)|%*', 'docgen_cmd_cb', '') weechat.hook_completion('docgen_locales', 'locales for docgen', 'docgen_completion_cb', '') if not weechat.config_is_set_plugin('path'): weechat.config_set_plugin('path', DEFAULT_PATH)
weechat.hook_command("cron", "Manage jobs in crontab", "list || add <minute> <hour> <monthday> <month> <weekday> <repeat> <buffer> <command> || " "del <number>|-all || exec <number> || reload|save", " list: display jobs in crontab\n" " add: add a job in crontab\n" " minute: minute (0-59)\n" " hour: hour (0-23)\n" "monthday: day of month (1-31)\n" " month: month (1-12)\n" " weekday: day of week (0-6, or name: " "sun (0), mon (1), tue (2), wed (3), thu (4), fri (5), sat (6))\n" " repeat: number of times job will be executed, must be >= 1 or special value * (repeat forever)\n" + str_buffer + str_commands + " del: remove job(s) from crontab\n" " number: job number\n" " -all: remove all jobs\n" " exec: execute a command for a job (useful for testing command)\n" " reload: reload crontab file (automatic by default)\n" " save: save current crontab to file (automatic by default)\n\n" "Format for time and date is similar to crontab, see man 5 crontab.\n\n" "Examples:\n" " Display \"short drink!\" at 12:00 each day:\n" " /cron add 0 12 * * * * core.weechat print short drink!\n" " Same example with python code:\n" " /cron add 0 12 * * * * core.weechat python weechat.prnt(\"\", \"short drink!\")\n" " Set away status on all servers at 23:30:\n" " /cron add 30 23 * * * * core.weechat command /away -all I am sleeping\n" " Remove away status on all servers at 07:00:\n" " /cron add 0 7 * * * * core.weechat command /away -all I am sleeping\n" " Set away status on all servers at 10:00 every sunday:\n" " /cron add 0 10 * * sun * core.weechat command /away -all I am playing tennis\n" " Say \"hello\" on IRC channel #private at 08:00 from monday to friday:\n" " /cron add 0 8 * * mon-fri * irc.freenode.#private command hello\n" " Display \"wake up!\" at 06:00 next monday, only one time, with highlight:\n" " /cron add 0 6 * * mon 1 core.weechat print_hl wake up!\n" " Delete first entry in crontab:\n" " /cron del 1", "list" " || add %(cron_time) %(cron_time) %(cron_time) " "%(cron_time) %(cron_time) %(cron_repeat) %(cron_buffer) " "%(cron_keyword) %(cron_commands)" " || del %(cron_number)|-all" " || exec %(cron_number)" " || reload" " || save", "cron_cmd_cb", "")
# colors color_delimiter = weechat.color('chat_delimiters') color_chat_nick = weechat.color('chat_nick') color_reset = weechat.color('reset') # pretty [SCRIPT_NAME] script_nick = '%s[%s%s%s]%s' % (color_delimiter, color_chat_nick, SCRIPT_NAME, color_delimiter, color_reset) weechat.hook_signal('*,irc_in2_311', 'whois_cb', '') # /whois weechat.hook_signal('*,irc_in2_314', 'whois_cb', '') # /whowas weechat.hook_command('country', cmd_country.__doc__, 'update | (nick|ip|uri)', " update: Downloads/updates ip database with country codes.\n" "nick, ip, uri: Gets country and local time for a given ip, domain or nick.", 'update||%(nick)', 'cmd_country', '') # settings for opt, val in settings.items(): if not weechat.config_is_set_plugin(opt): weechat.config_set_plugin(opt, val) if not check_database(): say("IP database not found. You must download a database with '/country update' before " "using this script.") if not pytz_module and get_config_boolean('show_localtime'): error( "pytz module isn't installed, local time information is DISABLED. " "Get it from http://pytz.sourceforge.net or from your distro packages "
## Example As an example, consider the following rule list: 0: core = 0 1: irc = 2 2: * = 1 3: irc.server.*.#* = 1 4: irc.server.*.* = 0 Rule 0 ensures the core buffer is always sorted first. Rule 1 sorts IRC buffers last and rule 2 puts all remaining buffers in between the two. Rule 3 and 4 would make no sense with the group_irc option off. With the option on though, these rules will sort private buffers before regular channel buffers. Rule 3 matches channel buffers and assigns them a higher score, while rule 4 matches the buffers that remain and assigns them a lower score. The same effect could also be achieved with a single rule: irc.server.*.[^#]* = 0 ''' command_completion = 'sort||rules list|add|insert|update|delete|move|swap||replacements list|add|insert|update|delete|move|swap' if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): config = Config('autosort') weechat.hook_config('autosort.*', 'on_config_changed', '') weechat.hook_command('autosort', command_description, '', '', command_completion, 'on_autosort_command', 'NULL') on_config_changed()
except: print "Script must be run under weechat. http://www.weechat.org" import_ok = False import re weechat.register (NAME, AUTHOR, VERSION, "GPL2", "Auto authentification while changing nick", "", "") weechat.hook_signal("*,irc_in2_notice", "auth_notice_check", "") weechat.hook_command( "autoauth", "Auto authentification while changing nick", "{ add $nick $pass [$server=current] | del $nick [$server=current] | list | cmd [$command [$server=current]] | ns [$Nick[!username[@host]]] [$server=current] }", " add : add authorization for $nick with password $pass for $server\n" " del : del authorization for $nick for $server\n" " list : list all authorization settings\n" " cmd : command(s) (separated by '|') to run when identified for $server\n" " %n will be replaced by current nick in each command\n" " ns : set NickServ mask (or part of mask) for $server, the NickServ nick is mandatory", "add|del|list|cmd %- %S %S", "auth_command", "" ) def auth_cmdlist(): cmd = '' cmds = weechat.config_get_plugin("commands") if cmds == '': weechat.prnt("", "[%s] commands (empty)" % (NAME)) else: weechat.prnt("", "[%s] commands (list)" % (NAME)) for c in cmds.split("####"):
weechat.hook_hsignal("500|buffer_open_full_name", "buffer_open_full_name_table_cb", "") weechat.hook_hsignal("500|buffer_open_full_name", "buffer_open_full_name_irc_cb", "") weechat.hook_signal("irc_server_connected", "irc_server_connected_cb", "") weechat.hook_command( SCRIPT_COMMAND, SCRIPT_DESC, """closed [-noswitch|-list] || [-noswitch] <full name>""", """ closed: open most recently closed buffer closed -list: list most recently closed buffers -noswitch: try not to switch to new buffer Without subcommand, this command opens a buffer with given full name. Option "{prefix}.max_closed" specifies the number of most recently closed buffers that are remembered. If option "{prefix}.layout_apply" is on and "/layout apply" is executed, closed buffers in the layout are opened.""" .format(prefix="plugins.var.python.{}".format(SCRIPT_NAME)), """closed -noswitch|-list %- || -noswitch""".replace("\n", ""), "command_cb", "") weechat.hook_signal("buffer_closing", "buffer_closing_cb", "") weechat.hook_command_run("/layout apply*", "layout_apply_cb", "") for option, value in SETTINGS.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, value[0])
def cstrip(text): return weechat.string_remove_color(text, '') def bufsave_cmd(data, buffer, args): filename = weechat.buffer_get_string(buffer, 'localvar_server') + '.' + weechat.buffer_get_string(buffer, 'localvar_channel')[1:] + '-' + time.strftime('%y_%m_%d') + '.log' filename = weechat.string_eval_path_home('%h/logs/' + filename, {}, {}, {}) try: fp = open(filename, 'w') except: weechat.prnt('', 'Error writing to target file!') return weechat.WEECHAT_RC_OK own_lines = weechat.hdata_pointer(weechat.hdata_get('buffer'), buffer, 'own_lines') if own_lines: line = weechat.hdata_pointer(weechat.hdata_get('lines'), own_lines, 'first_line') hdata_line = weechat.hdata_get('line') hdata_line_data = weechat.hdata_get('line_data') while line: data = weechat.hdata_pointer(hdata_line, line, 'data') if data: date = weechat.hdata_time(hdata_line_data, data, 'date') if not isinstance(date, str): date = time.strftime('%F %T', time.localtime(int(date))) fp.write('{0} {1} {2}\n'.format(date, cstrip(weechat.hdata_string(hdata_line_data, data, 'prefix')), cstrip(weechat.hdata_string(hdata_line_data, data, 'message')))) line = weechat.hdata_move(hdata_line, line, 1) fp.close() return weechat.WEECHAT_RC_OK if weechat.register('bufsave', 'acidvegas', '1.0', 'ISC', 'save buffer to file', '', ''): weechat.hook_command('bufsave', 'save current buffer to a file', '[filename]', 'filename: target file (must not exist)\n', '%f', 'bufsave_cmd', '')
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"
weechat.hook_command("twitch", SCRIPT_DESC, "", " settings:\n" " plugins.var.python.twitch.servers (default: twitch)\n" " plugins.var.python.twitch.prefix_nicks (default: 1)\n" "\n\n" " This script checks stream status of any channel on any servers listed\n" " in the \"plugins.var.python.twitch.servers\" setting. When you switch\n" " to a buffer it will display updated infomation about the stream in the\n" " title bar. Typing '/twitch' in a buffer will also fetch updated infomation.\n" " '/whois nick' will lookup user info and display it in current buffer.\n\n" " Option \"plugins.var.python.twitch.servers\" controls\n" " what server this script will work on. The default is twitch\n" " but you can have multiples separated by a space.\n" " /set plugins.var.python.twitch.servers twitch twitchcopy\n" "\n\n" " This script also will prefix users nicks (@ for mod, % for sub,\n" " and ~ for broadcaster). This will break the traditional function\n" " of /ignore add nightbot and will require you to prefix nicks if you\n" " want to ignore someone /ignore add re:[~@%]{0,3}nightbot should ignore\n" " a nick with all or none of the prefixes used by this script.\n" " NOTE: This may cause high cpu usage in very active chat and/or on slower cpus.\n" " This can also be disabled by setting\n /set plugins.var.python.twitch.prefix_nicks off\n" "\n\n" " Required server settings:\n" " /server add twitch irc.twitch.tv\n" " /set irc.server.twitch.capabilities \"twitch.tv/membership,twitch.tv/commands,twitch.tv/tags\"\n" " /set irc.server.twitch.nicks \"My Twitch Username\"\n" " /set irc.server.twitch.password \"oauth:My Oauth Key\"\n" "\n" " If you do not have a oauth token one can be generated for your account here\n" " https://twitchapps.com/tmi/\n" "\n" " This script also has whisper support that works like a standard query. \"/query user\"\n\n", "", "twitch_main", "")
SCRIPT_AUTHOR = "xt <*****@*****.**>" SCRIPT_VERSION = "0.3.1" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = "Configure autojoin for all servers according to currently joined channels" SCRIPT_COMMAND = "autojoin" # script options settings = { "autosave": "off", } if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): w.hook_command( SCRIPT_COMMAND, SCRIPT_DESC, "[--run]", " --run: actually run the commands instead of displaying\n", "--run", "autojoin_cb", "") # w.hook_signal('*,irc_in2_join', 'autosave_channels_on_activity', '') # w.hook_signal('*,irc_in2_part', 'autosave_channels_on_activity', '') w.hook_signal('quit', 'autosave_channels_on_quit', '') # Init everything for option, default_value in settings.items(): if w.config_get_plugin(option) == "": w.config_set_plugin(option, default_value) def autosave_channels_on_quit(signal, callback, callback_data): ''' Autojoin current channels ''' if w.config_get_plugin(option) != "on":
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", "")
global cs_settings # Set default settings for option, default_value, description in cs_settings: if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) version = weechat.info_get("version_number", "") or 0 if int(version) >= 0x00030500: weechat.config_set_desc_plugin(option, description) if __name__ == "__main__" and import_ok: if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, SCRIPT_CLOSE_CB, ""): cs_set_default_settings() cs_buffer = weechat.buffer_search("python", "clone_scanner") weechat.hook_signal("*,irc_in2_join", "on_join_scan_cb", "") weechat.hook_command( SCRIPT_COMMAND, SCRIPT_DESC, "[scan] [[plugin.][network.]channel] | [advertise] | [help]", "the target_buffer can be: \n" "- left out, so the current channel buffer will be scanned.\n" "- a plain channel name, such as #weechat, in which case it will prefixed with the current network name\n" "- a channel name prefixed with network name, such as Freenode.#weechat\n" "- a channel name prefixed with plugin and network name, such as irc.freenode.#weechat\n" "See /set plugins.var.python.clone_scanner.* for all possible configuration options", " || scan %(buffers_names)" " || advertise" " || help", "cs_command_main", "")
weechat.unhook(tgt['timer']) def toggle_target(buf): if buf in targets: cancel_target(buf) else: add_target(buf) def cmd_rix(data, buf, args): args = args.split(None, 1) if len(args) == 0 or args[0].lower() == 'off': cancel_target(buf) return weechat.WEECHAT_RC_OK dur = int(float(args[0]) * 1000) if dur < 10: weechat.prnt(buf, 'too fast!') return weechat.WEECHAT_RC_ERROR add_target(buf, dur, args[1]) return weechat.WEECHAT_RC_OK if __name__ == '__main__': weechat.register(NAME, AUTHOR, VERSION, LICENSE, DESC, '', '') weechat.hook_command('rix', CMD_DESC, CMD_ARGS, CMD_ARGS_DESC, '', 'cmd_rix', '')
return weechat.WEECHAT_RC_OK def docgen_completion_cb(data, completion_item, buf, completion): """Callback for completion.""" for locale in LOCALE_LIST: weechat.completion_list_add(completion, locale, 0, weechat.WEECHAT_LIST_POS_SORT) return weechat.WEECHAT_RC_OK if __name__ == '__main__' and IMPORT_OK: if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): weechat.hook_command( SCRIPT_COMMAND, 'Documentation generator.', '[locales]', 'locales: list of locales to build (by default build all locales)', '%(docgen_locales)|%*', 'docgen_cmd_cb', os.path.dirname(__file__), ) weechat.hook_completion( 'docgen_locales', 'locales for docgen', 'docgen_completion_cb', '', )
# ================================[ main ]=============================== if __name__ == "__main__": if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): version = weechat.info_get('version_number', '') or 0 if int(version) >= 0x00030400: weechat.hook_command( SCRIPT_NAME, SCRIPT_DESC, 'add <nick> <color> || del <nick< <color> || list', 'add <nick> <color>: add a nick with its color to nick_color_force\n' 'del <nick> : delete given nick with its color from nick_color_force\n' 'list <nick> : list all forced nicks with its assigned color or optional from one nick\n\n' 'Examples:\n' ' add nick nils_2 with color red:\n' ' /' + SCRIPT_NAME + ' add nils_2 red\n' ' recolor nick nils_2 with foreground color yellow and background color blue:\n' ' /' + SCRIPT_NAME + ' add nils_2 yellow:blue\n' ' delete nick nils_2:\n' ' /' + SCRIPT_NAME + ' del nils_2\n', 'add %(nick) %(plugin_nick_colors) %-||' 'del %(plugin_force_nick) %-||' 'list %(plugin_force_nick) %-', 'nick_colors_cmd_cb', '') nick_option = nick_option_old if int(version) >= 0x01050000: nick_option = nick_option_new weechat.hook_completion('plugin_nick_colors', 'nick_colors_completion', 'nick_colors_completion_cb', '') weechat.hook_completion('plugin_force_nick', 'force_nick_colors_completion',
for option, value in samegame_settings_default.items(): if weechat.config_is_set_plugin(option): samegame_settings[option] = weechat.config_get_plugin(option) else: weechat.config_set_plugin(option, value[0]) samegame_settings[option] = value[0] weechat.config_set_desc_plugin( option, '%s (default: "%s")' % (value[1], value[0])) samegame_set_colors() # mouse support weechat.key_bind('mouse', samegame_mouse_keys) weechat.hook_hsignal('samegame_mouse', 'samegame_mouse_cb', '') # detect config changes weechat.hook_config('plugins.var.python.%s.*' % SCRIPT_NAME, 'samegame_config_cb', '') # add command weechat.hook_command( SCRIPT_COMMAND, 'Samegame.', '', 'Instructions:\n' '- click on a group of adjoining blocks of the same color to remove them from the screen\n' '- blocks that are no longer supported will fall down, and a column without any blocks will be trimmed away by other columns sliding to the left\n' '- your score is increased by (N-1)², where N is the number of blocks removed by your click\n' '- the game ends when you can not play any more.', '', 'samegame_cmd_cb', '') # if buffer already exists (after /upgrade), init samegame if weechat.buffer_search('python', 'samegame'): samegame_init()
weechat.hook_command( SCRIPT_NAME, SCRIPT_DESC, '[save] || [list]', ' save: force to save command history\n' ' list: list local buffer variable(s)\n' '\n' 'If you \"/quit\" WeeChat, the script will automatically save the command history to a file.\n' 'You can also force the script to save command history, when you close a buffer with /buffer close.\n' 'If you restart WeeChat, the command history will be restored, when buffer opens again.\n' 'To save and restore \"global\" command history, use option \"save_global\".\n' '\n' 'The command history of a buffer will be saved \"only\", if the the local variable \"save_history\" is set.\n' 'You will need script \"buffer_autoset.py\" to make a local variabe persistent (see examples, below)!!\n' '\n' 'You can use option \"save_buffer\ to save command history for *all* buffers, localvar will be ignored using\n' 'this option.\n' 'You can use following values for local variable:\n' ' command: save commands only\n' ' text: save text only (text sent to a channel buffer)\n' ' all: save commands and text\n' '\n' 'Examples:\n' ' save the command history manually (for example with /cron script or with an /trigger):\n' ' /' + SCRIPT_NAME + ' save\n' ' save and restore command history for buffer #weechat on freenode (text only):\n' ' /buffer_autoset add irc.freenode.#weechat localvar_set_save_history text\n' ' save and restore command history for weechat core buffer (commands only):\n' ' /buffer_autoset add core.weechat localvar_set_save_history command\n', 'save %-' '|| list %-', 'histman_cmd_cb', '')
w.command('', '/help ' + NAME) return w.WEECHAT_RC_OK def quit_cb(data, signal, signal_data): """save config on quit""" save_conf(None) return w.WEECHAT_RC_OK if __name__ == '__main__': if w.register(NAME, AUTHOR, VERSION, LICENSE, DESCRIPTION, "", ""): w.hook_command(NAME, DESCRIPTION, 'save [path] || load [path]', '', 'save || load', 'autoconf_cb', '') default_txt = w.gettext("default: ") # check if string is translated RE = {'option': re.compile('\s*(.*) = (.*) \(%s' % default_txt)} # set default config for option, value in SETTINGS.items(): if not w.config_is_set_plugin(option): w.config_set_plugin(option, value[0]) w.config_set_desc_plugin( option, '%s (default: "%s")' % (value[1], value[0])) if 'on' in w.config_get_plugin('autoload'): load_conf(None) if 'on' in w.config_get_plugin('autosave'): w.hook_signal('quit', 'quit_cb', '')
else: bas_config_init() bas_config_read() weechat.hook_command( SCRIPT_COMMAND, "Auto-set buffer properties when a buffer is opened", "[add buffer property value] | [del option]", " add: add a buffer/property/value in configuration file\n" " del: delete an option from configuration file\n" " buffer: name of a buffer (can start or end with \"*\" as wildcard)\n" "property: buffer property\n" " value: value for property\n" " option: name of option from configuration file\n\n" "Examples:\n" " disable timestamp on channel #weechat:\n" " /" + SCRIPT_COMMAND + " add irc.freenode.#weechat time_for_each_line 0\n" " add word \"weechat\" in highlight list on channel #savannah:\n" " /" + SCRIPT_COMMAND + " add irc.freenode.#savannah highlight_words_add weechat\n" " disable highlights from nick \"mike\" on freenode server, channel #weechat (requires WeeChat >= 0.3.4):\n" " /" + SCRIPT_COMMAND + " add irc.freenode.#weechat hotlist_max_level_nicks_add mike:2\n" " disable hotlist changes for nick \"bot\" on freenode server (all channels) (requires WeeChat >= 0.3.4):\n" " /" + SCRIPT_COMMAND + " add irc.freenode.* hotlist_max_level_nicks_add bot:-1", "add %(buffers_plugins_names)|%(buffer_autoset_current_buffer) %(buffer_properties_set)" " || del %(buffer_autoset_options)", "bas_cmd", "") weechat.hook_completion("buffer_autoset_current_buffer", "current buffer name for buffer_autoset", "bas_completion_current_buffer_cb", "")
notifications = ['highlight'] # don't have/want the weechat icon? use ichat instead # applicationIcon = Growl.Image.imageWithIconForApplication("iChat") applicationIcon = Growl.Image.imageFromPath( weechat.config_get_plugin('icon')) # Init everything for option, default_value in settings.items(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) # Hook commands to setup stickynote command hook = weechat.hook_command( "stickynote", "Set stickyness of gnotify Growl notifications", "[on|off|toggle]", "'on' makes sticky, 'off' makes not sticky, 'toggle' toggles stickyness", "on || off || toggle", "stickynote_cmd", "") def stickynote_cmd(data, buffer, args): isSticky = weechat.config_get_plugin('sticky') if (args == 'toggle'): isSticky = ('on' if isSticky == 'off' else 'off') elif (args == 'on' or args == 'off'): isSticky = args else: weechat.prnt("", "Invalid stickynote option: " + args) weechat.config_set_plugin('sticky', isSticky) weechat.prnt("", "Growl notification stickyness is " + isSticky) return weechat.WEECHAT_RC_OK
# for cmd in (purgelogs_commands.keys()): # str_commands += " " + cmd + ": " + purgelogs_commands[cmd] + "\n"; w.hook_command( "purgelogs", "delete weechatlog-files by date or size", "[age|age_ls] <days> || [size|size_ls] <in KiB> || [delete]", " size : greater than <Kib> for log-files to purge\n" " size_ls : less than <Kib> for log-files to purge\n" " age : older than <days> for log-files to purge (maximum value: 9999)\n" " age_ls : younger than <days> for log-files to purge\n" " delete : argument for security reasons\n" "\n" # str_commands + "\n" "Examples:\n" " show log-files older than 100 days\n" " /" + SCRIPT_NAME + " age 100\n" " purge log-files older than 100 days\n" " /" + SCRIPT_NAME + " age 100 delete\n" " show log-files younger than 10 days\n" " /" + SCRIPT_NAME + " age_ls 10\n" " purge log-files younger than 10 days\n" " /" + SCRIPT_NAME + " age_ls 10 delete\n" " show log-files greater than 100 KiB\n" " /" + SCRIPT_NAME + " size 100\n" " purge log-files greater than 100 KiB\n" " /" + SCRIPT_NAME + " size 100 delete\n", "age|age_ls|size|size_ls %-", "purgelogs_cb", "") w.hook_config('plugins.var.python.%s.blacklist' % SCRIPT_NAME, 'update_blacklist', '')
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"
return '%s%s%s' % (color, nick, weechat.color('reset')) if __name__ == "__main__" and import_ok: 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",
color_reset = weechat.color('reset') color_peak = weechat.color('green') color_low = weechat.color('red') color_avg = weechat.color('brown') color_bold = weechat.color('white') # pretty [chanop] script_nick = '%s[%s%s%s]%s' %(color_delimiter, color_chat_nick, SCRIPT_NAME, color_delimiter, color_reset) for opt, val in settings.iteritems(): if not weechat.config_is_set_plugin(opt): weechat.config_set_plugin(opt, val) script_load() weechat.hook_signal('*,irc_in2_join', 'join_cb', '') weechat.hook_signal('*,irc_in2_part', 'join_cb', '') weechat.hook_signal('*,irc_in2_quit', 'quit_cb', '') weechat.hook_command('chanstat', "Display channel's statistics.", '[--save | --load]', "Displays channel peak, lowest and average users for current channel.\n" " --save: forces saving the stats database.\n" " --load: forces loading the stats database (Overwriting actual values).\n", #" --print: sends /chanstat output to the current channel.", '--save|--load', 'chanstat_cmd', '') weechat.hook_command('chanstat_debug', '', '', '', '', 'cmd_debug', '') # vim:set shiftwidth=4 tabstop=4 softtabstop=4 expandtab textwidth=100:
if len(tickerArguments) >= 1: if tickerArguments[0] in VALID_CRYPTO_CURRENCIES: cryptoCurrency = tickerArguments[0] else: weechat.prnt( buffer, '%s\tInvalid crypto currency; using default %s' % (COMMAND_NICK, DEFAULT_CRYPTO_CURRENCY)) if len(tickerArguments) == 2: if tickerArguments[1] in VALID_FIAT_CURRENCIES: fiatCurrency = tickerArguments[1] else: weechat.prnt( buffer, '%s\tInvalid fiat currency; using default %s' % (COMMAND_NICK, DEFAULT_FIAT_CURRENCY)) fetchJSONTickerFor(cryptoCurrency, fiatCurrency) return weechat.WEECHAT_RC_OK # *** main *** weechat.register( 'btc_ticker', 'pr3d4t0r', '1.0', 'BSD', 'Display a crypto currency spot price ticker (BTC, LTC) in the active buffer', '', 'UTF-8') weechat.hook_command(COMMAND_NICK, 'Display Bitcoin or other crypto currency spot exchange value in a fiat currency like USD or EUR',\ '[btc|ltc|nmc [usd|eur|rur] ]', ' btc = Bitcoin\n ltc = Litecoin\n nmc = Namecoin\n usd = US dollar\n eur = euro\n rur = Russian ruble', '', 'displayCryptoCurrencyTicker', '')