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 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', '[name]', 'name: directly jump to buffer by name (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', '')
'default': weechat.color('default'), 'reset': weechat.color('reset'), 'black': weechat.color('black'), 'red': weechat.color('red'), 'green': weechat.color('green'), 'brown': weechat.color('brown'), 'yellow': weechat.color('yellow'), 'blue': weechat.color('blue'), 'magenta': weechat.color('magenta'), 'cyan': weechat.color('cyan'), 'white': weechat.color('white'), '*default': weechat.color('*default'), '*black': weechat.color('*black'), '*red': weechat.color('*red'), '*green': weechat.color('*green'), '*brown': weechat.color('*brown'), '*yellow': weechat.color('*yellow'), '*blue': weechat.color('*blue'), '*magenta': weechat.color('*magenta'), '*cyan': weechat.color('*cyan'), '*white': weechat.color('*white'), } weechat.hook_config('autosort.*', 'on_config_changed', '') weechat.hook_completion('plugin_autosort', '', 'on_autosort_complete', '') weechat.hook_command('autosort', command_description.format(**colors), '', '', command_completion, 'on_autosort_command', '') weechat.hook_info('autosort_replace', info_replace_description, info_replace_arguments, 'on_info_replace', '') weechat.hook_info('autosort_order', info_order_description, info_order_arguments, 'on_info_order', '') apply_config()
buffers = [] buffers_pos = 0 if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "go_unload_script", ""): weechat.hook_command( "go", "Quick jump to buffers", "[name]", "name: directly jump to buffer by name (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", "") for option, default_value in settings.items(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) weechat.hook_info("go_running", "Return '1' if go is running", "", "info_go_running", "") def info_go_running(data, info_name, arguments): global hooks if "modifier" in hooks: return "1" return "0" def unhook_one(hook): """ Unhook something hooked by this script """ global hooks if hook in hooks: weechat.unhook(hooks[hook]) del hooks[hook]
"go", "Quick jump to buffers", "[name]", "name: directly jump to buffer by name (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", "", ) for option, default_value in settings.items(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) weechat.hook_info("go_running", "Return '1' if go is running", "", "info_go_running", "") def info_go_running(data, info_name, arguments): global hooks if "modifier" in hooks: return "1" return "0" def unhook_one(hook): """ Unhook something hooked by this script """ global hooks if hook in hooks: weechat.unhook(hooks[hook]) del hooks[hook]
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', '') weechat.hook_info("country_search_ip", "search country of a ip address, argument must be an ip address, domainds"\ " won't work.", "<ip>", "info_search_ip", "") # settings for opt, val in settings.iteritems(): 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 "
if __name__ == '__main__': global version if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): version = weechat.info_get('version_number', '') or 0 weechat.hook_command( SCRIPT_NAME, SCRIPT_DESC, 'last_written||last_sent', 'script provide two items:\n' '"last_written", will print name of buffer you typed text last time\n' '"last_sent", will print name of buffer you sent text last time\n\n' 'You can use both items with /eval or in /key using variable "${info:last_written}" and "${info:last_sent}"\n\n' 'Example:\n' 'bind key to jump to last buffer you sent text\n' ' /key bind meta-# /eval /buffer ${info:last_sent}\n' 'creates an item for text_item.py script (item name ""ti_last_written"\n' ' /set plugins.var.python.text_item.ti_last_written "all|input_text_changed ${info:last_written} ${info:last_sent}"' '', '', '', '') weechat.bar_item_new(item_last_written, 'bar_item_last_written_cb', '') weechat.bar_item_new(item_last_sent, 'bar_item_last_sent_cb', '') weechat.hook_info('last_written', 'Return name of last buffer text was written', '', 'last_written_info_cb', '') weechat.hook_info('last_sent', 'Return name of last buffer text was sent', '', 'last_sent_info_cb', '') weechat.hook_command_run('/input return', 'input_return_cb', '') weechat.hook_signal('input_text_changed', 'input_text_changed_cb', '')
# pretty [SCRIPT_NAME] script_nick = '%s[%s%s%s]%s' % (COLOR_CHAT_DELIMITERS, COLOR_CHAT_NICK, SCRIPT_NAME, COLOR_CHAT_DELIMITERS, COLOR_RESET) # settings for opt, val in settings.iteritems(): if not weechat.config_is_set_plugin(opt): weechat.config_set_plugin(opt, val) weechat.hook_modifier('weechat_print', 'playback_cb', '') weechat.hook_info("znc-playback", "Returns the name \"<server>.<channel>\" of the playback currently "\ "in progess. Returns \"\" if there's none.", "", "info_current_playback", "") # ------------------------------------------------------------------------- # Debug if weechat.config_get_plugin('debug'): try: # custom debug module I use, allows me to inspect script's objects. import pybuffer debug = pybuffer.debugBuffer(globals(), '%s_debug' % SCRIPT_NAME) except: def debug(s, *args): if not isinstance(s, basestring): s = str(s) if args: s = s %args
'*black': weechat.color('*black'), '*red': weechat.color('*red'), '*green': weechat.color('*green'), '*brown': weechat.color('*brown'), '*yellow': weechat.color('*yellow'), '*blue': weechat.color('*blue'), '*magenta': weechat.color('*magenta'), '*cyan': weechat.color('*cyan'), '*white': weechat.color('*white'), } weechat.hook_config('autosort.*', 'on_config_changed', '') weechat.hook_completion('plugin_autosort', '', 'on_autosort_complete', '') weechat.hook_command( 'autosort', command_description.format(**colors), '', '', '%(plugin_autosort) %(plugin_autosort) ' '%(plugin_autosort) %(plugin_autosort) ' '%(plugin_autosort)', 'on_autosort_command', '') weechat.hook_info( 'autosort_replace', 'Replace all occurences of `from` with `to` in the ' 'string `text`.', 'from,to,text', 'on_info_replace', '') weechat.hook_info( 'autosort_order', 'Get a zero padded index of a value in a list of ' 'possible values. If the value is not found, the index ' 'for `*` is returned. If there is no `*` in the list, ' 'the highest index + 1 is returned.', 'value,first,second,third,...', 'on_info_order', '') apply_config()
# 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', '') weechat.hook_info("country_search_ip", "search country of a ip address, argument must be an ip address, domainds"\ " won't work.", "<ip>", "info_search_ip", "") # settings for opt, val in settings.iteritems(): 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. "