minor fixes in colo.py
This commit is contained in:
parent
eb0faa09eb
commit
c05ec219e6
@ -36,7 +36,7 @@ settings = {
|
||||
"%c13♥ %0%s%o %c13♥",
|
||||
"Format string for text. %0 - %9 are different colours, %s is text, "
|
||||
"%c %b %u %r %o are ^C ^B ^U ^R ^O respectively, and %% is a literal "
|
||||
"percent sign.",
|
||||
"percent sign. %0 is the primary colour that should be used with %s.",
|
||||
),
|
||||
"fgs": (
|
||||
"04,05,06,13",
|
||||
@ -75,7 +75,6 @@ settings = {
|
||||
}
|
||||
|
||||
|
||||
|
||||
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
|
||||
SCRIPT_DESC, "", ""):
|
||||
for opt, val in settings.iteritems():
|
||||
@ -86,12 +85,24 @@ if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
|
||||
|
||||
weechat.hook_modifier("input_text_for_buffer", "cb_colo", "")
|
||||
|
||||
# prevent looping
|
||||
nest = False
|
||||
|
||||
def glob_match (haystack, needle):
|
||||
return re.search("^%s$" %
|
||||
re.escape(haystack).replace(r"\?", ".").replace(r"\*", ".*?"),
|
||||
needle)
|
||||
|
||||
def is_command (string):
|
||||
return (string.startswith("/") and not string.startswith("/ ") and
|
||||
string != "/" and string.split(" ", 1)[0].split("\n", 1)[0].find("/", 1)
|
||||
< 0)
|
||||
|
||||
def cb_colo (data, mod, buf, input):
|
||||
global nest
|
||||
if nest:
|
||||
nest = False
|
||||
return input
|
||||
buffer_name = weechat.buffer_get_string(buf, "name").lower()
|
||||
output = ""
|
||||
profile = ""
|
||||
@ -109,8 +120,7 @@ def cb_colo (data, mod, buf, input):
|
||||
if not input:
|
||||
return input
|
||||
|
||||
if (input.startswith("/") and not input.startswith("/ ") and input != "/"
|
||||
and input.split(" ", 1)[0].split("\n", 1)[0].find("/", 1) < 0):
|
||||
if is_command(input):
|
||||
for cmd in weechat.config_get_plugin("whitelist_cmds").lower().split(","):
|
||||
if not input.startswith("/%s " % cmd): continue
|
||||
output = "/%s " % cmd
|
||||
@ -154,13 +164,15 @@ def cb_colo (data, mod, buf, input):
|
||||
input.replace("\x0f","\x0f%s" % base))
|
||||
|
||||
fmt = "%".join(fmt)
|
||||
nest = is_command(fmt)
|
||||
|
||||
l = (409 - len(fmt) -
|
||||
int( weechat.info_get("irc_server_isupport_value", "%s,NICKLEN" %
|
||||
weechat.buffer_get_string(buf, "localvar_server")) )
|
||||
)
|
||||
o = []
|
||||
for line in input.replace("\r", "").split("\n"):
|
||||
for line in input.replace("\r", "\n").split("\n"):
|
||||
if not line: continue
|
||||
for i in xrange(0, len(line), l):
|
||||
o.append(fmt.replace("%s", line[i:i+l].rstrip()))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user