about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBen Harris <ben@tilde.team>2019-02-04 14:16:40 -0500
committerBen Harris <ben@tilde.team>2019-02-04 14:16:40 -0500
commit4f04567a43ea62158f0b77630ebef8622c56a06b (patch)
treeefa2f288dea749f419a620aa67fd00442b03c18f
parent56fb407f784884edab0c6088776cafcf3869bd7a (diff)
cool new aliases
-rw-r--r--weechat/.weechat/alias.conf3
-rw-r--r--weechat/.weechat/irc.conf2
-rw-r--r--weechat/.weechat/logger.conf2
-rw-r--r--weechat/.weechat/plugins.conf1
l---------weechat/.weechat/python/autoload/bitlbee_completion.py1
l---------weechat/.weechat/python/autoload/completion.py1
-rw-r--r--weechat/.weechat/python/bitlbee_completion.py114
-rw-r--r--weechat/.weechat/python/completion.py266
-rw-r--r--weechat/.weechat/trigger.conf32
-rw-r--r--weechat/.weechat/weechat.conf2
10 files changed, 421 insertions, 3 deletions
diff --git a/weechat/.weechat/alias.conf b/weechat/.weechat/alias.conf
index b94f415..bd74977 100644
--- a/weechat/.weechat/alias.conf
+++ b/weechat/.weechat/alias.conf
@@ -29,6 +29,7 @@ J = "join"
 K = "kick"
 KB = "kickban"
 LEAVE = "part"
+lenny = "/msg $channel ( ͡° ͜ʖ ͡°)"
 M = "msg"
 MS = "quote memoserv"
 MSGBUF = "command -buffer $1 * /input send $2-"
@@ -41,9 +42,11 @@ REDRAW = "window refresh"
 save_settings = "/autojoin --run;/layout store;/save"
 SAY = "msg *"
 setup_aspell = "/set weechat.bar.rootinput.items [input_prompt]+(away),[input_search],[input_paste],input_text,aspell_suggest;/set aspell.check.default_dict en_US;/set aspell.check.suggestions 4;/set aspell.check.enabled on;/unalias setup_aspell;/save"
+shrug = "/msg $channel ¯\_(ツ)_/¯"
 SIGNOFF = "quit"
 SLAP = "me slaps $1 around a bit with a large trout"
 T = "topic"
+tf = "/msg $channel (ノಥ益ಥ)ノ彡┻━┻"
 UB = "unban"
 UMODE = "mode $nick"
 V = "command core version"
diff --git a/weechat/.weechat/irc.conf b/weechat/.weechat/irc.conf
index c6390f6..1182321 100644
--- a/weechat/.weechat/irc.conf
+++ b/weechat/.weechat/irc.conf
@@ -221,7 +221,7 @@ hashbang.local_hostname
 hashbang.usermode
 hashbang.command = "/oper benharri x"
 hashbang.command_delay
-hashbang.autojoin = "#dots,#!,#!social,#!os,#!politics,#!space,#!support,#!opers"
+hashbang.autojoin = "#!support,#!space,#!politics,#!os,#!social,#!,#dots,#!opers"
 hashbang.autorejoin
 hashbang.autorejoin_delay
 hashbang.connection_timeout
diff --git a/weechat/.weechat/logger.conf b/weechat/.weechat/logger.conf
index 3c01580..71e3104 100644
--- a/weechat/.weechat/logger.conf
+++ b/weechat/.weechat/logger.conf
@@ -10,7 +10,7 @@
 #
 
 [look]
-backlog = 2147483647
+backlog = 2000
 backlog_conditions = ""
 
 [color]
diff --git a/weechat/.weechat/plugins.conf b/weechat/.weechat/plugins.conf
index 2f325eb..b01977a 100644
--- a/weechat/.weechat/plugins.conf
+++ b/weechat/.weechat/plugins.conf
@@ -67,6 +67,7 @@ python.buffer_autoclose.age_limit = "30"
 python.buffer_autoclose.ignore = ""
 python.buffer_autoclose.interval = "1"
 python.check_license = "off"
