This commit is contained in:
wowaname 2016-02-17 01:12:49 +00:00
commit 2c39155159
4 changed files with 2314 additions and 0 deletions

0
conf/alias.conf Normal file
View File

158
scripts/embellish.py Normal file
View File

@ -0,0 +1,158 @@
# -*- coding: utf-8 -*-
#
# Released into the Public Domain
"""embellish: make your chats noticable"""
# v1.2 - wowaname
# whitelist_buffers added
# message won't be decorated if blank
# changed default ignore_buffers
# v1.1 - wowaname
# ignore_buffers has regex support
# additional profile support
# colours restored on ^C or ^O in message
# v1.0 - wowaname
# Initial release
import random
import re
import weechat
SCRIPT_NAME = "embellish"
SCRIPT_AUTHOR = "The Krusty Krab <wowaname@volatile.ch>"
SCRIPT_VERSION = "1.1"
SCRIPT_LICENSE = "Public domain"
SCRIPT_DESC = "Makes your chats noticable"
# script options
settings = {
"pre": (
"13♥",
"Text to add to the beginning of messages.",
),
"suf": (
"13♥",
"Text to add to the end of messages.",
),
"fgs": (
"04,05,06,13",
"Colour codes to cycle for the foreground. "
"Leave blank for no foreground colours.",
),
"bgs": (
"",
"Colour codes to cycle for the background. "
"Leave blank for no background colours.",
),
"ignore_buffers": (
"bitlbee.*,scripts",
"List of buffers to ignore. Glob matches unless "
"you prefix the name with 're:'.",
),
"whitelist_buffers": (
"",
"List of buffers to whitelist. Glob match unless "
"you prefix the name with 're:'. Useful with "
"ignore_buffers = \"*\"",
),
"whitelist_cmds": (
"me,amsg,say",
"Commands to embellish.",
),
"profiles": (
"> greentext,! alert",
"List of prefix/profile pairs. If you type one of "
"these prefixes at the beginning of your message, "
"the options will switch to (profile)_pre, "
"(profile)_suf, (profile)_fgs, and (profile)_bgs. ",
),
"greentext_pre": ">",
"greentext_suf": "",
"greentext_fgs": "03",
"greentext_bgs": "",
}
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
SCRIPT_DESC, "", ""):
for opt, val in settings.iteritems():
setting, desc = val if type(val) == tuple else (val, "")
if desc: weechat.config_set_desc_plugin(opt, desc)
if weechat.config_is_set_plugin(opt): continue
weechat.config_set_plugin(opt, setting)
weechat.hook_command_run("/input return", "cb_embellish", "")
def glob_match (haystack, needle):
return re.search("^%s$" %
re.escape(haystack).replace(r"\?", ".").replace(r"\*", ".*?"),
needle)
def cb_embellish(data, buffer, command):
buffer_name = weechat.buffer_get_string(buffer, "name").lower()
output = ""
profile = ""
for pattern in weechat.config_get_plugin("whitelist_buffers").lower().split(","):
if (pattern.startswith("re:") and
re.search(pattern[3:], buffer_name)) or glob_match(pattern, buffer_name):
break
else:
for pattern in weechat.config_get_plugin("ignore_buffers").lower().split(","):
if (pattern.startswith("re:") and
re.search(pattern[3:], buffer_name)) or glob_match(pattern, buffer_name):
return weechat.WEECHAT_RC_OK
if command == "/input return":
input = weechat.buffer_get_string(buffer, "input").rstrip()
if not input:
return weechat.WEECHAT_RC_OK
if input.startswith("/"):
for cmd in weechat.config_get_plugin("whitelist_cmds").lower().split(","):
if not input.startswith("/%s " % cmd): continue
output = "/%s " % cmd
input = input.split(" ",1)[1] if " " in input else ""
break
else:
return weechat.WEECHAT_RC_OK
for profile_pairs in weechat.config_get_plugin("profiles").split(","):
prefix, name = profile_pairs.split()
if not input.startswith("%s " % prefix): continue
profile = "%s_" % name
input = input.split(" ",1)[1] if " " in input else ""
for opt in ("pre", "suf", "fgs", "bgs"):
if weechat.config_is_set_plugin(profile + opt): continue
weechat.config_set_plugin(profile + opt, "")
break
fgs = weechat.config_get_plugin("%sfgs" % profile).split(",")
bgs = weechat.config_get_plugin("%sbgs" % profile).split(",")
base = "%s%s%s" % (
random.choice(fgs),
"," if bgs != [""] else "",
random.choice(bgs),
) if fgs != [""] or bgs != [""] else ""
if base:
input = re.sub(
"\x03([^0-9])",
"\x03%s\\1" % base,
input.replace("\x0f","\x0f%s" % base).replace(
"\r","\r%s" % base).replace(
"\n","\n%s" % base)
)
output += "%s%s%s %s%s %s" % (
base,
weechat.config_get_plugin("%spre" % profile),
base,
input,
base,
weechat.config_get_plugin("%ssuf" % profile),
)
weechat.buffer_set(buffer, "input", output)
return weechat.WEECHAT_RC_OK

