mirror of https://tildegit.org/ben/dotfiles
update weechat scripts
parent
756dbd8397
commit
0eebd01222
2
fzf/.fzf
2
fzf/.fzf
|
@ -1 +1 @@
|
|||
Subproject commit 315e568de006e80138f79c77d5508c7e4853e6b2
|
||||
Subproject commit 0c6c76e08115d0ba160e2c95c8692e4174aa5368
|
|
@ -14,5 +14,4 @@ instant = on
|
|||
timer = 1
|
||||
|
||||
[buffer]
|
||||
irc.freenode.#thunix.hotlist_max_level_nicks_add = "Bender:2"
|
||||
irc.tilde.#trivia.hotlist_max_level_nicks_add = "Oz:2,Nerd:2"
|
||||
|
|
|
@ -106,6 +106,7 @@ whois_double_nick = off
|
|||
whois = current
|
||||
|
||||
[ctcp]
|
||||
pronouns = "he/him"
|
||||
|
||||
[ignore]
|
||||
|
||||
|
@ -153,10 +154,10 @@ usermode = ""
|
|||
username = "${env:USER}"
|
||||
|
||||
[server]
|
||||
tilde.addresses = "localhost"
|
||||
tilde.addresses = "gingko.tilde.chat/6697"
|
||||
tilde.proxy
|
||||
tilde.ipv6
|
||||
tilde.ssl = off
|
||||
tilde.ssl = on
|
||||
tilde.ssl_cert
|
||||
tilde.ssl_priorities
|
||||
tilde.ssl_dhkey_size
|
||||
|
@ -179,9 +180,9 @@ tilde.username
|
|||
tilde.realname
|
||||
tilde.local_hostname
|
||||
tilde.usermode
|
||||
tilde.command = "/oper root ${sec.data.tildenetoper}; /msg operserv login ${sec.data.pass}"
|
||||
tilde.command = "/msg operserv login ${sec.data.pass}"
|
||||
tilde.command_delay
|
||||
tilde.autojoin = "#chaos,#meta,#opers,#secret-sudoers,#team,#sudoers,#yourtilde,#music,#politics,#gopher,#tildeverse,#idlerpg,#tilderadio,#minecraft,#tildelinux,#cosmic,#institute,#.tilde,#tildetel,#thunix,#theasylum,#minetest,#aussie,#uucp,#projects,#hamradio,#vim,#black,#pink,#~,#netnews,#admin,#bots,#ctrl-c,#bitbot,#radiofreqs,#brains,#envs,#rfcs,#best :57:60,:10:20"
|
||||
tilde.autojoin = "#meta,#secret-sudoers,#opers,#sudoers,#yourtilde,#music,#politics,#gopher,#tildeverse,#idlerpg,#tilderadio,#minecraft,#tildelinux,#cosmic,#institute,#.tilde,#tildetel,#thunix,#theasylum,#minetest,#aussie,#uucp,#projects,#hamradio,#vim,#black,#pink,#~,#netnews,#admin,#bots,#ctrl-c,#bitbot,#radiofreqs,#brains,#envs,#rfcs,#best,#wilde,#tildegames,#theasylum-admins,#tildenet,#gemini,#club,#zine,#twtxt,#factorio,#team,#summit :10:20,secretsudoteam"
|
||||
tilde.autorejoin
|
||||
tilde.autorejoin_delay
|
||||
tilde.connection_timeout
|
||||
|
@ -304,7 +305,7 @@ esper.local_hostname
|
|||
esper.usermode
|
||||
esper.command
|
||||
esper.command_delay
|
||||
esper.autojoin = "#lobby,#coders 10:30"
|
||||
esper.autojoin = "#lobby,#coders,#factorio 10:30"
|
||||
esper.autorejoin
|
||||
esper.autorejoin_delay
|
||||
esper.connection_timeout
|
||||
|
@ -440,7 +441,7 @@ oftc.msg_part
|
|||
oftc.msg_quit
|
||||
oftc.notify
|
||||
oftc.split_msg_max_length
|
||||
freenode.addresses = "irc.freenode.net/6697"
|
||||
freenode.addresses = "irc.us.freenode.net/6697"
|
||||
freenode.proxy
|
||||
freenode.ipv6
|
||||
freenode.ssl = on
|
||||
|
@ -468,7 +469,7 @@ freenode.local_hostname
|
|||
freenode.usermode
|
||||
freenode.command
|
||||
freenode.command_delay
|
||||
freenode.autojoin = "#weechat,##oodnet,#lobsters,#lobsters-boil,#gitea,#mastodon,#pleroma,#pleroma-offtopic,#oragono,#weechat-android,#git,#tilde.team,#sr.ht,#cmpwn,#gopherproject,#bitreich-en,#bitbot,#bitreich-de,#ircv3,#gophernicus,##jan6,##ircv3-offtopic,#ovh,#elixir-lang,#ascii.town,#sonarr,#lxcontainers 6:10"
|
||||
freenode.autojoin = "#weechat,##oodnet,#lobsters,#lobsters-boil,#gitea,#mastodon,#pleroma,#pleroma-offtopic,#oragono,#weechat-android,#git,#tilde.team,#sr.ht,#cmpwn,#gopherproject,#bitreich-en,#bitbot,#bitreich-de,#ircv3,#gophernicus,##jan6,##ircv3-offtopic,#ovh,#elixir-lang,#ascii.town,#sonarr,#lxcontainers,#thelounge,#indieweb,#indieweb-dev,#indieweb-meta,#indieweb-chat,#knownchat,#NetBSD,#cjdns,##ircv3-chat,#mumble,#!,#tildeclub,#freenode,#stutter,#futel 6:10"
|
||||
freenode.autorejoin
|
||||
freenode.autorejoin_delay
|
||||
freenode.connection_timeout
|
||||
|
@ -591,7 +592,7 @@ slashnet.local_hostname
|
|||
slashnet.usermode
|
||||
slashnet.command
|
||||
slashnet.command_delay
|
||||
slashnet.autojoin = "#gtlug,#mefi"
|
||||
slashnet.autojoin = "#gtlug"
|
||||
slashnet.autorejoin
|
||||
slashnet.autorejoin_delay
|
||||
slashnet.connection_timeout
|
||||
|
@ -686,44 +687,85 @@ red.msg_part
|
|||
red.msg_quit
|
||||
red.notify
|
||||
red.split_msg_max_length
|
||||
ascii.addresses = "ascii.town/6697"
|
||||
ascii.proxy
|
||||
ascii.ipv6
|
||||
ascii.ssl = on
|
||||
ascii.ssl_cert
|
||||
ascii.ssl_priorities
|
||||
ascii.ssl_dhkey_size
|
||||
ascii.ssl_fingerprint
|
||||
ascii.ssl_verify
|
||||
ascii.password
|
||||
ascii.capabilities
|
||||
ascii.sasl_mechanism
|
||||
ascii.sasl_username
|
||||
ascii.sasl_password
|
||||
ascii.sasl_key
|
||||
ascii.sasl_timeout
|
||||
ascii.sasl_fail
|
||||
ascii.autoconnect
|
||||
ascii.autoreconnect
|
||||
ascii.autoreconnect_delay
|
||||
ascii.nicks
|
||||
ascii.nicks_alternate
|
||||
ascii.username
|
||||
ascii.realname
|
||||
ascii.local_hostname
|
||||
ascii.usermode
|
||||
ascii.command
|
||||
ascii.command_delay
|
||||
ascii.autojoin = "&town"
|
||||
ascii.autorejoin
|
||||
ascii.autorejoin_delay
|
||||
ascii.connection_timeout
|
||||
ascii.anti_flood_prio_high
|
||||
ascii.anti_flood_prio_low
|
||||
ascii.away_check
|
||||
ascii.away_check_max_nicks
|
||||
ascii.msg_kick
|
||||
ascii.msg_part
|
||||
ascii.msg_quit
|
||||
ascii.notify
|
||||
ascii.split_msg_max_length
|
||||
hackint.addresses = "irc.hackint.org/6697"
|
||||
hackint.proxy
|
||||
hackint.ipv6
|
||||
hackint.ssl = on
|
||||
hackint.ssl_cert
|
||||
hackint.ssl_priorities
|
||||
hackint.ssl_dhkey_size
|
||||
hackint.ssl_fingerprint
|
||||
hackint.ssl_verify
|
||||
hackint.password
|
||||
hackint.capabilities
|
||||
hackint.sasl_mechanism
|
||||
hackint.sasl_username = "benharri"
|
||||
hackint.sasl_password = "${sec.data.pass}"
|
||||
hackint.sasl_key
|
||||
hackint.sasl_timeout
|
||||
hackint.sasl_fail
|
||||
hackint.autoconnect
|
||||
hackint.autoreconnect
|
||||
hackint.autoreconnect_delay
|
||||
hackint.nicks = "benharri"
|
||||
hackint.nicks_alternate
|
||||
hackint.username
|
||||
hackint.realname
|
||||
hackint.local_hostname
|
||||
hackint.usermode
|
||||
hackint.command
|
||||
hackint.command_delay
|
||||
hackint.autojoin = "#tildeverse,#hackint,#36c3,#camp"
|
||||
hackint.autorejoin
|
||||
hackint.autorejoin_delay
|
||||
hackint.connection_timeout
|
||||
hackint.anti_flood_prio_high
|
||||
hackint.anti_flood_prio_low
|
||||
hackint.away_check
|
||||
hackint.away_check_max_nicks
|
||||
hackint.msg_kick
|
||||
hackint.msg_part
|
||||
hackint.msg_quit
|
||||
hackint.notify
|
||||
hackint.split_msg_max_length
|
||||
efnet.addresses = "irc.servercentral.net"
|
||||
efnet.proxy
|
||||
efnet.ipv6
|
||||
efnet.ssl
|
||||
efnet.ssl_cert
|
||||
efnet.ssl_priorities
|
||||
efnet.ssl_dhkey_size
|
||||
efnet.ssl_fingerprint
|
||||
efnet.ssl_verify
|
||||
efnet.password
|
||||
efnet.capabilities
|
||||
efnet.sasl_mechanism
|
||||
efnet.sasl_username
|
||||
efnet.sasl_password
|
||||
efnet.sasl_key
|
||||
efnet.sasl_timeout
|
||||
efnet.sasl_fail
|
||||
efnet.autoconnect
|
||||
efnet.autoreconnect
|
||||
efnet.autoreconnect_delay
|
||||
efnet.nicks
|
||||
efnet.nicks_alternate
|
||||
efnet.username
|
||||
efnet.realname
|
||||
efnet.local_hostname
|
||||
efnet.usermode
|
||||
efnet.command
|
||||
efnet.command_delay
|
||||
efnet.autojoin = "#dragonflybsd,#freebsd"
|
||||
efnet.autorejoin
|
||||
efnet.autorejoin_delay
|
||||
efnet.connection_timeout
|
||||
efnet.anti_flood_prio_high
|
||||
efnet.anti_flood_prio_low
|
||||
efnet.away_check
|
||||
efnet.away_check_max_nicks
|
||||
efnet.msg_kick
|
||||
efnet.msg_part
|
||||
efnet.msg_quit
|
||||
efnet.notify
|
||||
efnet.split_msg_max_length
|
||||
|
|
|
@ -69,7 +69,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=>¯\_(ツ)_/¯;;wiki=>https://tilde.team/wiki/;;sword=>o()xxxx[{::::::::::::::::::::::::::::::::::>;;lenny=>( ͡° ͜ʖ ͡°);;byobu=>https://superuser.com/a/423397/866501;;huh=>(-_-)ゞ゛;;tablefix=>┬─┬ノ( º _ ºノ);;weedoc=>https://weechat.org/files/doc/stable/weechat_user.en.html;;weekeys=>https://weechat.org/files/doc/stable/weechat_user.en.html#key_bindings;;denko=>(´・ω・`);;yuno=>ლ(́ಠ◞益◟ಠ‵ლ);;tf=>(ノಥ益ಥ)ノ彡┻━┻;;tb=>┬─┬ノ( º _ ºノ);;ducc=>・゜゜・。。・゜゜\_o< QUACK!"
|
||||
python.completion.replace_values = "shrug=>¯\_(ツ)_/¯;;wiki=>https://tilde.team/wiki/;;sword=>o()xxxx[{::::::::::::::::::::::::::::::::::>;;lenny=>( ͡° ͜ʖ ͡°);;byobu=>https://superuser.com/a/423397/866501;;fg=>(☞゚ヮ゚)☞;;huh=>(-_-)ゞ゛;;tablefix=>┬─┬ノ( º _ ºノ);;weedoc=>https://weechat.org/files/doc/stable/weechat_user.en.html;;weekeys=>https://weechat.org/files/doc/stable/weechat_user.en.html#key_bindings;;denko=>(´・ω・`);;yuno=>ლ(́ಠ◞益◟ಠ‵ლ);;tf=>(ノಥ益ಥ)ノ彡┻━┻;;tb=>┬─┬ノ( º _ ºノ);;ducc=>・゜゜・。。・゜゜\_o< QUACK!"
|
||||
python.go.auto_jump = "off"
|
||||
python.go.buffer_number = "on"
|
||||
python.go.color_name = "black,cyan"
|
||||
|
|
|
@ -48,7 +48,10 @@
|
|||
#
|
||||
# 2018-08-09, Julien Palard <julien@palard.fr>
|
||||
# version 0.3.0: Support for Python 3
|
||||
|
||||
#
|
||||
# 2019-09-28, fructose
|
||||
# version 0.3.1: Error on invalid arguments
|
||||
#
|
||||
# @TODO: add options to ignore certain buffers
|
||||
# @TODO: maybe add an option to enable autosaving on part/join messages
|
||||
|
||||
|
@ -57,7 +60,7 @@ import re
|
|||
|
||||
SCRIPT_NAME = "autojoin"
|
||||
SCRIPT_AUTHOR = "xt <xt@bash.no>"
|
||||
SCRIPT_VERSION = "0.3.0"
|
||||
SCRIPT_VERSION = "0.3.1"
|
||||
SCRIPT_LICENSE = "GPL3"
|
||||
SCRIPT_DESC = "Configure autojoin for all servers according to currently joined channels"
|
||||
SCRIPT_COMMAND = "autojoin"
|
||||
|
@ -77,8 +80,8 @@ if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT
|
|||
"autojoin_cb",
|
||||
"")
|
||||
|
||||
#w.hook_signal('*,irc_in2_join', 'autosave_channels_on_activity', '')
|
||||
#w.hook_signal('*,irc_in2_part', 'autosave_channels_on_activity', '')
|
||||
# w.hook_signal('*,irc_in2_join', 'autosave_channels_on_activity', '')
|
||||
# w.hook_signal('*,irc_in2_part', 'autosave_channels_on_activity', '')
|
||||
w.hook_signal('quit', 'autosave_channels_on_quit', '')
|
||||
|
||||
# Init everything
|
||||
|
@ -86,6 +89,7 @@ for option, default_value in settings.items():
|
|||
if w.config_get_plugin(option) == "":
|
||||
w.config_set_plugin(option, default_value)
|
||||
|
||||
|
||||
def autosave_channels_on_quit(signal, callback, callback_data):
|
||||
''' Autojoin current channels '''
|
||||
if w.config_get_plugin(option) != "on":
|
||||
|
@ -114,54 +118,60 @@ def autosave_channels_on_activity(signal, callback, callback_data):
|
|||
pattern = "^:%s!.*(JOIN|PART) :?(#[^ ]*)( :.*$)?" % nick
|
||||
match = re.match(pattern, callback_data)
|
||||
|
||||
if match: # check if nick is my nick. In that case: save
|
||||
if match: # check if nick is my nick. In that case: save
|
||||
process_server(server, channels)
|
||||
else: # someone else: ignore
|
||||
else: # someone else: ignore
|
||||
continue
|
||||
|
||||
return w.WEECHAT_RC_OK
|
||||
|
||||
def autojoin_cb(data, buffer, args):
|
||||
"""Old behaviour: doesn't save empty channel list"""
|
||||
"""In fact should also save open buffers with a /part'ed channel"""
|
||||
"""But I can't believe somebody would want that behaviour"""
|
||||
items = find_channels()
|
||||
|
||||
def autojoin_cb(data, buffer, args):
|
||||
if args == '--run':
|
||||
run = True
|
||||
elif args != '':
|
||||
w.prnt('', 'Unexpected argument: %s' % args)
|
||||
return w.WEECHAT_RC_ERROR
|
||||
else:
|
||||
run = False
|
||||
|
||||
# Old behaviour: doesn't save empty channel list
|
||||
# In fact should also save open buffers with a /part'ed channel
|
||||
# But I can't believe somebody would want that behaviour
|
||||
items = find_channels()
|
||||
|
||||
# print/execute commands
|
||||
for server, channels in items.items():
|
||||
process_server(server, channels, run)
|
||||
|
||||
return w.WEECHAT_RC_OK
|
||||
|
||||
|
||||
def process_server(server, channels, run=True):
|
||||
option = "irc.server.%s.autojoin" % server
|
||||
channels = channels.rstrip(',')
|
||||
oldchans = w.config_string(w.config_get(option))
|
||||
option = "irc.server.%s.autojoin" % server
|
||||
channels = channels.rstrip(',')
|
||||
oldchans = w.config_string(w.config_get(option))
|
||||
|
||||
if not channels: # empty channel list
|
||||
return
|
||||
if not channels: # empty channel list
|
||||
return
|
||||
|
||||
# Note: re already caches the result of regexp compilation
|
||||
sec = re.match('^\${sec\.data\.(.*)}$', oldchans)
|
||||
if sec:
|
||||
secvar = sec.group(1)
|
||||
command = "/secure set %s %s" % (secvar, channels)
|
||||
else:
|
||||
command = "/set irc.server.%s.autojoin '%s'" % (server, channels)
|
||||
# Note: re already caches the result of regexp compilation
|
||||
sec = re.match('^\${sec\.data\.(.*)}$', oldchans)
|
||||
if sec:
|
||||
secvar = sec.group(1)
|
||||
command = "/secure set %s %s" % (secvar, channels)
|
||||
else:
|
||||
command = "/set irc.server.%s.autojoin '%s'" % (server, channels)
|
||||
|
||||
if run:
|
||||
w.command('', command)
|
||||
else:
|
||||
w.prnt('', command)
|
||||
|
||||
if run:
|
||||
w.command('', command)
|
||||
else:
|
||||
w.prnt('', command)
|
||||
|
||||
def find_channels():
|
||||
"""Return list of servers and channels"""
|
||||
#@TODO: make it return a dict with more options like "nicks_count etc."
|
||||
# TODO: make it return a dict with more options like "nicks_count etc."
|
||||
items = {}
|
||||
infolist = w.infolist_get('irc_server', '', '')
|
||||
# populate servers
|
||||
|
@ -175,18 +185,18 @@ def find_channels():
|
|||
keys = []
|
||||
keyed_channels = []
|
||||
unkeyed_channels = []
|
||||
items[server] = '' #init if connected but no channels
|
||||
items[server] = '' # init if connected but no channels
|
||||
infolist = w.infolist_get('irc_channel', '', server)
|
||||
while w.infolist_next(infolist):
|
||||
if w.infolist_integer(infolist, 'nicks_count') == 0:
|
||||
#parted but still open in a buffer: bit hackish
|
||||
# parted but still open in a buffer: bit hackish
|
||||
continue
|
||||
if w.infolist_integer(infolist, 'type') == 0:
|
||||
key = w.infolist_string(infolist, "key")
|
||||
if len(key) > 0:
|
||||
keys.append(key)
|
||||
keyed_channels.append(w.infolist_string(infolist, "name"))
|
||||
else :
|
||||
else:
|
||||
unkeyed_channels.append(w.infolist_string(infolist, "name"))
|
||||
items[server] = ','.join(keyed_channels + unkeyed_channels)
|
||||
if len(keys) > 0:
|
||||
|
@ -194,4 +204,3 @@ def find_channels():
|
|||
w.infolist_free(infolist)
|
||||
|
||||
return items
|
||||
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
#
|
||||
#
|
||||
# History:
|
||||
# 2019-08-20
|
||||
# version 0.3: Ben Harris (benharri)
|
||||
# * port for python3
|
||||
#
|
||||
# 2010-05-08
|
||||
# version 0.2:
|
||||
# * complete any word behind the cursor, not just the last one in input line.
|
||||
|
@ -46,13 +50,13 @@ try:
|
|||
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/"
|
||||
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_VERSION = "0.3"
|
||||
SCRIPT_LICENSE = "GPL3"
|
||||
SCRIPT_DESC = "Word completions for WeeChat"
|
||||
SCRIPT_COMMAND = "completion"
|
||||
|
@ -63,16 +67,6 @@ settings = {
|
|||
}
|
||||
|
||||
### 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
|
||||
|
@ -84,13 +78,11 @@ def debug(s, prefix='', buffer=None):
|
|||
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:
|
||||
|
@ -102,67 +94,34 @@ def error(s, prefix=None, buffer='', 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)
|
||||
values = [s.split('=>') for s in value.split(';;')]
|
||||
#debug(values)
|
||||
return dict(values)
|
||||
|
||||
def load_replace_table():
|
||||
global replace_table
|
||||
replace_table = UTFDict(get_config_dict('replace_values'))
|
||||
replace_table = dict(get_config_dict('replace_values'))
|
||||
|
||||
def save_replace_table():
|
||||
global replace_table
|
||||
weechat.config_set_plugin('replace_values', str(replace_table))
|
||||
weechat.config_set_plugin('replace_values',
|
||||
';;'.join(['%s=>%s' %(k, v) for k, v in replace_table.items()]))
|
||||
|
||||
### Commands ###
|
||||
def cmd_completion(data, buffer, args):
|
||||
global replace_table
|
||||
if not args:
|
||||
if replace_table:
|
||||
for k, v in replace_table.iteritems():
|
||||
for k, v in replace_table.items():
|
||||
print_replace(k, v)
|
||||
else:
|
||||
say('No completions.')
|
||||
|
@ -189,7 +148,7 @@ def cmd_completion(data, buffer, args):
|
|||
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'))
|
||||
input = 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)
|
||||
|
@ -202,14 +161,14 @@ def completion_replacer(data, completion_item, buffer, completion):
|
|||
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', 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)
|
||||
weechat.hook_completion_list_add(completion, k, 0, weechat.WEECHAT_LIST_POS_SORT)
|
||||
return WEECHAT_RC_OK
|
||||
|
||||
### Main ###
|
||||
|
@ -231,7 +190,7 @@ if __name__ == '__main__' and import_ok and \
|
|||
error('WeeChat 0.3.1 or newer is required for this script.')
|
||||
else:
|
||||
# settings
|
||||
for opt, val in settings.iteritems():
|
||||
for opt, val in settings.items():
|
||||
if not weechat.config_is_set_plugin(opt):
|
||||
weechat.config_set_plugin(opt, val)
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#
|
||||
# History:
|
||||
#
|
||||
# 2019-07-11, Simmo Saan <simmo.saan@gmail.com>
|
||||
# version 2.6: fix detection of "/input search_text_here"
|
||||
# 2017-04-01, Sébastien Helleu <flashcode@flashtux.org>:
|
||||
# version 2.5: add option "buffer_number"
|
||||
# 2017-03-02, Sébastien Helleu <flashcode@flashtux.org>:
|
||||
|
@ -92,7 +94,7 @@ from __future__ import print_function
|
|||
|
||||
SCRIPT_NAME = 'go'
|
||||
SCRIPT_AUTHOR = 'Sébastien Helleu <flashcode@flashtux.org>'
|
||||
SCRIPT_VERSION = '2.5'
|
||||
SCRIPT_VERSION = '2.6'
|
||||
SCRIPT_LICENSE = 'GPL3'
|
||||
SCRIPT_DESC = 'Quick jump to buffers'
|
||||
|
||||
|
@ -480,7 +482,7 @@ def go_input_modifier(data, modifier, modifier_data, string):
|
|||
def go_command_run_input(data, buf, command):
|
||||
"""Function called when a command "/input xxx" is run."""
|
||||
global buffers, buffers_pos
|
||||
if command == '/input search_text' or command.find('/input jump') == 0:
|
||||
if command.startswith('/input search_text') or command.startswith('/input jump'):
|
||||
# search text or jump to another buffer is forbidden now
|
||||
return weechat.WEECHAT_RC_OK_EAT
|
||||
elif command == '/input complete_next':
|
||||
|
|
|
@ -69,6 +69,10 @@
|
|||
#
|
||||
# History:
|
||||
#
|
||||
# 2019-06-30, dabbill <dabbill@gmail.com>
|
||||
# and Sébastien Helleu <flashcode@flashtux.org>
|
||||
# version 0.8.2: make script compatible with Python 3
|
||||
#
|
||||
# 2018-04-10, Sébastien Helleu <flashcode@flashtux.org>
|
||||
# version 0.8.1: fix infolist_time for WeeChat >= 2.2 (WeeChat returns a long
|
||||
# integer instead of a string)
|
||||
|
@ -226,7 +230,7 @@ except ImportError:
|
|||
|
||||
SCRIPT_NAME = "grep"
|
||||
SCRIPT_AUTHOR = "Elián Hanisch <lambdae2@gmail.com>"
|
||||
SCRIPT_VERSION = "0.8.1"
|
||||
SCRIPT_VERSION = "0.8.2"
|
||||
SCRIPT_LICENSE = "GPL3"
|
||||
SCRIPT_DESC = "Search in buffers and logs"
|
||||
SCRIPT_COMMAND = "grep"
|
||||
|
@ -259,14 +263,14 @@ class linesDict(dict):
|
|||
def get_matches_count(self):
|
||||
"""Return the sum of total matches stored."""
|
||||
if dict.__len__(self):
|
||||
return sum(map(lambda L: L.matches_count, self.itervalues()))
|
||||
return sum(map(lambda L: L.matches_count, self.values()))
|
||||
else:
|
||||
return 0
|
||||
|
||||
def __len__(self):
|
||||
"""Return the sum of total lines stored."""
|
||||
if dict.__len__(self):
|
||||
return sum(map(len, self.itervalues()))
|
||||
return sum(map(len, self.values()))
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
@ -274,7 +278,7 @@ class linesDict(dict):
|
|||
"""Returns buffer count or buffer name if there's just one stored."""
|
||||
n = len(self.keys())
|
||||
if n == 1:
|
||||
return self.keys()[0]
|
||||
return list(self.keys())[0]
|
||||
elif n > 1:
|
||||
return '%s logs' %n
|
||||
else:
|
||||
|
@ -282,18 +286,18 @@ class linesDict(dict):
|
|||
|
||||
def items(self):
|
||||
"""Returns a list of items sorted by line count."""
|
||||
items = dict.items(self)
|
||||
items = list(dict.items(self))
|
||||
items.sort(key=lambda i: len(i[1]))
|
||||
return items
|
||||
|
||||
def items_count(self):
|
||||
"""Returns a list of items sorted by match count."""
|
||||
items = dict.items(self)
|
||||
items = list(dict.items(self))
|
||||
items.sort(key=lambda i: i[1].matches_count)
|
||||
return items
|
||||
|
||||
def strip_separator(self):
|
||||
for L in self.itervalues():
|
||||
for L in self.values():
|
||||
L.strip_separator()
|
||||
|
||||
def get_last_lines(self, n):
|
||||
|
@ -302,7 +306,7 @@ class linesDict(dict):
|
|||
if n >= total_lines:
|
||||
# nothing to do
|
||||
return
|
||||
for k, v in reversed(self.items()):
|
||||
for k, v in reversed(list(self.items())):
|
||||
l = len(v)
|
||||
if n > 0:
|
||||
if l > n:
|
||||
|
@ -657,8 +661,8 @@ def make_regexp(pattern, matchcase=False):
|
|||
regexp = re.compile(pattern, re.IGNORECASE)
|
||||
else:
|
||||
regexp = re.compile(pattern)
|
||||
except Exception, e:
|
||||
raise Exception, 'Bad pattern, %s' %e
|
||||
except Exception as e:
|
||||
raise Exception('Bad pattern, %s' % e)
|
||||
return regexp
|
||||
|
||||
def check_string(s, regexp, hilight='', exact=False):
|
||||
|
@ -736,7 +740,7 @@ def grep_file(file, head, tail, after_context, before_context, count, regexp, hi
|
|||
before_context, after_context = after_context, before_context
|
||||
|
||||
if before_context:
|
||||
before_context_range = range(1, before_context + 1)
|
||||
before_context_range = list(range(1, before_context + 1))
|
||||
before_context_range.reverse()
|
||||
|
||||
limit = tail or head
|
||||
|
@ -800,7 +804,7 @@ def grep_file(file, head, tail, after_context, before_context, count, regexp, hi
|
|||
while id < after_context + offset:
|
||||
id += 1
|
||||
try:
|
||||
context_line = file_object.next()
|
||||
context_line = next(file_object)
|
||||
_context_line = check(context_line)
|
||||
if _context_line:
|
||||
offset = id
|
||||
|
@ -1002,7 +1006,7 @@ def grep_process(*args):
|
|||
global grep_options, log_pairs
|
||||
for log_name, log in log_pairs:
|
||||
result[log_name] = grep_file(log, *grep_options)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
result = e
|
||||
|
||||
return pickle.dumps(result)
|
||||
|
@ -1038,7 +1042,7 @@ def grep_process_cb(data, command, return_code, out, err):
|
|||
if isinstance(data, Exception):
|
||||
raise data
|
||||
matched_lines.update(data)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
set_buffer_error(repr(e))
|
||||
return WEECHAT_RC_OK
|
||||
else:
|
||||
|
@ -1280,12 +1284,12 @@ def buffer_input(data, buffer, input_data):
|
|||
weechat.infolist_free(infolist)
|
||||
try:
|
||||
cmd_grep_parsing(input_data)
|
||||
except Exception, e:
|
||||
error('Argument error, %s' %e, buffer=buffer)
|
||||
except Exception as e:
|
||||
error('Argument error, %s' % e, buffer=buffer)
|
||||
return WEECHAT_RC_OK
|
||||
try:
|
||||
show_matching_lines()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
error(e)
|
||||
except NameError:
|
||||
error("There isn't any previous search to repeat.", buffer=buffer)
|
||||
|
@ -1346,7 +1350,7 @@ def cmd_grep_parsing(args):
|
|||
pattern = _tmplRe.sub(tmplReplacer, args)
|
||||
debug('Using regexp: %s', pattern)
|
||||
if not pattern:
|
||||
raise Exception, 'No pattern for grep the logs.'
|
||||
raise Exception('No pattern for grep the logs.')
|
||||
|
||||
def positive_number(opt, val):
|
||||
try:
|
||||
|
@ -1359,7 +1363,7 @@ def cmd_grep_parsing(args):
|
|||
opt = '-' + opt
|
||||
else:
|
||||
opt = '--' + opt
|
||||
raise Exception, "argument for %s must be a positive integer." %opt
|
||||
raise Exception("argument for %s must be a positive integer." % opt)
|
||||
|
||||
for opt, val in opts:
|
||||
opt = opt.strip('-')
|
||||
|
@ -1454,8 +1458,8 @@ def cmd_grep(data, buffer, args):
|
|||
# parse
|
||||
try:
|
||||
cmd_grep_parsing(args)
|
||||
except Exception, e:
|
||||
error('Argument error, %s' %e)
|
||||
except Exception as e:
|
||||
error('Argument error, %s' % e)
|
||||
return WEECHAT_RC_OK
|
||||
|
||||
# find logs
|
||||
|
@ -1501,7 +1505,7 @@ def cmd_grep(data, buffer, args):
|
|||
# grepping
|
||||
try:
|
||||
show_matching_lines()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
error(e)
|
||||
return WEECHAT_RC_OK
|
||||
|
||||
|
@ -1520,8 +1524,8 @@ def cmd_logs(data, buffer, args):
|
|||
opt = opt.strip('-')
|
||||
if opt in ('size', 's'):
|
||||
sort_by_size = True
|
||||
except Exception, e:
|
||||
error('Argument error, %s' %e)
|
||||
except Exception as e:
|
||||
error('Argument error, %s' % e)
|
||||
return WEECHAT_RC_OK
|
||||
|
||||
# is there's a filter, filter_excludes should be False
|
||||
|
@ -1703,7 +1707,7 @@ Examples:
|
|||
'completion_grep_args', '')
|
||||
|
||||
# settings
|
||||
for opt, val in settings.iteritems():
|
||||
for opt, val in settings.items():
|
||||
if not weechat.config_is_set_plugin(opt):
|
||||
weechat.config_set_plugin(opt, val)
|
||||
|
||||
|
|
|
@ -354,9 +354,11 @@ default.current = on
|
|||
|
||||
[notify]
|
||||
irc.bitlbee = highlight
|
||||
perl.highmon = none
|
||||
|
||||
[filter]
|
||||
irc_smart = on;*;irc_smart_filter;*
|
||||
markov_bitbot = on;irc.tilde.*;irc_privmsg;^,m(\s|arkov)|^\[Markov\]
|
||||
|
||||
[key]
|
||||
ctrl-? = "/input delete_previous_char"
|
||||
|
|
Loading…
Reference in New Issue