From 0176e216f2aab237d5bda42706c1b8a7ee59e9c2 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 11 Aug 2018 16:39:57 -0400 Subject: add same_nick --- weechat/.weechat/irc.conf | 2 +- weechat/.weechat/python/aformat.py | 121 ++++++++++++++++++++++++++++ weechat/.weechat/python/autoload/aformat.py | 1 + weechat/.weechat/relay.conf | 2 +- weechat/.weechat/ruby/auth.rb | 89 ++++++++++++++++++++ weechat/.weechat/ruby/autoload/auth.rb | 1 + weechat/.weechat/urlserver_list.txt | 3 + weechat/.weechat/weechat.conf | 5 +- 8 files changed, 220 insertions(+), 4 deletions(-) create mode 100644 weechat/.weechat/python/aformat.py create mode 120000 weechat/.weechat/python/autoload/aformat.py create mode 100644 weechat/.weechat/ruby/auth.rb create mode 120000 weechat/.weechat/ruby/autoload/auth.rb create mode 100644 weechat/.weechat/urlserver_list.txt (limited to 'weechat') diff --git a/weechat/.weechat/irc.conf b/weechat/.weechat/irc.conf index cbe63c8..76ef3df 100644 --- a/weechat/.weechat/irc.conf +++ b/weechat/.weechat/irc.conf @@ -407,7 +407,7 @@ gitter.ssl_priorities gitter.ssl_dhkey_size gitter.ssl_fingerprint gitter.ssl_verify -gitter.password = "323cf7b2994d646e80b261c0d5bc546b766fe0c6" +gitter.password = "${sec.data.gitterpass}" gitter.capabilities gitter.sasl_mechanism gitter.sasl_username diff --git a/weechat/.weechat/python/aformat.py b/weechat/.weechat/python/aformat.py new file mode 100644 index 0000000..bd8d096 --- /dev/null +++ b/weechat/.weechat/python/aformat.py @@ -0,0 +1,121 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2016 Hairo R. Carela +# +# Everyone is permitted to copy and distribute verbatim or modified +# copies of this license document, and changing it is allowed as long +# as the name is changed. +# +# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +# +# 0. You just DO WHAT THE FUCK YOU WANT TO. +# +# Alternate way of text formatting, useful for relays without text formatting +# features (Glowingbear, WeechatAndroid, etc) +# +# Usage: +# /aformat *text* for bold text +# /aformat /text/ for italic text +# /aformat _text_ for underlined text +# /aformat |text| for reversed (black on white) text +# +# History: +# 2016-09-24: +# v0.1: Initial release +# 2018-06-19: +# v0.2: py3k-ok +# +# TODO: +# - Colors support + +import sys + +try: + import weechat + from weechat import WEECHAT_RC_OK + import_ok = True +except ImportError: + print("This script must be run under WeeChat.") + print("Get WeeChat now at: http://www.weechat.org/") + import_ok = False + +SCRIPT_NAME = "aformat" +SCRIPT_AUTHOR = "Hairo R. Carela " +SCRIPT_VERSION = "0.2" +SCRIPT_LICENSE = "WTFPL" +SCRIPT_DESC = ("Alternate way of text formatting, see /help for instructions") + +PY3 = sys.version > '3' + +class format: + # Special byte sequences, using weechat.color("stuff") had some unwanted + # results, i'll look into it if needed. Colors are unused for now + BOLD = '\x02' + ITALIC = '\x1D' + UNDERLINE = '\x1F' + REVERSE = '\x16' + END = '\x0F' + +if PY3: + unichr = chr + def send(buf, text): + weechat.command(buf, "/input send {}".format(text)) +else: + def send(buf, text): + weechat.command(buf, "/input send {}".format(text.encode("utf-8"))) + +def cb_aformat_cmd(data, buf, args): + if not PY3: + args = args.decode("utf-8") + + # Get the indexes of the separators (*/_|) in the string + bolds = [i for i, ltr in enumerate(args) if ltr == "*"] + italics = [i for i, ltr in enumerate(args) if ltr == "/"] + underlines = [i for i, ltr in enumerate(args) if ltr == "_"] + reverses = [i for i, ltr in enumerate(args) if ltr == "|"] + + if len(bolds) != 0: + for i, v in enumerate(bolds): + if i%2 == 0: + args = args[:v] + format.BOLD + args[v+1:] + else: + args = args[:v] + format.END + args[v+1:] + + if len(italics) != 0: + for i, v in enumerate(italics): + if i%2 == 0: + args = args[:v] + format.ITALIC + args[v+1:] + else: + args = args[:v] + format.END + args[v+1:] + + if len(underlines) != 0: + for i, v in enumerate(underlines): + if i%2 == 0: + args = args[:v] + format.UNDERLINE + args[v+1:] + else: + args = args[:v] + format.END + args[v+1:] + + if len(reverses) != 0: + for i, v in enumerate(reverses): + if i%2 == 0: + args = args[:v] + format.REVERSE + args[v+1:] + else: + args = args[:v] + format.END + args[v+1:] + + send(buf, args) + return weechat.WEECHAT_RC_OK + + +if import_ok and __name__ == "__main__": + weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, + SCRIPT_LICENSE, SCRIPT_DESC, '', '') + weechat.hook_command("aformat", "Alternate way of text formatting, useful for relays without text formatting features (Glowingbear, WeechatAndroid, etc)", + "text <*/_|> text <*/_|> more text", + " *: bold text\n" + " /: italic text\n" + " _: underlined text\n" + " |: reversed (black on white) text\n\n" + " eg.: typing: /aformat This /must/ be the *work* of an _enemy_ |stand|\n" + " will output: This {0}must{4} be the {1}work{4} of an {2}enemy{4} {3}stand{4}".format(weechat.color("italic"), weechat.color("bold"), weechat.color("underline"), weechat.color("reverse"), weechat.color("reset")), + "", "cb_aformat_cmd", "") diff --git a/weechat/.weechat/python/autoload/aformat.py b/weechat/.weechat/python/autoload/aformat.py new file mode 120000 index 0000000..d7b05c3 --- /dev/null +++ b/weechat/.weechat/python/autoload/aformat.py @@ -0,0 +1 @@ +../aformat.py \ No newline at end of file diff --git a/weechat/.weechat/relay.conf b/weechat/.weechat/relay.conf index 5fbc8ff..fef9667 100644 --- a/weechat/.weechat/relay.conf +++ b/weechat/.weechat/relay.conf @@ -32,7 +32,7 @@ clients_purge_delay = 0 compression_level = 6 ipv6 = on max_clients = 5 -password = "${sec.data.pass}" +password = "${sec.data.relaypass}" ssl_cert_key = "%h/ssl/relay.pem" ssl_priorities = "NORMAL:-VERS-SSL3.0" websocket_allowed_origins = "" diff --git a/weechat/.weechat/ruby/auth.rb b/weechat/.weechat/ruby/auth.rb new file mode 100644 index 0000000..c304cab --- /dev/null +++ b/weechat/.weechat/ruby/auth.rb @@ -0,0 +1,89 @@ +# Copyright (c) 2013 Shawn Smith +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# 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 . + + +def weechat_init + # Register our plugin with WeeChat + Weechat.register("auth", + "Shawn Smith", + "0.3", + "GPL3", + "Automatically authenticate with NickServ using your sasl_username and sasl_password.", + "", + "") + + Weechat.hook_command("auth", + "Automatically authenticate with NickServ using your sasl_username and sasl_password.", + "list [server]", + "list: Displays your sasl_username and sasl_password", + "", + "auth_command_cb", + "") + + # Grab the hook for notices. + Weechat.hook_signal("*,irc_in_notice", "auth_notice_cb", "") + + return Weechat::WEECHAT_RC_OK +end + +# The auth command +def auth_command_cb(data, buffer, args) + server = buffer.split(',')[0] + arg = args.split(' ') + + # Check to make sure we were given a valid option. + if arg[0] == "list" && arg[1] + server = arg[1] + + # Grab the pointers from the config + sasl_username = Weechat.config_get("irc.server.#{server}.sasl_username") + sasl_password = Weechat.config_get("irc.server.#{server}.sasl_password") + + # Print the usernames/passwords + Weechat.print("", "[Auth]: sasl_username: #{Weechat.string_eval_expression("#{wee_string(sasl_username)}", {}, {}, {})}") + Weechat.print("", "[Auth]: sasl_password: #{Weechat.string_eval_expression("#{wee_string(sasl_password)}", {}, {}, {})}") + else + Weechat.command("", "/help auth") + end + + return Weechat::WEECHAT_RC_OK +end + +# The incoming notice. +def auth_notice_cb(data, buffer, args) + # Notice should come from nickserv, otherwise we ignore it. + if /^:NickServ!.+:This nickname is registered/i =~ args + # Get the server that we're on. + server = buffer.split(',')[0] + + # Grab the username/passwords if we have them. + sasl_username = Weechat.config_get("irc.server.#{server}.sasl_username") + sasl_password = Weechat.config_get("irc.server.#{server}.sasl_password") + + # Prevents us from sending empty passwords. + if sasl_password != nil + Weechat.command("", "/quote -server #{server} PRIVMSG NickServ IDENTIFY #{Weechat.string_eval_expression("#{wee_string(sasl_username)}", {}, {}, {})} #{Weechat.string_eval_expression("#{wee_string(sasl_password)}", {}, {}, {})}") + + # Backwards compatibility hack for shitty servers that don't let you use [nick pass] + Weechat.command("", "/quote -server #{server} PRIVMSG NickServ IDENTIFY #{Weechat.string_eval_expression("#{wee_string(sasl_password)}", {}, {}, {})}") + end + end + + return Weechat::WEECHAT_RC_OK +end + +def wee_string(input) + return Weechat.config_string(input) +end diff --git a/weechat/.weechat/ruby/autoload/auth.rb b/weechat/.weechat/ruby/autoload/auth.rb new file mode 120000 index 0000000..08c0b0f --- /dev/null +++ b/weechat/.weechat/ruby/autoload/auth.rb @@ -0,0 +1 @@ +../auth.rb \ No newline at end of file diff --git a/weechat/.weechat/urlserver_list.txt b/weechat/.weechat/urlserver_list.txt new file mode 100644 index 0000000..0db3279 --- /dev/null +++ b/weechat/.weechat/urlserver_list.txt @@ -0,0 +1,3 @@ +{ + +} diff --git a/weechat/.weechat/weechat.conf b/weechat/.weechat/weechat.conf index 44dd173..0bc6e68 100644 --- a/weechat/.weechat/weechat.conf +++ b/weechat/.weechat/weechat.conf @@ -54,7 +54,7 @@ day_change_message_1date = "-- %a, %d %b %Y --" day_change_message_2dates = "-- %%a, %%d %%b %%Y (%a, %d %b %Y) --" eat_newline_glitch = off emphasized_attributes = "" -highlight = "" +highlight = "ben" highlight_regex = "" highlight_tags = "" hotlist_add_conditions = "${away} || ${buffer.num_displayed} == 0" @@ -110,7 +110,7 @@ prefix_error = "=!=" prefix_join = "-->" prefix_network = "--" prefix_quit = "<--" -prefix_same_nick = "" +prefix_same_nick = "↪" prefix_suffix = "│" quote_nick_prefix = "<" quote_nick_suffix = ">" @@ -354,6 +354,7 @@ default.window = "3;1;0;0;core;weechat" default.current = on [notify] +irc.bitlbee = highlight irc.darwin = message irc.freenode.##csharp = highlight irc.freenode.#litepub = highlight -- cgit 1.4.1