File: noirccolors.py

package info (click to toggle)
weechat-scripts 20161006-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,504 kB
  • ctags: 6,245
  • sloc: python: 37,508; perl: 27,405; ruby: 1,931; tcl: 226; lisp: 56; sh: 8; makefile: 7
file content (22 lines) | stat: -rw-r--r-- 945 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import weechat as w

SCRIPT_NAME    = "noirccolors"
SCRIPT_AUTHOR  = "Fredrick Brennan <fredrick.brennan1@gmail.com>"
SCRIPT_VERSION = "0.2"
SCRIPT_LICENSE = "Public domain"
SCRIPT_DESC    = "Remove IRC colors from buffers with the localvar 'noirccolors' set. To disable IRC colors in the current buffer, type /buffer set localvar_set_noirccolors true. You can also set this with autosetbuffer. :)"

w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '')


def my_modifier_cb(data, modifier, modifier_data, string):
    if w.buffer_get_string(w.buffer_search('irc',modifier_data.split(";")[1]),"localvar_noirccolors") == "true":
        try:
            nick, message = string.split("\t")
        except ValueError, e:
            return string
        return "%s\t%s" % (nick, w.string_remove_color(message,""))
    else:
        return string

hook = w.hook_modifier("weechat_print", "my_modifier_cb", "")