+python.completion.replace_values = "shrug=>¯\_(ツ)_/¯;;tf=>(ノಥ益ಥ)ノ彡┻━┻;;lenny=>( ͡° ͜ʖ ͡°)"
 python.go.auto_jump = "off"
 python.go.buffer_number = "on"
 python.go.color_name = "black,cyan"
diff --git a/weechat/.weechat/python/autoload/bitlbee_completion.py b/weechat/.weechat/python/autoload/bitlbee_completion.py
new file mode 120000
index 0000000..1bc83b6
--- /dev/null
+++ b/weechat/.weechat/python/autoload/bitlbee_completion.py
@@ -0,0 +1 @@
+../bitlbee_completion.py
\ No newline at end of file
diff --git a/weechat/.weechat/python/autoload/completion.py b/weechat/.weechat/python/autoload/completion.py
new file mode 120000
index 0000000..736270f
--- /dev/null
+++ b/weechat/.weechat/python/autoload/completion.py
@@ -0,0 +1 @@
+../completion.py
\ No newline at end of file
diff --git a/weechat/.weechat/python/bitlbee_completion.py b/weechat/.weechat/python/bitlbee_completion.py
new file mode 100644
index 0000000..be6f80e
--- /dev/null
+++ b/weechat/.weechat/python/bitlbee_completion.py
@@ -0,0 +1,114 @@
+# -*- coding: utf-8 -*-
+# Add tab completion to bitlbee commands
+# based on http://scripts.irssi.org/scripts/bitlbee_tab_completion.pl
+#
+# History:
+#
+# 2015-11-02, Mickaël Thomas <mickael9@gmail.com>:
+#     version 0.2: strip color attributes for topic detection
+# 2015-03-22, Roger Duran <rogerduran@gmail.com>:
+#     version 0.1: initial version
+
+import weechat
+
+SCRIPT_NAME = "bitlbee_completion"
+SCRIPT_AUTHOR = "Roger Duran <rogerduran@gmail.com>"
+SCRIPT_VERSION = "0.2"
+SCRIPT_LICENSE = "GPL3"
+SCRIPT_DESC = "Add tab completion to bitlbee commands"
+
+OPTS = {
+    "server": None,
+    "channel": None
+    }
+
+TOPIC = "Welcome to the control channel. "\
+    "Type help for help information."
+
+commands = []
+
+
+def request_completion():
+    """
+    Request the completion to the bitlbee server and wait for response
+    """
+    server = OPTS["server"]
+    weechat.command(server, "/quote -server %s COMPLETIONS" % server)
+
+
+def modifier_cb(data, modifier, modifier_data, string):
+    """
+    When the server returns the completion, update the commands list
+    """
+
+    if ":COMPLETIONS" not in string:
+        return string
+    command = string.split(":COMPLETIONS ")[1]
+    if command not in ("OK", "END"):
+        commands.append(command)
+    return ""
+
+
+def bitlbee_completion(data, completion_item, buffer, completion):
+    """
+    Complete bitlbee commands only in the bitlbee buffer
+    """
+
+    server = OPTS["server"]
+    channel = OPTS["channel"]
+    if not server or not channel:
+        return weechat.WEECHAT_RC_OK
+
+    buff_name = weechat.buffer_get_string(buffer, "name")
+    if buff_name == "%s.%s" % (server, channel):
+        for command in commands:
+            weechat.hook_completion_list_add(completion, command, 0,
+                                             weechat.WEECHAT_LIST_POS_SORT)
+    return weechat.WEECHAT_RC_OK
+
+
+def find_buffer():
+    """
+    Find the buffer when the plugin starts
+    """
+    infolist = weechat.infolist_get("buffer", "", "")
+    while weechat.infolist_next(infolist):
+        topic = weechat.infolist_string(infolist, "title")
+        if weechat.string_remove_color(topic, "") == TOPIC:
+            name = weechat.infolist_string(infolist, "name")
+            set_options(name)
+            request_completion()
+            break
+    weechat.infolist_free(infolist)
+
+
+def set_options(name):
+    server, channel = name.split(".")
+    OPTS["server"] = server
+    OPTS["channel"] = channel
+
+
+def print_332(data, buffer, time, tags, displayed, highlight, prefix, message):
+    """
+    Find the buffer when a new one is open
+    """
+    if weechat.string_remove_color(message, "") == TOPIC:
+        name = weechat.buffer_get_string(buffer, "name")
+        set_options(name)
+        request_completion()
+    return weechat.WEECHAT_RC_OK
+
+
+def main():
+    weechat.hook_modifier("irc_in_notice", "modifier_cb", "")
+    weechat.hook_completion("bitlbee", "bitlbee completion",
+                            "bitlbee_completion", "")
+
+    weechat.hook_print('', 'irc_332', '', 1, 'print_332', '')
+    weechat.hook_print('', 'irc_topic', '', 1, 'print_332', '')
+    find_buffer()
+
+if __name__ == "__main__":
+    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
+                        SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
+        main()
diff --git a/weechat/.weechat/python/completion.py b/weechat/.weechat/python/completion.py
new file mode 100644
index 0000000..62a69ae
--- /dev/null
+++ b/weechat/.weechat/python/completion.py
@@ -0,0 +1,266 @@
+# -*- coding: utf-8 -*-
+###
+# Copyright (c) 2010 by Elián Hanisch <lambdae2@gmail.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+###
+
+###
+#
+#   This scripts adds word completion, like irssi's /completion
+#   (depends on WeeChat 0.3.1 or newer)
+#
+#   Commands:
+#   * /completion: see /help completion
+#
+#
+#   Settings:
+#   * plugins.var.python.completion.replace_values:
+#     Completion list, it shouldn't be edited by hand.
+#
+#
+#   History:
+#   2010-05-08
+#   version 0.2:
+#   * complete any word behind the cursor, not just the last one in input line.
+#   * change script display name 'completion' to 'cmpl'.
+#
+#   2010-01-26
+#   version 0.1: release
+#
+###
+
+try:
+    import weechat
+    WEECHAT_RC_OK = weechat.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    = "completion"
+SCRIPT_AUTHOR  = "Elián Hanisch <lambdae2@gmail.com>"
+SCRIPT_VERSION = "0.2"
+SCRIPT_LICENSE = "GPL3"
+SCRIPT_DESC    = "Word completions for WeeChat"
+SCRIPT_COMMAND = "completion"
+
+### Config ###
+settings = {
+'replace_values':''
+}
+
+### Messages ###
+def decode(s):
+    if isinstance(s, str):
+        s = s.decode('utf-8')
+    return s
+
+def encode(u):
+    if isinstance(u, unicode):
+        u = u.encode('utf-8')
+    return u
+
+def debug(s, prefix='', buffer=None):
+    """Debug msg"""
+    #if not weechat.config_get_plugin('debug'): return
+    if buffer is None:
+        buffer_name = 'DEBUG_' + SCRIPT_NAME
+        buffer = weechat.buffer_search('python', buffer_name)
+        if not buffer:
+            buffer = weechat.buffer_new(buffer_name, '', '', '', '')
+            weechat.buffer_set(buffer, 'nicklist', '0')
+            weechat.buffer_set(buffer, 'time_for_each_line', '0')
+            weechat.buffer_set(buffer, 'localvar_set_no_log', '1')
+    s = encode(s)
+    weechat.prnt(buffer, '%s\t%s' %(prefix, s))
+
+def error(s, prefix=None, buffer='', trace=''):
+    """Error msg"""
+    prefix = prefix or script_nick
+    s = encode(s)
+    weechat.prnt(buffer, '%s%s %s' %(weechat.prefix('error'), prefix, s))
+    if weechat.config_get_plugin('debug'):
+        if not trace:
+            import traceback
+            if traceback.sys.exc_type:
+                trace = traceback.format_exc()
+        not trace or weechat.prnt('', trace)
+
+def say(s, prefix=None, buffer=''):
+    """normal msg"""
+    prefix = prefix or script_nick
+    s = encode(s)
+    weechat.prnt(buffer, '%s\t%s' %(prefix, s))
+
+print_replace = lambda k,v : say('%s %s=>%s %s' %(k, color_delimiter, color_reset, v))
+
+### Config functions ###
+class UTFDict(dict):
+    decode = staticmethod(decode)
+    encode = staticmethod(encode)
+
+    def __init__(self, d={}):
+        dict.__init__(self)
+        for k, v in d.iteritems():
+            self[k] = v
+
+    def __setitem__(self, k, v):
+        k = self.decode(k)
+        v = self.decode(v)
+        dict.__setitem__(self, k, v)
+
+    def __getitem__(self, k):
+        k = self.decode(k)
+        return dict.__getitem__(self, k)
+
+    def __delitem__(self, k):
+        k = self.decode(k)
+        dict.__delitem__(self, k)
+
+    def __contains__(self, k):
+        k = self.decode(k)
+        return dict.__contains__(self, k)
+
+    def __str__(self):
+        values = [ '%s=>%s' %(k, v) for k, v in self.iteritems() ]
+        values = ';;'.join(values)
+        return self.encode(values)
+
+
+def get_config_dict(config):
+    value = weechat.config_get_plugin(config)
+    if not value:
+        return {}
+    values = value.split(';;')
+    values = map(lambda s: s.split('=>'), values)
+    #debug(values)
+    return dict(values)
+
+def load_replace_table():
+    global replace_table
+    replace_table = UTFDict(get_config_dict('replace_values'))
+
+def save_replace_table():
+    global replace_table
+    weechat.config_set_plugin('replace_values', str(replace_table))
+
+### Commands ###
+def cmd_completion(data, buffer, args):
+    global replace_table
+    if not args:
+        if replace_table:
+            for k, v in replace_table.iteritems():
+                print_replace(k, v)
+        else:
+            say('No completions.')
+        return WEECHAT_RC_OK
+    cmd, space, args = args.partition(' ')
+    if cmd == 'add':
+        word, space, text = args.partition(' ')
+        k, v = word.strip(), text.strip()
+        replace_table[k] = v
+        save_replace_table()
+        say('added: %s %s=>%s %s' %(k, color_delimiter, color_reset, v))
+    elif cmd == 'del':
+        k = args.strip()
+        try:
+            del replace_table[k]
+            save_replace_table()
+            say("completion for '%s' deleted." %k)
+            save_replace_table()
+        except KeyError:
+            error("completion for '%s' not found." %k)
+    return WEECHAT_RC_OK
+
+### Completion ###
+def completion_replacer(data, completion_item, buffer, completion):
+    global replace_table
+    pos = weechat.buffer_get_integer(buffer, 'input_pos')
+    input = decode(weechat.buffer_get_string(buffer, 'input'))
+    #debug('%r %s %s' %(input, len(input), pos))
+    if pos > 0 and (pos == len(input) or input[pos] == ' '):
+        n = input.rfind(' ', 0, pos)
+        word = input[n+1:pos]
+        #debug(repr(word))
+        if word in replace_table:
+            replace = replace_table[word]
+            if pos >= len(input.strip()):
+                # cursor is in the end of line, append a space
+                replace += ' '
+            n = len(word)
+            input = '%s%s%s' %(input[:pos-n], replace, input[pos:])
+            weechat.buffer_set(buffer, 'input', encode(input))
+            weechat.buffer_set(buffer, 'input_pos', str(pos - n + len(replace)))
+    return WEECHAT_RC_OK
+
+def completion_keys(data, completion_item, buffer, completion):
+    global replace_table
+    for k in replace_table:
+        weechat.hook_completion_list_add(completion, encode(k), 0, weechat.WEECHAT_LIST_POS_SORT)
+    return WEECHAT_RC_OK
+
+### Main ###
+if __name__ == '__main__' and import_ok and \
+        weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, \
+        SCRIPT_DESC, '', ''):
+
+    # colors
+    color_delimiter   = weechat.color('chat_delimiters')
+    color_script_nick = weechat.color('chat_nick')
+    color_reset   = weechat.color('reset')
+
+    # pretty [SCRIPT_NAME]
+    script_nick = '%s[%s%s%s]%s' %(color_delimiter, color_script_nick, 'cmpl', color_delimiter,
+            color_reset)
+
+    version = weechat.info_get('version', '')
+    if version == '0.3.0':
+        error('WeeChat 0.3.1 or newer is required for this script.')
+    else:
+        # settings
+        for opt, val in settings.iteritems():
+            if not weechat.config_is_set_plugin(opt):
+                weechat.config_set_plugin(opt, val)
+
+        load_replace_table()
+
+        completion_template = 'completion_script'
+        weechat.hook_completion(completion_template,
+                "Replaces last word in input by its configured value.", 'completion_replacer', '')
+        weechat.hook_completion('completion_keys', "Words in completion list.", 'completion_keys', '')
+
+        weechat.hook_command(SCRIPT_COMMAND, SCRIPT_DESC , "[add <word> <text>|del <word>]",
+"""
+add: adds a new completion, <word> => <text>.
+del: deletes a completion.
+Without arguments it displays current completions.
+
+<word> will be replaced by <text> when pressing tab in input line,
+where <word> is any word currently behind the cursor.
+
+Setup:
+For this script to work, you must add the template
+%%(%(completion)s) to the default completion template, use:
+/set weechat.completion.default_template "%%(nicks)|%%(irc_channels)|%%(%(completion)s)"
+
+Examples:
+/%(command)s add wee WeeChat (typing wee<tab> will replace 'wee' by 'WeeChat')
+/%(command)s add weeurl http://www.weechat.org/
+/%(command)s add test This is a test!
+""" %dict(completion=completion_template, command=SCRIPT_COMMAND),
+            'add|del %(completion_keys)', 'cmd_completion', '')
+
+# vim:set shiftwidth=4 tabstop=4 softtabstop=4 expandtab textwidth=100:
diff --git a/weechat/.weechat/trigger.conf b/weechat/.weechat/trigger.conf
index fbff88e..6e0796e 100644
--- a/weechat/.weechat/trigger.conf
+++ b/weechat/.weechat/trigger.conf
@@ -57,6 +57,30 @@ msg_auth.hook = modifier
 msg_auth.post_action = none
 msg_auth.regex = "==^(.*(id|identify|register|ghost +[^ ]+|release +[^ ]+) +)(.*)==${re:1}${hide:*,${re:+}}"
 msg_auth.return_code = ok