105
scripts/masshl.py Normal file
View File

@ -0,0 +1,105 @@
# Released into the Public Domain
import random
#from threading import Thread
#from time import sleep
import weechat
SCRIPT_NAME = "masshl"
SCRIPT_AUTHOR = "The Krusty Krab <wowaname@volatile.ch>"
SCRIPT_VERSION = "1.0"
SCRIPT_LICENSE = "Public domain"
SCRIPT_DESC = "Provides nicklist hooks."
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
weechat.hook_command("masshl",
SCRIPT_DESC,
"[-do <delay>] text (broken, currently no-op)",
"-d Specify a delay at the beginning (e.g. -d 1 for\n"
" one second) to insert a delay between messages.\n"
" %n - replace with next nick\n"
" %N - replace with as many nicks as possible per line\n"
" %r - replace with random hex value to thwart antispam\n"
"-o Include your own nick in output",
"-od", "masshl_cmd_cb", "")
class Loop():
def __init__(self, buffer, nicks, input, input_method, N_param, delay, opts):
self.buffer = buffer
self.nicks = nicks
self.input = input
self.input_method = input_method
self.N_param = N_param
self.delay = delay
self.opts = opts
def run(self):
i = -('o' not in self.opts)
if i == -1: self.nicks.pop(0)
N_nicks = ""
output = self.input
for nick in self.nicks:
i += 1
if self.N_param:
N_nicks += " %s" % nick
# weechat.prnt(
if (nick != self.nicks[-1] or
len(output) + len(N_nicks) + len(self.nicks[i]) < 300):
continue
else: output = self.input.replace("%n",nick)
N_nicks = N_nicks.lstrip()
output = output.replace("%N",N_nicks)
output = output.replace("%r","%08x" % random.randint(0,0xffffffff))
if self.input_method == "keybinding":
weechat.buffer_set(self.buffer, "input", output) #.encode("UTF-8"))
else:
weechat.command(self.buffer, output) #.encode("UTF-8"))
# sleep(self.delay)
output = self.input
def masshl_cmd_cb(data, buffer, args):
input = args
# do we need to loop a bit before printing, or can we send after each nick?
N_param = "%N" in input
if not N_param and "%n" not in input and "%r" not in input:
# if we bind this to Enter key, we don't want useless flooding on
# normal messages
return weechat.WEECHAT_RC_OK
input_method = "command"
server = weechat.buffer_get_string(buffer, 'localvar_server')
channel = weechat.buffer_get_string(buffer, 'localvar_channel')
if not input or (input[0] == '-' and input.find(' ') == -1):
input = (input + ' ' if input else '') + weechat.buffer_get_string(buffer, "input")
input_method = "keybinding"
optstop = input and input[0] == '-' and input.find(' ')
opts = input[1:optstop] if optstop else ''
cmdstop = 'd' in opts and input.find(' ', optstop+1)
delay = 0
if 'd' in opts:
find = input[optstop+1:cmdstop]
where = input.find(find, cmdstop+1)
try: delay = float(find)
except ValueError:
weechat.prnt(buffer, "delay must be a float value!")
return weechat.WEECHAT_RC_ERROR
input = input[where+len(find):]
else: input = input[optstop+bool(optstop):]
nicklist = weechat.infolist_get("irc_nick", "", "%s,%s" % (server,channel))
# dealing with the cursor can get a little tricky. let's use a dict
# instead, that way we can manipulate just what we need and we can
# do that with builtins
nicks = []
while weechat.infolist_next(nicklist):
nicks.append(weechat.infolist_string(nicklist, "name"))
workhorse = Loop(buffer, nicks, input, input_method, N_param, delay, opts)
workhorse.run()
return weechat.WEECHAT_RC_OK

2051
scripts/weechat_otr.py Normal file

File diff suppressed because it is too large Load Diff