def styurl_config_cb(data, option, value): """Callback called when a script option is changed.""" global styurl_settings, line_hook pos = option.rfind('.') if pos > 0: name = option[pos + 1:] if name in styurl_settings: # Changing the buffer target requires us to re-hook to prevent # obsolete buffer types from getting styled if name == "buffer_type": if value in ("free", "formatted", "*"): w.unhook(line_hook) line_hook = w.hook_line(value, "", "", "styurl_line_cb", "") else: # Don't change buffer type if it is invalid w.prnt( "", SCRIPT_NAME + ": Invalid buffer type: '%s', " "not changing." % value) w.config_set_plugin(name, styurl_settings[name]) return w.WEECHAT_RC_ERROR styurl_settings[name] = value return w.WEECHAT_RC_OK
def toggle_refresh(pointer, name, value): global OPTIONS, hook_line option = name[len('plugins.var.python.' + SCRIPT_NAME + '.'):] # get optionname OPTIONS[option] = value # save new value if hook_line and option == 'message_tags' and value == "": weechat.unhook(hook_line) hook_line = False elif not hook_line and option == 'message_tags' and value != "": hook_line = weechat.hook_line('', '', OPTIONS['message_tags'], 'confusables', '') return weechat.WEECHAT_RC_OK
SCRIPT_LICENSE, SCRIPT_DESC, 'shutdown_cb', ''): weechat.hook_command( SCRIPT_NAME, SCRIPT_DESC, '', 'How to use script:\n' '\n' 'configure script options with either /set command or /fset ' + SCRIPT_NAME + '\n' 'create an filter to filter messages with tags created by this script ' '(by default, the script is using tag "confusable_filter").\n' '/filter add confusable * confusable_filter *\n' 'see /help filter\n' '', '', '', '') version = weechat.info_get('version_number', '') or 0 # get weechat version (3.2) and store it if int(version) >= 0x03020000: # init options from your script init_options() hook_line = weechat.hook_line('', '', OPTIONS['message_tags'], 'confusables', '') # create a hook for your options hook_config = weechat.hook_config( 'plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '') else: weechat.prnt( '', '%s%s %s' % (weechat.prefix('error'), SCRIPT_NAME, ': needs version 3.2 or higher')) weechat.command('', '/wait 1ms /python unload %s' % SCRIPT_NAME)
"""Callback called when the script is unloaded.""" global line_hook w.unhook(line_hook) del line_hook return w.WEECHAT_RC_OK if __name__ == "__main__" and import_ok: if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "styurl_unload_cb", ""): version = w.info_get("version_number", "") or 0 for option, value in styurl_settings.items(): if w.config_is_set_plugin(option): styurl_settings[option] = w.config_get_plugin(option) else: w.config_set_plugin(option, value[0]) styurl_settings[option] = value[0] if int(version) >= 0x00030500: w.config_set_desc_plugin( option, "%s (default: \"%s\")" % (value[1], value[0])) w.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "styurl_config_cb", "") # Style URLs line_hook = w.hook_line(styurl_settings["buffer_type"], "", "", "styurl_line_cb", "")
"\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 now by default limits the level of NOTICEs from twitch server\n" " What this does is makes it so 'Now hosting' notifications are classes as a low level message\n" " So they no longer show up in your hotlist like a 'actual' message\n" " If you would like to disable this set the following\n" " /set plugins.var.python.twitch.notice_notify_block 0\n" "\n" " If would like to use your own Client-ID it can be set with\n" " /set plugins.var.python.twitch.client_id (clientid)\n" "\n" " This script also has whisper support that works like a standard query. \"/query user\"\n\n", "", "twitch_main", "") weechat.hook_signal('buffer_switch', 'twitch_buffer_switch', '') weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'config_change', '') config_setup() weechat.hook_line("", "", "irc_notice+nick_tmi.twitch.tv", "twitch_notice", "") weechat.hook_modifier("irc_in2_CLEARCHAT", "twitch_clearchat", "") weechat.hook_modifier("irc_in2_CLEARMSG", "twitch_clearmsg", "") weechat.hook_modifier("irc_in2_RECONNECT", "twitch_reconnect", "") weechat.hook_modifier("irc_in2_USERSTATE", "twitch_suppress", "") weechat.hook_modifier("irc_in2_HOSTTARGET", "twitch_suppress", "") weechat.hook_modifier("irc_in2_ROOMSTATE", "twitch_roomstate", "") weechat.hook_modifier("irc_in2_USERNOTICE", "twitch_usernotice", "") weechat.hook_modifier("irc_in_WHISPER", "twitch_whisper", "") weechat.hook_modifier("irc_out_PRIVMSG", "twitch_privmsg", "") weechat.hook_modifier("irc_out_WHOIS", "twitch_whois", "") weechat.hook_modifier("irc_in2_PRIVMSG", "twitch_in_privmsg", "")
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. import weechat SCRIPT_NAME = "message_spacer" SCRIPT_AUTHOR = "davidj361 <*****@*****.**>" SCRIPT_VERSION = "0.1" SCRIPT_LICENSE = "GPL" SCRIPT_DESC = "Adds spaces/separators between messages of different users" bufLastNick = {} def separate(data, line): buf = line['buffer'] nick = line['prefix'] if buf in bufLastNick and nick != bufLastNick[buf]: weechat.prnt(buf, '\t\t') bufLastNick[buf] = nick return {} if __name__ == "__main__": if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): weechat.hook_line('', '', 'irc_privmsg', 'separate', '')