+pong.arguments = ""
+pong.command = "pong"
+pong.conditions = "${type} == private && ${tg_message} == ping"
+pong.enabled = on
+pong.hook = print
+pong.post_action = none
+pong.regex = ""
+pong.return_code = ok
+resize_big.arguments = "signal_sigwinch"
+resize_big.command = "/bar show nicklist"
+resize_big.conditions = "${info:term_width} >= 100"
+resize_big.enabled = on
+resize_big.hook = signal
+resize_big.post_action = none
+resize_big.regex = ""
+resize_big.return_code = ok
+resize_small.arguments = "signal_sigwinch"
+resize_small.command = "/bar hide nicklist"
+resize_small.conditions = "${info:term_width} < 100"
+resize_small.enabled = on
+resize_small.hook = signal
+resize_small.post_action = none
+resize_small.regex = ""
+resize_small.return_code = ok
 server_pass.arguments = "5000|input_text_display;5000|history_add"
 server_pass.command = ""
 server_pass.conditions = ""
@@ -65,3 +89,11 @@ server_pass.hook = modifier
 server_pass.post_action = none
 server_pass.regex = "==^(/(server|connect) .*-(sasl_)?password=)([^ ]+)(.*)==${re:1}${hide:*,${re:4}}${re:5}"
 server_pass.return_code = ok
+url_color.arguments = "weechat_print"
+url_color.command = ""
+url_color.conditions = "${tg_notify}"
+url_color.enabled = on
+url_color.hook = modifier
+url_color.post_action = none
+url_color.regex = "==\S+://\S+==${color:blue}${re:0}${color:reset}=="
+url_color.return_code = ok
diff --git a/weechat/.weechat/weechat.conf b/weechat/.weechat/weechat.conf
index 99e35e8..8c9e4cf 100644
--- a/weechat/.weechat/weechat.conf
+++ b/weechat/.weechat/weechat.conf
@@ -207,7 +207,7 @@ status_time = default
 [completion]
 base_word_until_cursor = on
 command_inline = on
-default_template = "%(nicks)|%(irc_channels)"
+default_template = "%(nicks)|%(irc_channels)|%(completion_script)"
 nick_add_space = on
 nick_case_sensitive = off
 nick_completer = ":"