my shell and tool configurations

update weechat scripts

+191 -174
-1
weechat/.weechat/buffer_autoset.conf
··· 14 14 timer = 1 15 15 16 16 [buffer] 17 - irc.freenode.#thunix.hotlist_max_level_nicks_add = "Bender:2" 18 17 irc.tilde.#trivia.hotlist_max_level_nicks_add = "Oz:2,Nerd:2"
+91 -49
weechat/.weechat/irc.conf
··· 106 106 whois = current 107 107 108 108 [ctcp] 109 + pronouns = "he/him" 109 110 110 111 [ignore] 111 112 ··· 153 154 username = "${env:USER}" 154 155 155 156 [server] 156 - tilde.addresses = "localhost" 157 + tilde.addresses = "gingko.tilde.chat/6697" 157 158 tilde.proxy 158 159 tilde.ipv6 159 - tilde.ssl = off 160 + tilde.ssl = on 160 161 tilde.ssl_cert 161 162 tilde.ssl_priorities 162 163 tilde.ssl_dhkey_size ··· 179 180 tilde.realname 180 181 tilde.local_hostname 181 182 tilde.usermode 182 - tilde.command = "/oper root ${sec.data.tildenetoper}; /msg operserv login ${sec.data.pass}" 183 + tilde.command = "/msg operserv login ${sec.data.pass}" 183 184 tilde.command_delay 184 - 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" 185 + 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" 185 186 tilde.autorejoin 186 187 tilde.autorejoin_delay 187 188 tilde.connection_timeout ··· 304 305 esper.usermode 305 306 esper.command 306 307 esper.command_delay 307 - esper.autojoin = "#lobby,#coders 10:30" 308 + esper.autojoin = "#lobby,#coders,#factorio 10:30" 308 309 esper.autorejoin 309 310 esper.autorejoin_delay 310 311 esper.connection_timeout ··· 440 441 oftc.msg_quit 441 442 oftc.notify 442 443 oftc.split_msg_max_length 443 - freenode.addresses = "irc.freenode.net/6697" 444 + freenode.addresses = "irc.us.freenode.net/6697" 444 445 freenode.proxy 445 446 freenode.ipv6 446 447 freenode.ssl = on ··· 468 469 freenode.usermode 469 470 freenode.command 470 471 freenode.command_delay 471 - 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" 472 + 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" 472 473 freenode.autorejoin 473 474 freenode.autorejoin_delay 474 475 freenode.connection_timeout ··· 591 592 slashnet.usermode 592 593 slashnet.command 593 594 slashnet.command_delay 594 - slashnet.autojoin = "#gtlug,#mefi" 595 + slashnet.autojoin = "#gtlug" 595 596 slashnet.autorejoin 596 597 slashnet.autorejoin_delay 597 598 slashnet.connection_timeout ··· 686 687 red.msg_quit 687 688 red.notify 688 689 red.split_msg_max_length 689 - ascii.addresses = "ascii.town/6697" 690 - ascii.proxy 691 - ascii.ipv6 692 - ascii.ssl = on 693 - ascii.ssl_cert 694 - ascii.ssl_priorities 695 - ascii.ssl_dhkey_size 696 - ascii.ssl_fingerprint 697 - ascii.ssl_verify 698 - ascii.password 699 - ascii.capabilities 700 - ascii.sasl_mechanism 701 - ascii.sasl_username 702 - ascii.sasl_password 703 - ascii.sasl_key 704 - ascii.sasl_timeout 705 - ascii.sasl_fail 706 - ascii.autoconnect 707 - ascii.autoreconnect 708 - ascii.autoreconnect_delay 709 - ascii.nicks 710 - ascii.nicks_alternate 711 - ascii.username 712 - ascii.realname 713 - ascii.local_hostname 714 - ascii.usermode 715 - ascii.command 716 - ascii.command_delay 717 - ascii.autojoin = "&town" 718 - ascii.autorejoin 719 - ascii.autorejoin_delay 720 - ascii.connection_timeout 721 - ascii.anti_flood_prio_high 722 - ascii.anti_flood_prio_low 723 - ascii.away_check 724 - ascii.away_check_max_nicks 725 - ascii.msg_kick 726 - ascii.msg_part 727 - ascii.msg_quit 728 - ascii.notify 729 - ascii.split_msg_max_length 690 + hackint.addresses = "irc.hackint.org/6697" 691 + hackint.proxy 692 + hackint.ipv6 693 + hackint.ssl = on 694 + hackint.ssl_cert 695 + hackint.ssl_priorities 696 + hackint.ssl_dhkey_size 697 + hackint.ssl_fingerprint 698 + hackint.ssl_verify 699 + hackint.password 700 + hackint.capabilities 701 + hackint.sasl_mechanism 702 + hackint.sasl_username = "benharri" 703 + hackint.sasl_password = "${sec.data.pass}" 704 + hackint.sasl_key 705 + hackint.sasl_timeout 706 + hackint.sasl_fail 707 + hackint.autoconnect 708 + hackint.autoreconnect 709 + hackint.autoreconnect_delay 710 + hackint.nicks = "benharri" 711 + hackint.nicks_alternate 712 + hackint.username 713 + hackint.realname 714 + hackint.local_hostname 715 + hackint.usermode 716 + hackint.command 717 + hackint.command_delay 718 + hackint.autojoin = "#tildeverse,#hackint,#36c3,#camp" 719 + hackint.autorejoin 720 + hackint.autorejoin_delay 721 + hackint.connection_timeout 722 + hackint.anti_flood_prio_high 723 + hackint.anti_flood_prio_low 724 + hackint.away_check 725 + hackint.away_check_max_nicks 726 + hackint.msg_kick 727 + hackint.msg_part 728 + hackint.msg_quit 729 + hackint.notify 730 + hackint.split_msg_max_length 731 + efnet.addresses = "irc.servercentral.net" 732 + efnet.proxy 733 + efnet.ipv6 734 + efnet.ssl 735 + efnet.ssl_cert 736 + efnet.ssl_priorities 737 + efnet.ssl_dhkey_size 738 + efnet.ssl_fingerprint 739 + efnet.ssl_verify 740 + efnet.password 741 + efnet.capabilities 742 + efnet.sasl_mechanism 743 + efnet.sasl_username 744 + efnet.sasl_password 745 + efnet.sasl_key 746 + efnet.sasl_timeout 747 + efnet.sasl_fail 748 + efnet.autoconnect 749 + efnet.autoreconnect 750 + efnet.autoreconnect_delay 751 + efnet.nicks 752 + efnet.nicks_alternate 753 + efnet.username 754 + efnet.realname 755 + efnet.local_hostname 756 + efnet.usermode 757 + efnet.command 758 + efnet.command_delay 759 + efnet.autojoin = "#dragonflybsd,#freebsd" 760 + efnet.autorejoin 761 + efnet.autorejoin_delay 762 + efnet.connection_timeout 763 + efnet.anti_flood_prio_high 764 + efnet.anti_flood_prio_low 765 + efnet.away_check 766 + efnet.away_check_max_nicks 767 + efnet.msg_kick 768 + efnet.msg_part 769 + efnet.msg_quit 770 + efnet.notify 771 + efnet.split_msg_max_length
+1 -1
weechat/.weechat/plugins.conf
··· 69 69 python.buffer_autoclose.ignore = "" 70 70 python.buffer_autoclose.interval = "1" 71 71 python.check_license = "off" 72 - 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!" 72 + 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!" 73 73 python.go.auto_jump = "off" 74 74 python.go.buffer_number = "on" 75 75 python.go.color_name = "black,cyan"
+41 -32
weechat/.weechat/python/autojoin.py
··· 48 48 # 49 49 # 2018-08-09, Julien Palard <julien@palard.fr> 50 50 # version 0.3.0: Support for Python 3 51 - 51 + # 52 + # 2019-09-28, fructose 53 + # version 0.3.1: Error on invalid arguments 54 + # 52 55 # @TODO: add options to ignore certain buffers 53 56 # @TODO: maybe add an option to enable autosaving on part/join messages 54 57 ··· 57 60 58 61 SCRIPT_NAME = "autojoin" 59 62 SCRIPT_AUTHOR = "xt <xt@bash.no>" 60 - SCRIPT_VERSION = "0.3.0" 63 + SCRIPT_VERSION = "0.3.1" 61 64 SCRIPT_LICENSE = "GPL3" 62 65 SCRIPT_DESC = "Configure autojoin for all servers according to currently joined channels" 63 66 SCRIPT_COMMAND = "autojoin" ··· 77 80 "autojoin_cb", 78 81 "") 79 82 80 - #w.hook_signal('*,irc_in2_join', 'autosave_channels_on_activity', '') 81 - #w.hook_signal('*,irc_in2_part', 'autosave_channels_on_activity', '') 83 + # w.hook_signal('*,irc_in2_join', 'autosave_channels_on_activity', '') 84 + # w.hook_signal('*,irc_in2_part', 'autosave_channels_on_activity', '') 82 85 w.hook_signal('quit', 'autosave_channels_on_quit', '') 83 86 84 87 # Init everything 85 88 for option, default_value in settings.items(): 86 89 if w.config_get_plugin(option) == "": 87 90 w.config_set_plugin(option, default_value) 91 + 88 92 89 93 def autosave_channels_on_quit(signal, callback, callback_data): 90 94 ''' Autojoin current channels ''' ··· 114 118 pattern = "^:%s!.*(JOIN|PART) :?(#[^ ]*)( :.*$)?" % nick 115 119 match = re.match(pattern, callback_data) 116 120 117 - if match: # check if nick is my nick. In that case: save 121 + if match: # check if nick is my nick. In that case: save 118 122 process_server(server, channels) 119 - else: # someone else: ignore 123 + else: # someone else: ignore 120 124 continue 121 125 122 126 return w.WEECHAT_RC_OK 123 127 128 + 124 129 def autojoin_cb(data, buffer, args): 125 - """Old behaviour: doesn't save empty channel list""" 126 - """In fact should also save open buffers with a /part'ed channel""" 127 - """But I can't believe somebody would want that behaviour""" 128 - items = find_channels() 129 - 130 130 if args == '--run': 131 131 run = True 132 + elif args != '': 133 + w.prnt('', 'Unexpected argument: %s' % args) 134 + return w.WEECHAT_RC_ERROR 132 135 else: 133 136 run = False 134 137 138 + # Old behaviour: doesn't save empty channel list 139 + # In fact should also save open buffers with a /part'ed channel 140 + # But I can't believe somebody would want that behaviour 141 + items = find_channels() 142 + 135 143 # print/execute commands 136 144 for server, channels in items.items(): 137 145 process_server(server, channels, run) 138 146 139 147 return w.WEECHAT_RC_OK 140 148 149 + 141 150 def process_server(server, channels, run=True): 142 - option = "irc.server.%s.autojoin" % server 143 - channels = channels.rstrip(',') 144 - oldchans = w.config_string(w.config_get(option)) 151 + option = "irc.server.%s.autojoin" % server 152 + channels = channels.rstrip(',') 153 + oldchans = w.config_string(w.config_get(option)) 154 + 155 + if not channels: # empty channel list 156 + return 145 157 146 - if not channels: # empty channel list 147 - return 158 + # Note: re already caches the result of regexp compilation 159 + sec = re.match('^\${sec\.data\.(.*)}$', oldchans) 160 + if sec: 161 + secvar = sec.group(1) 162 + command = "/secure set %s %s" % (secvar, channels) 163 + else: 164 + command = "/set irc.server.%s.autojoin '%s'" % (server, channels) 148 165 149 - # Note: re already caches the result of regexp compilation 150 - sec = re.match('^\${sec\.data\.(.*)}$', oldchans) 151 - if sec: 152 - secvar = sec.group(1) 153 - command = "/secure set %s %s" % (secvar, channels) 154 - else: 155 - command = "/set irc.server.%s.autojoin '%s'" % (server, channels) 166 + if run: 167 + w.command('', command) 168 + else: 169 + w.prnt('', command) 156 170 157 - if run: 158 - w.command('', command) 159 - else: 160 - w.prnt('', command) 161 171 162 172 def find_channels(): 163 173 """Return list of servers and channels""" 164 - #@TODO: make it return a dict with more options like "nicks_count etc." 174 + # TODO: make it return a dict with more options like "nicks_count etc." 165 175 items = {} 166 176 infolist = w.infolist_get('irc_server', '', '') 167 177 # populate servers ··· 175 185 keys = [] 176 186 keyed_channels = [] 177 187 unkeyed_channels = [] 178 - items[server] = '' #init if connected but no channels 188 + items[server] = '' # init if connected but no channels 179 189 infolist = w.infolist_get('irc_channel', '', server) 180 190 while w.infolist_next(infolist): 181 191 if w.infolist_integer(infolist, 'nicks_count') == 0: 182 - #parted but still open in a buffer: bit hackish 192 + # parted but still open in a buffer: bit hackish 183 193 continue 184 194 if w.infolist_integer(infolist, 'type') == 0: 185 195 key = w.infolist_string(infolist, "key") 186 196 if len(key) > 0: 187 197 keys.append(key) 188 198 keyed_channels.append(w.infolist_string(infolist, "name")) 189 - else : 199 + else: 190 200 unkeyed_channels.append(w.infolist_string(infolist, "name")) 191 201 items[server] = ','.join(keyed_channels + unkeyed_channels) 192 202 if len(keys) > 0: ··· 194 204 w.infolist_free(infolist) 195 205 196 206 return items 197 -
+16 -57
weechat/.weechat/python/completion.py
··· 31 31 # 32 32 # 33 33 # History: 34 + # 2019-08-20 35 + # version 0.3: Ben Harris (benharri) 36 + # * port for python3 37 + # 34 38 # 2010-05-08 35 39 # version 0.2: 36 40 # * complete any word behind the cursor, not just the last one in input line. ··· 46 50 WEECHAT_RC_OK = weechat.WEECHAT_RC_OK 47 51 import_ok = True 48 52 except ImportError: 49 - print "This script must be run under WeeChat." 50 - print "Get WeeChat now at: http://www.weechat.org/" 53 + print("This script must be run under WeeChat.") 54 + print("Get WeeChat now at: http://www.weechat.org/") 51 55 import_ok = False 52 56 53 57 SCRIPT_NAME = "completion" 54 58 SCRIPT_AUTHOR = "Elián Hanisch <lambdae2@gmail.com>" 55 - SCRIPT_VERSION = "0.2" 59 + SCRIPT_VERSION = "0.3" 56 60 SCRIPT_LICENSE = "GPL3" 57 61 SCRIPT_DESC = "Word completions for WeeChat" 58 62 SCRIPT_COMMAND = "completion" ··· 63 67 } 64 68 65 69 ### Messages ### 66 - def decode(s): 67 - if isinstance(s, str): 68 - s = s.decode('utf-8') 69 - return s 70 - 71 - def encode(u): 72 - if isinstance(u, unicode): 73 - u = u.encode('utf-8') 74 - return u 75 - 76 70 def debug(s, prefix='', buffer=None): 77 71 """Debug msg""" 78 72 #if not weechat.config_get_plugin('debug'): return ··· 84 78 weechat.buffer_set(buffer, 'nicklist', '0') 85 79 weechat.buffer_set(buffer, 'time_for_each_line', '0') 86 80 weechat.buffer_set(buffer, 'localvar_set_no_log', '1') 87 - s = encode(s) 88 81 weechat.prnt(buffer, '%s\t%s' %(prefix, s)) 89 82 90 83 def error(s, prefix=None, buffer='', trace=''): 91 84 """Error msg""" 92 85 prefix = prefix or script_nick 93 - s = encode(s) 94 86 weechat.prnt(buffer, '%s%s %s' %(weechat.prefix('error'), prefix, s)) 95 87 if weechat.config_get_plugin('debug'): 96 88 if not trace: ··· 102 94 def say(s, prefix=None, buffer=''): 103 95 """normal msg""" 104 96 prefix = prefix or script_nick 105 - s = encode(s) 106 97 weechat.prnt(buffer, '%s\t%s' %(prefix, s)) 107 98 108 99 print_replace = lambda k,v : say('%s %s=>%s %s' %(k, color_delimiter, color_reset, v)) 109 100 110 101 ### Config functions ### 111 - class UTFDict(dict): 112 - decode = staticmethod(decode) 113 - encode = staticmethod(encode) 114 - 115 - def __init__(self, d={}): 116 - dict.__init__(self) 117 - for k, v in d.iteritems(): 118 - self[k] = v 119 - 120 - def __setitem__(self, k, v): 121 - k = self.decode(k) 122 - v = self.decode(v) 123 - dict.__setitem__(self, k, v) 124 - 125 - def __getitem__(self, k): 126 - k = self.decode(k) 127 - return dict.__getitem__(self, k) 128 - 129 - def __delitem__(self, k): 130 - k = self.decode(k) 131 - dict.__delitem__(self, k) 132 - 133 - def __contains__(self, k): 134 - k = self.decode(k) 135 - return dict.__contains__(self, k) 136 - 137 - def __str__(self): 138 - values = [ '%s=>%s' %(k, v) for k, v in self.iteritems() ] 139 - values = ';;'.join(values) 140 - return self.encode(values) 141 - 142 - 143 102 def get_config_dict(config): 144 103 value = weechat.config_get_plugin(config) 145 104 if not value: 146 105 return {} 147 - values = value.split(';;') 148 - values = map(lambda s: s.split('=>'), values) 106 + values = [s.split('=>') for s in value.split(';;')] 149 107 #debug(values) 150 108 return dict(values) 151 109 152 110 def load_replace_table(): 153 111 global replace_table 154 - replace_table = UTFDict(get_config_dict('replace_values')) 112 + replace_table = dict(get_config_dict('replace_values')) 155 113 156 114 def save_replace_table(): 157 115 global replace_table 158 - weechat.config_set_plugin('replace_values', str(replace_table)) 116 + weechat.config_set_plugin('replace_values', 117 + ';;'.join(['%s=>%s' %(k, v) for k, v in replace_table.items()])) 159 118 160 119 ### Commands ### 161 120 def cmd_completion(data, buffer, args): 162 121 global replace_table 163 122 if not args: 164 123 if replace_table: 165 - for k, v in replace_table.iteritems(): 124 + for k, v in replace_table.items(): 166 125 print_replace(k, v) 167 126 else: 168 127 say('No completions.') ··· 189 148 def completion_replacer(data, completion_item, buffer, completion): 190 149 global replace_table 191 150 pos = weechat.buffer_get_integer(buffer, 'input_pos') 192 - input = decode(weechat.buffer_get_string(buffer, 'input')) 151 + input = weechat.buffer_get_string(buffer, 'input') 193 152 #debug('%r %s %s' %(input, len(input), pos)) 194 153 if pos > 0 and (pos == len(input) or input[pos] == ' '): 195 154 n = input.rfind(' ', 0, pos) ··· 202 161 replace += ' ' 203 162 n = len(word) 204 163 input = '%s%s%s' %(input[:pos-n], replace, input[pos:]) 205 - weechat.buffer_set(buffer, 'input', encode(input)) 164 + weechat.buffer_set(buffer, 'input', input) 206 165 weechat.buffer_set(buffer, 'input_pos', str(pos - n + len(replace))) 207 166 return WEECHAT_RC_OK 208 167 209 168 def completion_keys(data, completion_item, buffer, completion): 210 169 global replace_table 211 170 for k in replace_table: 212 - weechat.hook_completion_list_add(completion, encode(k), 0, weechat.WEECHAT_LIST_POS_SORT) 171 + weechat.hook_completion_list_add(completion, k, 0, weechat.WEECHAT_LIST_POS_SORT) 213 172 return WEECHAT_RC_OK 214 173 215 174 ### Main ### ··· 231 190 error('WeeChat 0.3.1 or newer is required for this script.') 232 191 else: 233 192 # settings 234 - for opt, val in settings.iteritems(): 193 + for opt, val in settings.items(): 235 194 if not weechat.config_is_set_plugin(opt): 236 195 weechat.config_set_plugin(opt, val) 237 196
+4 -2
weechat/.weechat/python/go.py
··· 21 21 # 22 22 # History: 23 23 # 24 + # 2019-07-11, Simmo Saan <simmo.saan@gmail.com> 25 + # version 2.6: fix detection of "/input search_text_here" 24 26 # 2017-04-01, Sébastien Helleu <flashcode@flashtux.org>: 25 27 # version 2.5: add option "buffer_number" 26 28 # 2017-03-02, Sébastien Helleu <flashcode@flashtux.org>: ··· 92 94 93 95 SCRIPT_NAME = 'go' 94 96 SCRIPT_AUTHOR = 'Sébastien Helleu <flashcode@flashtux.org>' 95 - SCRIPT_VERSION = '2.5' 97 + SCRIPT_VERSION = '2.6' 96 98 SCRIPT_LICENSE = 'GPL3' 97 99 SCRIPT_DESC = 'Quick jump to buffers' 98 100 ··· 480 482 def go_command_run_input(data, buf, command): 481 483 """Function called when a command "/input xxx" is run.""" 482 484 global buffers, buffers_pos 483 - if command == '/input search_text' or command.find('/input jump') == 0: 485 + if command.startswith('/input search_text') or command.startswith('/input jump'): 484 486 # search text or jump to another buffer is forbidden now 485 487 return weechat.WEECHAT_RC_OK_EAT 486 488 elif command == '/input complete_next':
+36 -32
weechat/.weechat/python/grep.py
··· 69 69 # 70 70 # History: 71 71 # 72 + # 2019-06-30, dabbill <dabbill@gmail.com> 73 + # and Sébastien Helleu <flashcode@flashtux.org> 74 + # version 0.8.2: make script compatible with Python 3 75 + # 72 76 # 2018-04-10, Sébastien Helleu <flashcode@flashtux.org> 73 77 # version 0.8.1: fix infolist_time for WeeChat >= 2.2 (WeeChat returns a long 74 78 # integer instead of a string) ··· 117 121 # * supress highlights when printing in grep buffer 118 122 # 119 123 # 2010-10-06 120 - # version 0.6.7: by xt <xt@bash.no> 124 + # version 0.6.7: by xt <xt@bash.no> 121 125 # * better temporary file: 122 - # use tempfile.mkstemp. to create a temp file in log dir, 126 + # use tempfile.mkstemp. to create a temp file in log dir, 123 127 # makes it safer with regards to write permission and multi user 124 128 # 125 129 # 2010-04-08 ··· 226 230 227 231 SCRIPT_NAME = "grep" 228 232 SCRIPT_AUTHOR = "Elián Hanisch <lambdae2@gmail.com>" 229 - SCRIPT_VERSION = "0.8.1" 233 + SCRIPT_VERSION = "0.8.2" 230 234 SCRIPT_LICENSE = "GPL3" 231 235 SCRIPT_DESC = "Search in buffers and logs" 232 236 SCRIPT_COMMAND = "grep" ··· 259 263 def get_matches_count(self): 260 264 """Return the sum of total matches stored.""" 261 265 if dict.__len__(self): 262 - return sum(map(lambda L: L.matches_count, self.itervalues())) 266 + return sum(map(lambda L: L.matches_count, self.values())) 263 267 else: 264 268 return 0 265 269 266 270 def __len__(self): 267 271 """Return the sum of total lines stored.""" 268 272 if dict.__len__(self): 269 - return sum(map(len, self.itervalues())) 273 + return sum(map(len, self.values())) 270 274 else: 271 275 return 0 272 276 ··· 274 278 """Returns buffer count or buffer name if there's just one stored.""" 275 279 n = len(self.keys()) 276 280 if n == 1: 277 - return self.keys()[0] 281 + return list(self.keys())[0] 278 282 elif n > 1: 279 283 return '%s logs' %n 280 284 else: ··· 282 286 283 287 def items(self): 284 288 """Returns a list of items sorted by line count.""" 285 - items = dict.items(self) 289 + items = list(dict.items(self)) 286 290 items.sort(key=lambda i: len(i[1])) 287 291 return items 288 292 289 293 def items_count(self): 290 294 """Returns a list of items sorted by match count.""" 291 - items = dict.items(self) 295 + items = list(dict.items(self)) 292 296 items.sort(key=lambda i: i[1].matches_count) 293 297 return items 294 298 295 299 def strip_separator(self): 296 - for L in self.itervalues(): 300 + for L in self.values(): 297 301 L.strip_separator() 298 302 299 303 def get_last_lines(self, n): ··· 302 306 if n >= total_lines: 303 307 # nothing to do 304 308 return 305 - for k, v in reversed(self.items()): 309 + for k, v in reversed(list(self.items())): 306 310 l = len(v) 307 311 if n > 0: 308 312 if l > n: ··· 487 491 return cache_dir[key] 488 492 except KeyError: 489 493 pass 490 - 494 + 491 495 filter_list = filter_list or get_config_log_filter() 492 496 dir_len = len(dir) 493 497 if filter_list: ··· 657 661 regexp = re.compile(pattern, re.IGNORECASE) 658 662 else: 659 663 regexp = re.compile(pattern) 660 - except Exception, e: 661 - raise Exception, 'Bad pattern, %s' %e 664 + except Exception as e: 665 + raise Exception('Bad pattern, %s' % e) 662 666 return regexp 663 667 664 668 def check_string(s, regexp, hilight='', exact=False): ··· 716 720 return s 717 721 else: 718 722 check = lambda s: check_string(s, regexp, hilight, exact) 719 - 723 + 720 724 try: 721 725 file_object = open(file, 'r') 722 726 except IOError: ··· 736 740 before_context, after_context = after_context, before_context 737 741 738 742 if before_context: 739 - before_context_range = range(1, before_context + 1) 743 + before_context_range = list(range(1, before_context + 1)) 740 744 before_context_range.reverse() 741 745 742 746 limit = tail or head ··· 800 804 while id < after_context + offset: 801 805 id += 1 802 806 try: 803 - context_line = file_object.next() 807 + context_line = next(file_object) 804 808 _context_line = check(context_line) 805 809 if _context_line: 806 810 offset = id ··· 1002 1006 global grep_options, log_pairs 1003 1007 for log_name, log in log_pairs: 1004 1008 result[log_name] = grep_file(log, *grep_options) 1005 - except Exception, e: 1009 + except Exception as e: 1006 1010 result = e 1007 1011 1008 1012 return pickle.dumps(result) ··· 1038 1042 if isinstance(data, Exception): 1039 1043 raise data 1040 1044 matched_lines.update(data) 1041 - except Exception, e: 1045 + except Exception as e: 1042 1046 set_buffer_error(repr(e)) 1043 1047 return WEECHAT_RC_OK 1044 1048 else: ··· 1180 1184 1181 1185 # free matched_lines so it can be removed from memory 1182 1186 del matched_lines 1183 - 1187 + 1184 1188 def split_line(s): 1185 1189 """Splits log's line 's' in 3 parts, date, nick and msg.""" 1186 1190 global weechat_format ··· 1280 1284 weechat.infolist_free(infolist) 1281 1285 try: 1282 1286 cmd_grep_parsing(input_data) 1283 - except Exception, e: 1284 - error('Argument error, %s' %e, buffer=buffer) 1287 + except Exception as e: 1288 + error('Argument error, %s' % e, buffer=buffer) 1285 1289 return WEECHAT_RC_OK 1286 1290 try: 1287 1291 show_matching_lines() 1288 - except Exception, e: 1292 + except Exception as e: 1289 1293 error(e) 1290 1294 except NameError: 1291 1295 error("There isn't any previous search to repeat.", buffer=buffer) ··· 1342 1346 1343 1347 args = ' '.join(args) # join pattern for keep spaces 1344 1348 if args: 1345 - pattern_tmpl = args 1349 + pattern_tmpl = args 1346 1350 pattern = _tmplRe.sub(tmplReplacer, args) 1347 1351 debug('Using regexp: %s', pattern) 1348 1352 if not pattern: 1349 - raise Exception, 'No pattern for grep the logs.' 1353 + raise Exception('No pattern for grep the logs.') 1350 1354 1351 1355 def positive_number(opt, val): 1352 1356 try: ··· 1359 1363 opt = '-' + opt 1360 1364 else: 1361 1365 opt = '--' + opt 1362 - raise Exception, "argument for %s must be a positive integer." %opt 1366 + raise Exception("argument for %s must be a positive integer." % opt) 1363 1367 1364 1368 for opt, val in opts: 1365 1369 opt = opt.strip('-') ··· 1454 1458 # parse 1455 1459 try: 1456 1460 cmd_grep_parsing(args) 1457 - except Exception, e: 1458 - error('Argument error, %s' %e) 1461 + except Exception as e: 1462 + error('Argument error, %s' % e) 1459 1463 return WEECHAT_RC_OK 1460 1464 1461 1465 # find logs ··· 1501 1505 # grepping 1502 1506 try: 1503 1507 show_matching_lines() 1504 - except Exception, e: 1508 + except Exception as e: 1505 1509 error(e) 1506 1510 return WEECHAT_RC_OK 1507 1511 ··· 1520 1524 opt = opt.strip('-') 1521 1525 if opt in ('size', 's'): 1522 1526 sort_by_size = True 1523 - except Exception, e: 1524 - error('Argument error, %s' %e) 1527 + except Exception as e: 1528 + error('Argument error, %s' % e) 1525 1529 return WEECHAT_RC_OK 1526 1530 1527 1531 # is there's a filter, filter_excludes should be False ··· 1703 1707 'completion_grep_args', '') 1704 1708 1705 1709 # settings 1706 - for opt, val in settings.iteritems(): 1710 + for opt, val in settings.items(): 1707 1711 if not weechat.config_is_set_plugin(opt): 1708 1712 weechat.config_set_plugin(opt, val) 1709 1713 ··· 1716 1720 color_summary = weechat.color('lightcyan') 1717 1721 color_delimiter = weechat.color('chat_delimiters') 1718 1722 color_script_nick = weechat.color('chat_nick') 1719 - 1723 + 1720 1724 # pretty [grep] 1721 1725 script_nick = '%s[%s%s%s]%s' %(color_delimiter, color_script_nick, SCRIPT_NAME, color_delimiter, 1722 1726 color_reset)
+2
weechat/.weechat/weechat.conf
··· 354 354 355 355 [notify] 356 356 irc.bitlbee = highlight 357 + perl.highmon = none 357 358 358 359 [filter] 359 360 irc_smart = on;*;irc_smart_filter;* 361 + markov_bitbot = on;irc.tilde.*;irc_privmsg;^,m(\s|arkov)|^\[Markov\] 360 362 361 363 [key] 362 364 ctrl-? = "/input delete_previous_char"