1
1
#
2
2
# (c) 2013 Hendrik 'henk' Jaeger <[email protected] >
3
+ # (c) 2015 arza <[email protected] >
3
4
#
4
5
# This program is free software; you can redistribute it and/or modify
5
6
# it under the terms of the GNU General Public License as published by
15
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
#
17
18
19
+ # Changelog:
20
+ # 2013-10-19 0.0.1 henk:
21
+ # - initial release
22
+ # 2015-09-24 0.1 arza:
23
+ # - option -m/--minimum for minimum count of mutual channels
24
+ # - fixed completion
25
+
18
26
def weechat_init
19
27
Weechat . register (
20
28
"samechannel" ,
21
29
"henk" ,
22
- "0.0. 1" ,
30
+ "0.1" ,
23
31
"GPL3" ,
24
32
"Lists multiple occurences of the same nick(s) in a set of channels." ,
25
33
"" ,
@@ -29,34 +37,33 @@ def weechat_init
29
37
Weechat . hook_command (
30
38
"samechannel" ,
31
39
"Lists multiple occurences of the same nick(s) in a set of channels." ,
32
- "[[-s| --servers] servername[,...]] [[-c| --channels] channelname[,...]] [[-n| --nicks] nickname[,...]]" ,
40
+ "[-s/ --servers servername[,...]] [-c/ --channels channelname[,...]] [-n/ --nicks nickname[,...]] [-m/--minimum minimum ]" ,
33
41
"--servers servername[,servername],...]
34
42
--channels channelname[@servername][,channelname[@servername],...]
35
43
--nicks nickname[,nickname,...]
36
- Options used to set filters. All given names are treated as regular expressions. If no names are given, no filters are set.
44
+ --minimum minimum (default: 2)
37
45
38
- WARNING: If you are joined to MANY or even just a few very crowded channels, this script may have to do a lot of comparisons!
46
+ Options used to set filters. All given names are treated as regular expressions. If no names are given, no filters are set.
39
47
40
48
NOTE: Only nicknames from channels the client is joined to are available for comparison!
41
49
42
50
EXAMPLES:
51
+
52
+ /samechannel -m 5 -s freenode,IRCnet
53
+ Lists nicks found on at least five channels in freenode and IRCnet combined.
54
+
43
55
/samechannel --channels foo
44
- Lists nicks found in more than two channels on all servers.
56
+ Lists nicks found on at least two channels that include 'foo' on all servers.
45
57
46
58
/samechannel --nicks barbaz,hons --servers example,foobarbaz
47
59
Lists channels from the servers example and foobarbaz for each given nick.
48
60
49
61
/samechannel --nicks foo --channels ^#example.*@.*free.*$
50
62
Lists channels you share with nick foo that begin with 'example' from every server with 'free' in their names." ,
51
- "-servers %(irc_servers)
52
- || -servers %(irc_servers) -channels %(irc_channels)
53
- || -servers %(irc_servers) -nicks %(irc_server_nicks)
54
- || -channels %(irc_channels)
55
- || -channels %(irc_channels) -servers %(irc_servers)
56
- || -channels %(irc_channels) -nicks %(irc_server_nicks)
57
- || -nicks %(irc_server_nicks)
58
- || -nicks %(irc_server_nicks) -servers %(irc_servers)
59
- || -nicks %(irc_server_nicks) -channels %(irc_channels)" ,
63
+ "--minimum" +
64
+ "|| --servers %(irc_servers) --minimum --channels %(irc_channels)" +
65
+ "|| --channels %(irc_channels) --servers %(irc_servers)" +
66
+ "|| --nicks %(irc_server_nicks) --servers %(irc_servers)" ,
60
67
"samechannel_cb" ,
61
68
""
62
69
)
@@ -98,8 +105,11 @@ def samechannel_cb( data, buffer, args )
98
105
end
99
106
end
100
107
108
+ minimum = options [ :minimumfilter ] . to_i
109
+ minimum = 2 if minimum ==0
110
+
101
111
duplicate_nicks = nickcount . delete_if do |nickname , nickpaths |
102
- nickpaths . length <= 1
112
+ nickpaths . length < minimum
103
113
end
104
114
duplicate_nicks_sorted = duplicate_nicks . sort do |a , b |
105
115
a [ 1 ] . length <=> b [ 1 ] . length
@@ -168,6 +178,7 @@ def get_options( args )
168
178
options = Hash . new
169
179
170
180
opt_parser = OptionParser . new do |opts |
181
+
171
182
opts . on ( "-c" , "--channels channelname[,channelname,...]" ,
172
183
"Only channels matching the given (partial) channelname(s) will be considered.)" ) do |channels |
173
184
options [ :channelfilter ] = channels . split ( ',' )
@@ -182,6 +193,12 @@ def get_options( args )
182
193
"Only servers matching the given (partial) servername(s) will be considered.)" ) do |servers |
183
194
options [ :serverfilter ] = servers . split ( ',' )
184
195
end
196
+
197
+ opts . on ( "-m" , "--minimum minimum" ,
198
+ "Only nicks with at least this many matches will be considered." ) do |minimum |
199
+ options [ :minimumfilter ] = minimum
200
+ end
201
+
185
202
end
186
203
187
204
opt_parser . parse ( args )
0 commit comments