def main(): if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): version = int(weechat.info_get('version_number', '')) or 0 # unset unused setting from older versions of script if weechat.config_is_set_plugin('display_unit'): weechat.prnt("", "Option plugins.var.python.bandwidth.display_unit no longer used, removing.") weechat.config_unset_plugin('display_unit') # set default settings for option in SCRIPT_SETTINGS.keys(): if not weechat.config_is_set_plugin(option): value = SCRIPT_SETTINGS[option][0] if isinstance(value, str): pass elif isinstance(value, bytes): pass elif isinstance(value, unicode): value = value.encode('utf8') weechat.config_set_plugin(option, value) if version >= 0x00030500: weechat.config_set_desc_plugin(option, SCRIPT_SETTINGS[option][1]) # ensure sane refresh_rate setting if int(weechat.config_get_plugin('refresh_rate')) < 1: weechat.prnt("", "{}Invalid value for option plugins.var.python.bandwidth.refresh_rate, setting to default of {}".format(weechat.prefix("error"), SCRIPT_SETTINGS['refresh_rate'][0])) weechat.config_set_plugin('refresh_rate', SCRIPT_SETTINGS['refresh_rate'][0]) # create the bandwidth monitor bar item weechat.bar_item_new('bandwidth', 'bandwidth_item_cb', '') # update it every plugins.var.python.bandwidth.refresh_rate seconds weechat.hook_timer(int(weechat.config_get_plugin('refresh_rate'))*1000, 0, 0, 'bandwidth_timer_cb', '')
def main(): if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): version = int(weechat.info_get("version_number", "")) or 0 # unset unused setting from older versions of script if weechat.config_is_set_plugin("display_unit"): weechat.prnt("", "Option plugins.var.python.bandwidth.display_unit no longer used, removing.") weechat.config_unset_plugin("display_unit") # set default settings for option in SCRIPT_SETTINGS.iterkeys(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, SCRIPT_SETTINGS[option][0]) if version >= 0x00030500: weechat.config_set_desc_plugin(option, SCRIPT_SETTINGS[option][1]) # ensure sane refresh_rate setting if int(weechat.config_get_plugin("refresh_rate")) < 1: weechat.prnt( "", "{}Invalid value for option plugins.var.python.bandwidth.refresh_rate, setting to default of {}".format( weechat.prefix("error"), SCRIPT_SETTINGS["refresh_rate"][0] ), ) weechat.config_set_plugin("refresh_rate", SCRIPT_SETTINGS["refresh_rate"][0]) # create the bandwidth monitor bar item weechat.bar_item_new("bandwidth", "bandwidth_item_cb", "") # update it every plugins.var.python.bandwidth.refresh_rate seconds weechat.hook_timer(int(weechat.config_get_plugin("refresh_rate")) * 1000, 0, 0, "bandwidth_timer_cb", "")
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 toggle_refresh(pointer, name, value): option_name = name[len('plugins.var.python.' + SCRIPT_NAME + '.'):] # get optionname # option was removed? remove bar_item from struct if not weechat.config_get_plugin(option_name): ptr_bar = weechat.bar_item_search(option_name) if ptr_bar: weechat.bar_item_remove(ptr_bar) return weechat.WEECHAT_RC_OK # check if option is new or changed if not weechat.bar_item_search(option_name): weechat.bar_item_new(option_name,'update_item',option_name) weechat.bar_item_update(option_name) return weechat.WEECHAT_RC_OK
def create_bar_items(): ptr_infolist_option = weechat.infolist_get('option','','plugins.var.python.' + SCRIPT_NAME + '.*') if not ptr_infolist_option: return while weechat.infolist_next(ptr_infolist_option): option_full_name = weechat.infolist_string(ptr_infolist_option, 'full_name') option_name = option_full_name[len('plugins.var.python.' + SCRIPT_NAME + '.'):] # get optionname if weechat.bar_item_search(option_name): weechat.bar_item_update(option_name) else: weechat.bar_item_new(option_name,'update_item',option_name) weechat.bar_item_update(option_name) weechat.infolist_free(ptr_infolist_option)
def create_bar_items(): ptr_infolist_option = weechat.infolist_get("option", "", "plugins.var.python." + SCRIPT_NAME + ".*") if not ptr_infolist_option: return while weechat.infolist_next(ptr_infolist_option): option_full_name = weechat.infolist_string(ptr_infolist_option, "full_name") option_name = option_full_name[len("plugins.var.python." + SCRIPT_NAME + ".") :] # get optionname if weechat.bar_item_search(option_name): weechat.bar_item_update(option_name) else: weechat.bar_item_new(option_name, "update_item", option_name) weechat.bar_item_update(option_name) weechat.infolist_free(ptr_infolist_option)
def hook_timer(): global hooks hooks["timer"] = weechat.hook_timer(int(OPTIONS["refresh"]) * 1000, 0, 0, 'item_update', '') hooks["bar_item"] = weechat.bar_item_new(SCRIPT_NAME, 'show_item','') if hooks["timer"] == 0: weechat.prnt('',"%s: can't enable %s, hook failed" % (weechat.prefix("error"), SCRIPT_NAME)) weechat.bar_item_remove(hooks["bar_item"]) hooks["bar_item"] = "" return 0 weechat.bar_item_update(SCRIPT_NAME) return 1
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
OPTIONS[option] = weechat.config_get_plugin(option) weechat.config_set_desc_plugin(option, "%s (default: '%s')" % (value[1], value[0])) def toggle_refresh(pointer, name, value): global OPTIONS option = name[len('plugins.var.python.' + SCRIPT_NAME + '.'):] # get optionname OPTIONS[option] = value # save new value weechat.bar_item_update(SCRIPT_NAME) return weechat.WEECHAT_RC_OK # ================================[ main ]=============================== if __name__ == "__main__": # global filter_status if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): version = weechat.info_get("version_number", "") or 0 if int(version) >= 0x00030600: filter_status = int(weechat.info_get('filters_enabled','')) bar_item = weechat.bar_item_new(SCRIPT_NAME, 'show_item','') weechat.bar_item_update(SCRIPT_NAME) weechat.hook_signal('buffer_line_added','update_cb','') weechat.hook_signal('window_scrolled','update_cb','') weechat.hook_signal('buffer_switch','update_cb','') weechat.hook_signal('*filters*','filtered_update_cb','') weechat.hook_command_run('/buffer clear*','update_cb','') weechat.hook_command_run('/window page*','update_cb','') weechat.hook_command_run('/input zoom_merged_buffer','update_cb','') weechat.hook_config( 'plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '' ) init_options() else: weechat.prnt('','%s%s %s' % (weechat.prefix('error'),SCRIPT_NAME,': needs version 0.3.6 or higher'))
weechat.hook_set(send_hook, 'stdin', proc_data) else: proc_data = email + '\n' + passwd + '\n' +\ weechat.config_get_plugin('poll_interval') + '\n' recv_hook = weechat.hook_process_hashtable(weechat_dir + '/python/wtrecv.py', { 'stdin': '' }, 0, 'renderConversations', '') weechat.hook_set(recv_hook, 'stdin', proc_data) PIPE=-1 # register plugin if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", "UTF-8"): buffer = weechat.buffer_new("weeText", "gvOut", "", "buffer_close_cb", "") weechat_dir = weechat.info_get("weechat_dir","") key_dir = weechat.config_get_plugin("key_dir") weechat.bar_item_new('encryption', 'encryption_statusbar', '') for option, default_value in script_options.iteritems(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) # get email/passwd and pass to other script email=weechat.config_get_plugin('email') passwd = weechat.config_get_plugin('passwd') if re.search('sec.*data', passwd): passwd=weechat.string_eval_expression(passwd, {}, {}, {}) # write the helper files with open(weechat_dir + '/python/wtrecv.py', 'w') as f: f.write("""#!/usr/bin/env python2 import sys
ircrypt_config_init() ircrypt_config_read() ircrypt_check_binary() weechat.hook_modifier('irc_in_privmsg', 'ircrypt_decrypt_hook', '') weechat.hook_modifier('irc_out_privmsg', 'ircrypt_encrypt_hook', '') weechat.hook_command('ircrypt', 'Commands to manage IRCrypt options and execute IRCrypt commands', '[list]' '| set-key [-server <server>] <target> <key> ' '| remove-key [-server <server>] <target> ' '| set-cipher [-server <server>] <target> <cipher> ' '| remove-cipher [-server <server>] <target> ' '| plain [-server <server>] [-channel <channel>] <message>', SCRIPT_HELP_TEXT, 'list || set-key %(irc_channel)|%(nicks)|-server %(irc_servers) %- ' '|| remove-key %(irc_channel)|%(nicks)|-server %(irc_servers) %- ' '|| set-cipher %(irc_channel)|-server %(irc_servers) %- ' '|| remove-cipher |%(irc_channel)|-server %(irc_servers) %- ' '|| plain |-channel %(irc_channel)|-server %(irc_servers) %-', 'ircrypt_command', '') weechat.bar_item_new('ircrypt', 'ircrypt_encryption_statusbar', '') weechat.hook_signal('ircrypt_buffer_opened', 'update_encryption_status', '') def ircrypt_unload_script(): '''Hook to ensure the configuration is properly written to disk when the script is unloaded. ''' ircrypt_config_write() return weechat.WEECHAT_RC_OK
def send_typing(nick, level): if not channel_has_nick(bitlbee_server_name, bitlbee_channel, nick): return cookie = sending_typing.get(nick, 1) + 1 if not sending_typing.get(nick, None): send_typing_ctcp(nick, level) sending_typing[nick] = cookie w.hook_timer(4000, 0, 1, "typing_disable_timer", "%s:%i" % (nick, cookie)) def typing_notice_item_cb(data, buffer, args): if typing: msgs = [] for key, value in typing.items(): msg = key if value == 2: msg += " (stale)" msgs.append(msg) return "typing: " + ", ".join(sorted(msgs)) return "" if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): w.hook_signal("input_text_changed", "typed_char", "") w.hook_signal(bitlbee_server_name + ",irc_in_quit", "stop_typing", "") w.hook_signal(bitlbee_server_name + ",irc_in_privmsg", "stop_typing", "") w.bar_item_new('bitlbee_typing_notice', 'typing_notice_item_cb', '') w.hook_modifier("irc_in_privmsg", "ctcp_cb", "")
weechat.config_set_plugin(option, value[0]) OPTIONS[option] = value[0] else: OPTIONS[option] = weechat.config_get_plugin(option) weechat.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0])) def toggle_refresh(pointer, name, value): global OPTIONS option = name[len('plugins.var.python.' + SCRIPT_NAME + '.'):] # get optionname OPTIONS[option] = value # save new value 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 # get weechat version (0.3.6) and store it if int(version) >= 0x00030600: # init options from your script init_options() # create a hook for your options weechat.hook_config( 'plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '' ) # create a new bar item (for scripts running on weechat >= 0.4.2 see script API for additional arguments) bar_item = weechat.bar_item_new(SCRIPT_NAME, 'bar_item_cb','') # create a hook with signal "buffer_switch" for your item weechat.hook_signal("buffer_switch","update_cb","") else: weechat.prnt("","%s%s %s" % (weechat.prefix("error"),SCRIPT_NAME,": needs version 0.3.6 or higher")) weechat.command("","/wait 1ms /python unload %s" % SCRIPT_NAME)
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', '')
# Show the command line when needed, hide it (and update vi_buffer since # we'd be looking for keystrokes instead) otherwise. if cmd_text != '': weechat.command('', "/bar show vi_cmd") weechat.bar_item_update("cmd_text") else: weechat.command('', "/bar hide vi_cmd") if is_printing(signal_data, pressed_keys): vi_buffer += signal_data pressed_keys += signal_data # Check for any matching bound keys. weechat.hook_timer(1, 0, 1, "pressed_keys_check", '') last_time = time.time() # Clear the buffers after some time. weechat.hook_timer(1000, 0, 1, "clear_vi_buffers", "check_time") weechat.bar_item_update("vi_buffer") return weechat.WEECHAT_RC_OK weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '') weechat.bar_item_new("mode_indicator", "mode_indicator_cb", '') weechat.bar_item_new("cmd_text", "cmd_text_cb", '') weechat.bar_item_new("vi_buffer", "vi_buffer_cb", '') vi_cmd = weechat.bar_new("vi_cmd", "off", "0", "root", '', "bottom", "vertical", "vertical", "0", "0", "default", "default", "default", "0", "cmd_text") weechat.hook_signal("key_pressed", "key_pressed_cb", '')
VERSION = weechat.info_get("version_number", "") if int(VERSION) < 0x01000000: print_warning("Please upgrade to WeeChat ≥ 1.0.0. Previous versions" " are not supported.") # 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", "") weechat.bar_item_new("line_numbers", "cb_line_numbers", "") weechat.bar_new( "vi_cmd", "off", "0", "root", "", "bottom", "vertical", "vertical", "0", "0", "default",
loadproc = open("/proc/loadavg") load_data = loadproc.read().split(" ") loadproc.close() config_items = weechat.config_get_plugin("items") first_load = load_data[0] second_load = load_data[1] third_load = load_data[2] if config_items == "1": return load_data[0] if config_items == "5": return load_data[1] if config_items == "15": return load_data[2] if config_items == "all": return "%s %s %s" % (load_data[0], load_data[1], load_data[2]) def load_timer(*args): weechat.bar_item_update("load") return weechat.WEECHAT_RC_OK if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): for option, default_value in settings.iteritems(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) weechat.bar_item_new("load", "load_item", "") weechat.bar_item_update("load") weechat.hook_timer(1000 * 20, 0, 0, "load_timer", "")
last_i = cur_i last_o = cur_o if not last_i or not last_o: return "" i_unit = "" o_unit = "" if weechat.config_get_plugin("display_unit") == "on": i_unit = "KiB/s" o_unit = "KiB/s" if i > 1023: i = i / 1024 i_unit = "MiB/s" if o > 1023: o = o / 1024 o_unit = "MiB/s" return "i: %(in)d %(i_unit)s, o: %(out)d %(o_unit)s" % {"in": i, "out": o, "i_unit": i_unit, "o_unit": o_unit} 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 bandwidth_settings.iteritems(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) # new item weechat.bar_item_new("bandwidth", "bandwidth_item_cb", "") weechat.hook_timer(int(weechat.config_get_plugin("refresh_rate")) * 1000, 0, 0, "bandwidth_timer_cb", "")
'Using "aspell.check.real_time" the nick-completion will not work, until all misspelled words in input_line are replaced.\n' '\n' 'You can bind following commands to key:\n' ' /' + SCRIPT_NAME + ' : to cycle though next suggestion\n' ' /' + SCRIPT_NAME + ' previous : to cycle though previous suggestion\n' ' /' + SCRIPT_NAME + ' replace : to replace misspelled word\n' '', 'previous|replace', 'auto_suggest_cmd_cb', '') init_options() weechat.hook_command_run('/input delete_*', 'input_delete_cb', '') weechat.hook_command_run('/input move*', 'input_move_cb', '') weechat.hook_signal ('input_text_changed', 'input_text_changed_cb', '') # multiline workaround weechat.hook_signal('input_flow_free', 'multiline_cb', '') weechat.hook_signal ('aspell_suggest', 'aspell_suggest_cb', '') weechat.hook_signal ('buffer_switch', 'buffer_switch_cb','') weechat.hook_signal ('window_switch', 'window_switch_cb','') if OPTIONS['catch_input_completion'].lower() == "on": Hooks['catch_input_completion'] = weechat.hook_command_run('/input complete*', 'input_complete_cb', '') Hooks['catch_input_return'] = weechat.hook_command_run('/input return', 'input_return_cb', '') weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '') weechat.bar_item_new('spell_correction', 'show_spell_correction_item_cb', '') weechat.bar_item_new('spell_suggest', 'show_spell_suggestion_item_cb', '') # weechat.prnt("","%s" % sys.version_info)
if loaded: # We want to highlight on our screen_name. user = twitter.api.me() # Find timelined timelined = which(wc.config_get_plugin("timelined_location")) if not timelined: print_error( "Couldn't find timelined, please set 'plugins.var.python.weetwit.timelined" ) tl = timelined[0] setup_timeline(tl, followed=followed) bar_item = wc.bar_item_new('tweet_counter', 'tcounter_item_cb', '') # Config change hook. wc.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "storage_cb", "") # All commands hook = wc.hook_command("tweet", "Updates your twitter status.", "[tweet]", "The text to update with (140 characters max).", "", "tweet_cb", "") hook = wc.hook_command("tinfo", "Lookup info about a certain tweet.", "[tweet id/@username]",
# Bar items. # ---------- def cb_hats(data, item, window): buf = weechat.current_buffer() plugin = weechat.buffer_get_string(buf, "localvar_plugin") if plugin == "irc": server = weechat.buffer_get_string(buf, "localvar_server") channel = weechat.buffer_get_string(buf, "localvar_channel") nick = weechat.buffer_get_string(buf, "localvar_nick") nicks = weechat.infolist_get("irc_nick", "", "{},{},{}".format( server, channel, nick)) weechat.infolist_next(nicks) hats = weechat.infolist_string(nicks, "prefixes") weechat.infolist_free(nicks) return hats.replace(" ", "") return "" # Main script. # ============ if __name__ == "__main__": weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", "") # Create bar items and setup hooks. weechat.bar_item_new("hats", "cb_hats", "") weechat.hook_print("", "irc_mode", "", 0, "cb_irc_mode", "") weechat.hook_signal("buffer_switch", "cb_buffer_switch", "")
weechat.hook_modifier('irc_in_privmsg', 'message_in_cb', '') weechat.hook_modifier('irc_out_privmsg', 'message_out_cb', '') weechat.hook_command( SCRIPT_NAME, SCRIPT_HELP, 'start [NICK SERVER] || ' 'finish [NICK SERVER] || ' 'smp ask NICK SERVER SECRET [QUESTION] || ' 'smp respond NICK SERVER SECRET || ' 'trust [NICK SERVER] || ' 'policy [POLICY on|off]', '', 'start %(nick) %(irc_servers) %-||' 'finish %(nick) %(irc_servers) %-||' 'smp ask|respond %(nick) %(irc_servers) %-||' 'trust %(nick) %(irc_servers) %-||' 'policy %(otr_policy) on|off %-||', 'command_cb', '') weechat.hook_completion( 'otr_policy', 'OTR policies', 'policy_completion_cb', '') weechat.hook_config('logger.level.irc.*', 'logger_level_update_cb', '') weechat.hook_signal('buffer_switch', 'buffer_switch_cb', '') OTR_STATUSBAR = weechat.bar_item_new(SCRIPT_NAME, 'otr_statusbar_cb', '') weechat.bar_item_update(SCRIPT_NAME)
weechat.hook_signal("input_search", "input_search_cb", "") weechat.hook_signal("input_text_changed", "input_text_changed_cb", "") weechat.hook_command(SCRIPT_COMMAND, SCRIPT_DESC, """enable || disable || toggle""", """ enable: enable {0} in current buffer disable: disable {0} in current buffer toggle: toggle {0} in current buffer By default a bind in "search" context is added to toggle with "ctrl-G". To see {0} status during search, add "{1}" item to some bar. On default configuration you can do it with: /set weechat.bar.input.items "[input_prompt]+(away),[{1}],[input_search],[input_paste],input_text" Due to technical reasons with /filter it is not possible to exactly {0} in "pre|msg" search mode, thus the bar item is shown in warning color.""".format(SCRIPT_NAME, SCRIPT_BAR_ITEM), """enable || disable || toggle""", "command_cb", "") weechat.bar_item_new("(extra)%s" % SCRIPT_BAR_ITEM, "bar_item_cb", "") for option, value in SETTINGS.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, value[0]) weechat.config_set_desc_plugin(option, "%s (default: \"%s\")" % (value[1], value[0])) weechat.key_bind("search", KEYS)
if loaded: # We want to highlight on our screen_name. user = twitter.api.me() # Find timelined timelined = which(wc.config_get_plugin("timelined_location")) if not timelined: print_error( "Couldn't find timelined, please set 'plugins.var.python.weetwit.timelined" ) tl = timelined[0] setup_timeline(tl, followed=followed) bar_item = wc.bar_item_new('tweet_counter', 'tcounter_item_cb', '') # Config change hook. wc.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "storage_cb", "") # All commands hook = wc.hook_command( "tweet", "Updates your twitter status.", "[tweet]", "The text to update with (140 characters max).", "", "tweet_cb", "") hook = wc.hook_command( "tinfo", "Lookup info about a certain tweet.", "[tweet id/@username]", "The ID of the tweet, if @username is given, the ID of their last tweet is used.",
'.'):] # get optionname OPTIONS[option] = value # save new value weechat.bar_item_update(SCRIPT_NAME) return weechat.WEECHAT_RC_OK # ================================[ main ]=============================== if __name__ == "__main__": # global filter_status if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): version = weechat.info_get("version_number", "") or 0 if int(version) >= 0x00030600: filter_status = int(weechat.info_get('filters_enabled', '')) bar_item = weechat.bar_item_new(SCRIPT_NAME, 'show_item', '') weechat.bar_item_update(SCRIPT_NAME) weechat.hook_signal('buffer_line_added', 'update_cb', '') weechat.hook_signal('window_scrolled', 'update_cb', '') weechat.hook_signal('buffer_switch', 'update_cb', '') weechat.hook_signal('*filters*', 'filtered_update_cb', '') weechat.hook_command_run('/buffer clear*', 'update_cb', '') weechat.hook_command_run('/window page*', 'update_cb', '') weechat.hook_command_run('/input zoom_merged_buffer', 'update_cb', '') weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '') init_options() else: weechat.prnt( '', '%s%s %s' % (weechat.prefix('error'), SCRIPT_NAME,
servers = SearchList() for token in slack_api_token.split(','): servers.append(SlackServer(token)) channels = Meta('channels', servers) users = Meta('users', servers) w.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_changed_cb", "") w.hook_timer(10, 0, 0, "async_queue_cb", "") w.hook_timer(6000, 0, 0, "slack_connection_persistence_cb", "") ### attach to the weechat hooks we need w.hook_timer(1000, 0, 0, "typing_update_cb", "") w.hook_timer(1000, 0, 0, "buffer_list_update_cb", "") w.hook_timer(1000, 0, 0, "hotlist_cache_update_cb", "") w.hook_timer(1000 * 3, 0, 0, "slack_never_away_cb", "") w.hook_timer(1000 * 60* 29, 0, 0, "slack_never_away_cb", "") w.hook_signal('buffer_closing', "buffer_closing_cb", "") w.hook_signal('buffer_switch', "buffer_switch_cb", "") w.hook_signal('window_switch', "buffer_switch_cb", "") w.hook_signal('input_text_changed', "typing_notification_cb", "") w.hook_command('slack','Plugin to allow typing notification and sync of read markers for slack.com', 'stuff', 'stuff2', '|'.join(cmds.keys()), 'slack_command_cb', '') w.hook_command('me','', 'stuff', 'stuff2', '', 'me_command_cb', '') # w.hook_command('me', 'me_command_cb', '') w.hook_command_run('/join', 'join_command_cb', '') w.hook_command_run('/part', 'part_command_cb', '') w.hook_command_run('/leave', 'part_command_cb', '') w.bar_item_new('slack_typing_notice', 'typing_bar_item_cb', '') ### END attach to the weechat hooks we need
except ImportError as message: print('Missing package(s) for %s: %s' % (SCRIPT_NAME, message)) import_ok = False def unfocused_bar_item_update (data=None, signal=None, signal_data=None): '''Updates bar item''' w.bar_item_update('inputtape') return w.WEECHAT_RC_OK def unfocused_bar_item (data, item, window): '''Item constructor''' # window empty? root bar! if not window: window = w.current_window() ptr_buffer = w.window_get_pointer(window, "buffer") if ptr_buffer == "" or ptr_buffer == w.current_buffer(): return "" length = w.window_get_integer(window, 'win_width') - w.buffer_get_integer(ptr_buffer, 'input_length') s = length * inputtape_char return s if __name__ == "__main__": if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): # update status bar display unfocused_bar_item_update() w.hook_signal('buffer_switch', 'unfocused_bar_item_update', '') w.bar_item_new('inputtape', 'unfocused_bar_item', '')
ptr_hotlist = w.hdata_move(hdata_hotlist, ptr_hotlist, 1) items = [] for number, priority in sorted(priorities.items()): items.append('%s %s %s' % ( w.color(COLORS[priority]), titles[number], w.color('reset'))) return ' '.join(items) def hotlist_hook_cb(data, signal, signal_data): w.bar_item_update('custom_hotlist') return w.WEECHAT_RC_OK def my_signal_cb(data, signal, signal_data): return w.WEECHAT_RC_OK if w.register( SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): w.bar_item_new('custom_hotlist', 'hotlist_item_cb', '') w.hook_signal('buffer_line_added', 'hotlist_hook_cb', '')
def create_bar_item(): weechat.bar_item_new("check_mail", "on_bar_item_update", "") weechat.bar_item_update("check_mail")
buf = weechat.window_get_pointer(window, 'buffer') else: buf = weechat.current_buffer() if os.path.exists(weechat_dir + '/' + \ weechat.buffer_get_string(buf, 'short_name') + '.db'): return weechat.config_get_plugin("statusbar_indicator") else: return "" # register plugin if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, \ SCRIPT_LICENSE, SCRIPT_DESC, "", "UTF-8"): weechat_dir = weechat.info_get("weechat_dir", "") key_dir = weechat.config_get_plugin('key_dir') version = weechat.info_get("version_number", "") or 0 if int(version) < 0x00030000: weechat.prnt( "", "%s%s: WeeChat 0.3.0 is required for this script." % (weechat.prefix("error"), SCRIPT_NAME)) else: weechat.bar_item_new('axolotl', 'encryption_statusbar', '') for option, default_value in script_options.iteritems(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) # register the modifiers weechat.hook_modifier("irc_in_privmsg", "decrypt", "") weechat.hook_modifier("irc_out_privmsg", "encrypt", "") weechat.hook_signal("buffer_switch", "update_encryption_status", "")
" remove: remove settings for responsive layout\n" " list: list current configuration\n" " terminal: list current terminal width and height\n" " debug: print script debug output\n\n" "To get current layout and terminal dimensions in your bar, use 'rlayout' bar item.", "size %(layouts_names)" " || nicklist %(layouts_names) %(rlayout_bool_value)" " || default_nicklist %(rlayout_bool_value)" " || remove %(rlayouts_names)" " || list" " || terminal" " || debug %(rlayout_bool_value)", "rlayout_cmd_cb", "") # Default settings for option, default_value in SETTINGS.items(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value[0]) weechat.config_set_desc_plugin( option, '%s (default: %s)' % (default_value[1], default_value[0])) weechat.hook_completion("rlayout_bool_value", "list of bool values", "rlayout_completion_bool_cb", "") weechat.hook_completion("rlayouts_names", "list of rlayouts", "rlayout_completion_layout_list_cb", "") weechat.hook_config("plugins.var.python.responsive_layout.layout.*", "config_cb", "") weechat.bar_item_new("rlayout", "rlayout_bar_cb", "") update_layout_list() hook = weechat.hook_signal("signal_sigwinch", "responsive_cb", "")
'Color for icons in list (non-IRC buffers)'), } # Loop through and set options with default values and descriptions, and load values into dict to use option_values = {} for option, values in options.items(): # First ensure it's not already set if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, values[0]) weechat.config_set_desc_plugin(option, values[1]) option_values[option] = weechat.config_get_plugin(option) # Setup callback for config option updates weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'config_handler', '') # Create bar item weechat.bar_item_new('squigzlist', 'build_list', '') # Hook various signals on which to refresh the list signals = [ 'buffer_opened', 'buffer_closed', 'buffer_merged', 'buffer_unmerged', 'buffer_moved', 'buffer_renamed', 'buffer_switch', 'buffer_hidden', 'buffer_unhidden', 'buffer_localvar_added', 'buffer_localvar_changed', 'hotlist_changed' ] for signal in signals: weechat.hook_signal(signal, 'signal_handler', '')
else: buf = weechat.current_buffer() if os.path.exists(weechat_dir + "/cryptkey." + weechat.buffer_get_string(buf, "short_name")): return weechat.config_get_plugin("statusbar_indicator") else: return "" # for subprocess.Popen call PIPE = -1 # register plugin if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", "UTF-8"): weechat_dir = weechat.info_get("weechat_dir", "") version = weechat.info_get("version_number", "") or 0 if int(version) < 0x00030000: weechat.prnt( "", "%s%s: WeeChat 0.3.0 is required for this script." % (weechat.prefix("error"), SCRIPT_NAME)) else: weechat.bar_item_new('encryption', 'encryption_statusbar', '') for option, default_value in script_options.iteritems(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) # register the modifiers weechat.hook_modifier("irc_in_privmsg", "decrypt", "") weechat.hook_modifier("irc_out_privmsg", "encrypt", "") weechat.hook_signal("buffer_switch", "update_encryption_status", "")
return (tm.tm_hour*3600+tm.tm_min*60+tm.tm_sec)/1000.0 def kiloseconds_cmd(data, buffer, args): """Callback for /ks command""" weechat.command(buffer,"The current time is " + str(getKiloseconds()) + " ks") return weechat.WEECHAT_RC_OK def kiloseconds_cb(data, buffer, args): """Callback for the bar item""" return "%06.3f" % getKiloseconds() def kiloseconds_update(data,cals): """Update the bar item""" weechat.bar_item_update('kiloseconds') return weechat.WEECHAT_RC_OK if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): weechat.hook_command(SCRIPT_COMMAND, "Display current time in kiloseconds", "", "Add 'kiloseconds' to any bar to have it show the time in kiloseconds.", "", "kiloseconds_cmd", "") weechat.bar_item_new('kiloseconds', 'kiloseconds_cb', '') weechat.hook_timer(1000,1,0,'kiloseconds_update','')
python2_bin = weechat.info_get("python2_bin", "") or "python" gweather_hook_process = weechat.hook_process(\ python2_bin + " -c \"import urllib2;\ handler = " + command + ";\ print handler.info().dict['content-type'];\ print handler.read();\ handler.close();\"", int(weechat.config_get_plugin('timeout')) * 1000, "gweather_data_cb", "") # The old cached string is returned here. gweather_data_cb() will # request a new update after the data is fetched and parsed. return gweather_output def gweather_update(*kwargs): weechat.bar_item_update('gweather') return weechat.WEECHAT_RC_OK if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): for option, default_value in settings.iteritems(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) weechat.bar_item_new('gweather', 'gweather_cb', '') weechat.bar_item_update('gweather') weechat.hook_timer(int(weechat.config_get_plugin('interval')) * 1000 * 60, 0, 0, 'gweather_update', '')
print_warning("Please upgrade to WeeChat ≥ 1.0.0. Previous versions" " are not supported.") # 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", "") weechat.bar_item_new("line_numbers", "cb_line_numbers", "") weechat.bar_new("vi_cmd", "off", "0", "root", "", "bottom", "vertical", "vertical", "0", "0", "default", "default", "default", "0", "cmd_text") weechat.bar_new("vi_line_numbers", "on", "0", "window", "", "left", "vertical", "vertical", "0", "0", "default", "default", "default", "0", "line_numbers") 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_signal("buffer_switch", "cb_update_line_numbers", "") weechat.hook_command(
def unfocused_bar_item_update(data=None, signal=None, signal_data=None): '''Updates bar item''' w.bar_item_update('inputtape') return w.WEECHAT_RC_OK def unfocused_bar_item(data, item, window): '''Item constructor''' # window empty? root bar! if not window: window = w.current_window() ptr_buffer = w.window_get_pointer(window, "buffer") if ptr_buffer == "" or ptr_buffer == w.current_buffer(): return "" length = w.window_get_integer(window, 'win_width') - w.buffer_get_integer( ptr_buffer, 'input_length') s = length * inputtape_char return s if __name__ == "__main__": if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): # update status bar display unfocused_bar_item_update() w.hook_signal('buffer_switch', 'unfocused_bar_item_update', '') w.bar_item_new('inputtape', 'unfocused_bar_item', '')
if num_displayed == 0 or show_all_buffers == "on": highlight_enabled = weechat.config_get_plugin("highlight") private_enabled = weechat.config_get_plugin("private") if ((highlight == "1") and (highlight_enabled == "on")) or (("notify_private" in tagslist) and (private_enabled == "on")): hlpv_item_add(buffer, highlight, prefix, message) return weechat.WEECHAT_RC_OK def hlpv_item_cb(data, buffer, args): """ Callback for building hlpv item. """ global hlpv_messages if len(hlpv_messages) > 0: return hlpv_messages[0] return "" 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 hlpv_settings.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) # new item weechat.bar_item_new('hlpv', 'hlpv_item_cb', '') # hook all printed messages weechat.hook_print("", "", "", 1, "hlpv_print_cb", "")
def config_changed(data, option, value): init_config() return w.WEECHAT_RC_OK def tc_action_cb(): global tc_options if tc_options['warn_command']: if tc_options['warn_command'] == '$bell': f = open('/dev/tty', 'w') f.write('\a') f.close() else: os.system(tc_options['warn_command']) return w.WEECHAT_RC_OK if __name__ == "__main__" and import_ok: if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): version = w.info_get("version_number", "") or 0 init_config() # read configuration tc_bar_item_update() # update status bar display w.hook_signal('input_text_changed', 'tc_bar_item_update', '') w.hook_signal('input_text_cursor_moved','tc_bar_item_update','') w.hook_command_run('/input move_previous_char','command_run_cb','') w.hook_command_run('/input delete_previous_char','command_run_cb','') w.hook_signal('buffer_switch','tc_bar_item_update','') w.hook_config('plugins.var.python.' + SCRIPT_NAME + ".*", "config_changed", "") w.bar_item_new('tc', 'tc_bar_item', '')
cmd_text += signal_data # Show the command line when needed, hide it (and update vi_buffer since # we'd be looking for keystrokes instead) otherwise. if cmd_text != '': weechat.command('', "/bar show vi_cmd") weechat.bar_item_update("cmd_text") else: weechat.command('', "/bar hide vi_cmd") if is_printing(signal_data, pressed_keys): vi_buffer += signal_data pressed_keys += signal_data # Check for any matching bound keys. weechat.hook_timer(1, 0, 1, "pressed_keys_check", '') last_time = time.time() # Clear the buffers after some time. weechat.hook_timer(1000, 0, 1, "clear_vi_buffers", "check_time") weechat.bar_item_update("vi_buffer") return weechat.WEECHAT_RC_OK weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '') weechat.bar_item_new("mode_indicator", "mode_indicator_cb", '') weechat.bar_item_new("cmd_text", "cmd_text_cb", '') weechat.bar_item_new("vi_buffer", "vi_buffer_cb", '') vi_cmd = weechat.bar_new("vi_cmd", "off", "0", "root", '', "bottom", "vertical", "vertical", "0", "0", "default", "default", "default", "0", "cmd_text") weechat.hook_signal("key_pressed", "key_pressed_cb", '')
SCRIPT_NAME = "alternatetz" SCRIPT_AUTHOR = "Chmouel Boudjnah <*****@*****.**>" SCRIPT_VERSION = "0.1" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = "Display Alternate Time from different TimeZone" # script options settings = { "timezone" : 'US/Central', "timeformat" : "%H:%M", } def alternatetz_item_cb(*kwargs): tzname = w.config_get_plugin('timezone') tz = pytz.timezone(tzname) return datetime.datetime.now(tz).strftime(w.config_get_plugin('timeformat')) def alternatetz_timer_cb(*kwargs): w.bar_item_update('alternatetz') return w.WEECHAT_RC_OK if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): for option, default_value in settings.iteritems(): if not w.config_is_set_plugin(option): w.config_set_plugin(option, default_value) w.bar_item_new('alternatetz', 'alternatetz_item_cb', '') w.bar_item_update('alternatetz') w.hook_timer(1000*60, 60, 0, 'alternatetz_timer_cb', '')
"You can bind following commands to key:\n" " /" + SCRIPT_NAME + " : to cycle though next suggestion\n" " /" + SCRIPT_NAME + " previous : to cycle though previous suggestion\n" " /" + SCRIPT_NAME + " replace : to replace misspelled word\n" "", "previous|replace", "auto_suggest_cmd_cb", "", ) init_options() weechat.hook_command_run("/input delete_*", "input_delete_cb", "") weechat.hook_command_run("/input move*", "input_move_cb", "") weechat.hook_signal("input_text_changed", "input_text_changed_cb", "") # multiline workaround weechat.hook_signal("input_flow_free", "multiline_cb", "") weechat.hook_signal("aspell_suggest", "aspell_suggest_cb", "") weechat.hook_signal("buffer_switch", "buffer_switch_cb", "") weechat.hook_signal("window_switch", "window_switch_cb", "") if OPTIONS["catch_input_completion"].lower() == "on": Hooks["catch_input_completion"] = weechat.hook_command_run("/input complete*", "input_complete_cb", "") Hooks["catch_input_return"] = weechat.hook_command_run("/input return", "input_return_cb", "") weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "toggle_refresh", "") weechat.bar_item_new("spell_correction", "show_spell_correction_item_cb", "") weechat.bar_item_new("spell_suggest", "show_spell_suggestion_item_cb", "") # weechat.prnt("","%s" % sys.version_info)
OTR_DIR = os.path.join(info_get('weechat_dir', ''), OTR_DIR_NAME) create_dir() ACCOUNTS = AccountDict() weechat.hook_modifier('irc_in_privmsg', 'message_in_cb', '') weechat.hook_modifier('irc_out_privmsg', 'message_out_cb', '') weechat.hook_command( SCRIPT_NAME, SCRIPT_HELP, 'start [NICK SERVER] || ' 'finish [NICK SERVER] || ' 'smp ask NICK SERVER SECRET [QUESTION] || ' 'smp respond NICK SERVER SECRET || ' 'trust [NICK SERVER] || ' 'policy [POLICY on|off]', '', 'start %(nick) %(irc_servers) %-||' 'finish %(nick) %(irc_servers) %-||' 'smp ask|respond %(nick) %(irc_servers) %-||' 'trust %(nick) %(irc_servers) %-||' 'policy %(otr_policy) on|off %-||', 'command_cb', '') weechat.hook_completion('otr_policy', 'OTR policies', 'policy_completion_cb', '') weechat.hook_config('logger.level.irc.*', 'logger_level_update_cb', '') weechat.hook_signal('buffer_switch', 'buffer_switch_cb', '') OTR_STATUSBAR = weechat.bar_item_new(SCRIPT_NAME, 'otr_statusbar_cb', '') weechat.bar_item_update(SCRIPT_NAME)
output += w.color('reset') LAST_RUN = now() LAST_MESSAGE = '' if any_with_unread: LAST_MESSAGE = output return LAST_MESSAGE def imap_update(*kwargs): w.bar_item_update('imap') return w.WEECHAT_RC_OK if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): for option, default_value in settings.iteritems(): if not w.config_is_set_plugin(option): w.config_set_plugin(option, default_value) w.bar_item_new('imap', 'imap_cb', '') w.hook_timer(\ int(w.config_get_plugin('interval'))*1000*60, 0, 0, 'imap_update', '')
def toggle_refresh(pointer, name, value): global OPTIONS option = name[len("plugins.var.python." + SCRIPT_NAME + ".") :] # get optionname OPTIONS[option] = value # save new value weechat.bar_item_update(SCRIPT_NAME) return weechat.WEECHAT_RC_OK # ================================[ main ]=============================== if __name__ == "__main__": # global filter_status if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): version = weechat.info_get("version_number", "") or 0 if int(version) >= 0x00030600: filter_status = weechat.info_get("filters_enabled", "") bar_item = weechat.bar_item_new(SCRIPT_NAME, "show_item", "") weechat.bar_item_update(SCRIPT_NAME) weechat.hook_signal("buffer_line_added", "update_cb", "") weechat.hook_signal("window_scrolled", "update_cb", "") weechat.hook_signal("buffer_switch", "update_cb", "") weechat.hook_signal("filters_*", "filtered_update_cb", "") weechat.hook_command_run("/buffer clear*", "update_cb", "") weechat.hook_command_run("/window page*", "update_cb", "") weechat.hook_command_run("/input zoom_merged_buffer", "update_cb", "") weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "toggle_refresh", "") init_options() else: weechat.prnt("", "%s%s %s" % (weechat.prefix("error"), SCRIPT_NAME, ": needs version 0.3.6 or higher"))
print_warning("Please upgrade to WeeChat ≥ 1.0.0. Previous versions" " are not supported.") # 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",
' /' + SCRIPT_NAME + ' previous : to cycle though previous suggestion\n' ' /' + SCRIPT_NAME + ' replace : to replace misspelled word\n' '', 'previous|replace|addword', 'auto_suggest_cmd_cb', '') init_options() weechat.hook_command_run('/input delete_*', 'input_delete_cb', '') weechat.hook_command_run('/input move*', 'input_move_cb', '') weechat.hook_signal('input_text_changed', 'input_text_changed_cb', '') # multiline workaround weechat.hook_signal('input_flow_free', 'multiline_cb', '') weechat.hook_signal('aspell_suggest', 'aspell_suggest_cb', '') weechat.hook_signal('buffer_switch', 'buffer_switch_cb', '') weechat.hook_signal('window_switch', 'window_switch_cb', '') if OPTIONS['catch_input_completion'].lower() == "on": Hooks['catch_input_completion'] = weechat.hook_command_run( '/input complete*', 'input_complete_cb', '') Hooks['catch_input_return'] = weechat.hook_command_run( '/input return', 'input_return_cb', '') weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '') weechat.bar_item_new('spell_correction', 'show_spell_correction_item_cb', '') weechat.bar_item_new('spell_suggest', 'show_spell_suggestion_item_cb', '') # weechat.prnt("","%s" % sys.version_info)
def encryption_statusbar(data, item, window): if window: buf = weechat.window_get_pointer(window, 'buffer') else: buf = weechat.current_buffer() if os.path.exists(weechat_dir + '/' + \ weechat.buffer_get_string(buf, 'short_name') + '.db'): return weechat.config_get_plugin("statusbar_indicator") else: return "" # register plugin if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, \ SCRIPT_LICENSE, SCRIPT_DESC, "", "UTF-8"): weechat_dir = weechat.info_get("weechat_dir","") key_dir = weechat.config_get_plugin('key_dir') version = weechat.info_get("version_number", "") or 0 if int(version) < 0x00030000: weechat.prnt("", "%s%s: WeeChat 0.3.0 is required for this script." % (weechat.prefix("error"), SCRIPT_NAME)) else: weechat.bar_item_new('axolotl', 'encryption_statusbar', '') for option, default_value in script_options.iteritems(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) # register the modifiers weechat.hook_modifier("irc_in_privmsg", "decrypt", "") weechat.hook_modifier("irc_out_privmsg", "encrypt", "") weechat.hook_signal("buffer_switch","update_encryption_status","")
init_config() return w.WEECHAT_RC_OK def tc_action_cb(): global tc_options if tc_options['warn_command']: if tc_options['warn_command'] == '$bell': f = open('/dev/tty', 'w') f.write('\a') f.close() else: os.system(tc_options['warn_command']) return w.WEECHAT_RC_OK if __name__ == "__main__": if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): init_config() # read configuration tc_bar_item_update() # update status bar display w.hook_signal('input_text_changed', 'tc_bar_item_update', '') w.hook_signal('input_text_cursor_moved', 'tc_bar_item_update', '') w.hook_command_run('/input move_previous_char', 'command_run_cb', '') w.hook_command_run('/input delete_previous_char', 'command_run_cb', '') w.hook_signal('buffer_switch', 'tc_bar_item_update', '') w.hook_config('plugins.var.python.' + SCRIPT_NAME + ".*", "config_changed", "") w.bar_item_new('tc', 'tc_bar_item', '')
if activity: message = w.config_get_plugin('message') delim = w.config_get_plugin('delimiter') return message + delim.join(a[0] for a in activity) else: return '' def chanact_update(*args): ''' Hooked to hotlist changes ''' w.bar_item_update('chanact') return w.WEECHAT_RC_OK if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): for option, default_value in settings.items(): if not w.config_is_set_plugin(option): w.config_set_plugin(option, default_value) for hook, cb in hooks: w.hook_signal(hook, cb, '') w.bar_item_new('chanact', 'chanact_cb', '') keydict_update() w.hook_command('chanact', 'Manipulate chanact.', 'sort [rank]', 'sort: Show or set the sort rank of the current buffer.', 'sort', 'chanact_command', '')
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", "")
for line in error.split('\n'): if line == 'FATAL_ERROR: The server is not running': return STATUS_NOT_RUNNING output = proc.stdout.read() proc.wait() return output # ==================================[ main ]================================== if __name__ == "__main__" and import_ok: if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "moc_unload", ""): load_settings('', '', '') weechat.hook_config('plugins.var.python.moc_control.*', 'load_settings', '') weechat.bar_item_new('moc_infobar', 'moc_infobar_update', '') weechat.hook_timer(infobar['update']*1000,0,0,'moc_infobar_updater','') if infobar['enabled']: _add_infobar() weechat.hook_command( SCRIPT_COMMAND, 'Control moc or display now playing information.', 'play|pause|pp|stop|prev|next|infobar|help', 'Commands Available\n' ' /moc - Display currently playing song.\n' ' /moc play - Start playing music.\n' ' /moc pause - Toggle between pause/playing.\n' ' /moc pp - Toggle between pause/playing.\n' ' /moc stop - Stop playing music.\n' ' /moc prev - Move to the previous song in the playlist.\n'
SCRIPT_COMMAND, SCRIPT_DESC, """""", # TODO """Prepend to weechat.bar.buflist.items: go_buflist, Append to buflist.look.display_conditions: && ${buffer.local_variables.go_buflist_hidden}==0 Prepend to buflist.format.buffer: ${eval:${plugins.var.python.go_buflist.format}}""", # TODO """""".replace("\n", ""), # TODO "command_cb", "") weechat.bar_item_new("(extra)%s" % SCRIPT_BAR_ITEM, "bar_item_cb", "") weechat.hook_command_run("/input *", "command_run_input_cb", "") weechat.hook_modifier("input_text_display_with_cursor", "input_text_display_with_cursor_cb", "") for option, value in SETTINGS.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, value[0]) weechat.config_set_desc_plugin( option, "%s (default: \"%s\")" % (value[1], value[0])) weechat.key_bind("default", KEYS) set_localvars("")
output = proc.stdout.read().decode('utf-8') proc.wait() return output # ==================================[ main ]================================== if __name__ == "__main__" and import_ok: if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "moc_unload", ""): load_settings('', '', '') weechat.hook_config('plugins.var.python.moc_control.*', 'load_settings', '') weechat.bar_item_new('moc_infobar', 'moc_infobar_update', '') weechat.hook_timer(infobar['update'] * 1000, 0, 0, 'moc_infobar_updater', '') if infobar['enabled']: _add_infobar() weechat.hook_command( SCRIPT_COMMAND, 'Control moc or display now playing information.', 'play|pause|pp|stop|prev|next|infobar|help', 'Commands Available\n' ' /moc - Display currently playing song.\n' ' /moc play - Start playing music.\n' ' /moc pause - Toggle between pause/playing.\n' ' /moc pp - Toggle between pause/playing.\n' ' /moc stop - Stop playing music.\n' ' /moc prev - Move to the previous song in the playlist.\n' ' /moc next - Move to the next song in the playlist.\n'