slackup 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/slackup.rb +19 -12
- data/lib/slackup/channels.rb +20 -0
- data/lib/slackup/groups.rb +19 -0
- data/lib/slackup/ims.rb +12 -0
- data/lib/slackup/stars.rb +11 -0
- data/lib/slackup/users.rb +11 -0
- data/lib/slackup/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2a6ccd804fcb8f4b965e9a95e71fc893d3eb263
|
4
|
+
data.tar.gz: be9b759ec58de1e56ed08722e9cbfbb963a0e658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8286cfb800e9349830e4ebd2b219c521997707cfd7e7e0dbbb10e251e170e56348d0ffc882514e8608206840e0e0390d2875769a52f20a516a76456e10c69d11
|
7
|
+
data.tar.gz: 36307a23aff28e4927e5b74e507c0940685e557d41051766842246bd776411ac86a62761eb6d7fc0b2974227cfffb96f94fb4ce69ded2cc59b84d44c7d9dbf61
|
data/README.md
CHANGED
@@ -20,6 +20,11 @@ where each team config is a dictionary (hash) as below:
|
|
20
20
|
| name (required) | the team name. e.g. `some-team` in `some-team.slackup.com`. Is used as backup directory name for the team.
|
21
21
|
| nickname (optional) | a nickname. When present, overrides `name` as the backup directory name for the team.
|
22
22
|
| token (required) | https://api.slack.com/custom-integrations/legacy-tokens
|
23
|
+
| channels (optional) | array of whitelisted channels to include. Default is to include all
|
24
|
+
| groups (optional) | array of whitelisted groups to include. Default is to include all
|
25
|
+
| users (optional) | boolean whether to write out users
|
26
|
+
| stars (optional) | boolean whether to write out stars
|
27
|
+
| ims (optional) | boolean whether to write out ims
|
23
28
|
|
24
29
|
e.g.
|
25
30
|
|
@@ -32,6 +37,14 @@ slack_teams.yml
|
|
32
37
|
- name: another-team
|
33
38
|
nickname: ateam
|
34
39
|
token: xxxp-different-token
|
40
|
+
channels:
|
41
|
+
- general
|
42
|
+
# - random
|
43
|
+
groups:
|
44
|
+
- core-maintainers
|
45
|
+
users: true
|
46
|
+
stars: false
|
47
|
+
ims: true
|
35
48
|
```
|
36
49
|
|
37
50
|
slack_teams.json
|
data/lib/slackup.rb
CHANGED
@@ -46,10 +46,7 @@ class Slackup
|
|
46
46
|
def self.backup(team_config = team_config())
|
47
47
|
team_config.each do |config|
|
48
48
|
fork do
|
49
|
-
|
50
|
-
token = config.fetch("token")
|
51
|
-
client = configure_client(token)
|
52
|
-
new(name, client).execute
|
49
|
+
new(config).execute
|
53
50
|
end
|
54
51
|
end
|
55
52
|
p Process.waitall
|
@@ -57,9 +54,10 @@ class Slackup
|
|
57
54
|
|
58
55
|
attr_reader :name, :client
|
59
56
|
alias dirname name
|
60
|
-
def initialize(
|
61
|
-
@
|
62
|
-
@
|
57
|
+
def initialize(config, client=nil)
|
58
|
+
@config = config
|
59
|
+
@name = config.fetch("nickname") { config.fetch("name") }
|
60
|
+
@client = client || configure_client
|
63
61
|
FileUtils.mkdir_p(name)
|
64
62
|
end
|
65
63
|
|
@@ -69,14 +67,23 @@ class Slackup
|
|
69
67
|
|
70
68
|
def write!
|
71
69
|
Dir.chdir(dirname) do
|
72
|
-
Channels.new(
|
73
|
-
Groups.new(
|
74
|
-
Stars.new(
|
70
|
+
Channels.new(config, client).write!
|
71
|
+
Groups.new(config, client).write!
|
72
|
+
Stars.new(config, client).write!
|
75
73
|
user_client.write!
|
76
|
-
Ims.new(
|
74
|
+
Ims.new(config, client).write!
|
77
75
|
end
|
78
76
|
end
|
79
77
|
|
78
|
+
def configure_client
|
79
|
+
token = config.fetch("token")
|
80
|
+
self.class.configure_client(token)
|
81
|
+
end
|
82
|
+
|
83
|
+
protected
|
84
|
+
|
85
|
+
attr_reader :config
|
86
|
+
|
80
87
|
private
|
81
88
|
|
82
89
|
def authorize!
|
@@ -122,7 +129,7 @@ class Slackup
|
|
122
129
|
end
|
123
130
|
|
124
131
|
def user_client
|
125
|
-
@user_client ||= Users.new(
|
132
|
+
@user_client ||= Users.new(config, client)
|
126
133
|
end
|
127
134
|
|
128
135
|
def users
|
data/lib/slackup/channels.rb
CHANGED
@@ -5,8 +5,28 @@ class Slackup::Channels < Slackup
|
|
5
5
|
end
|
6
6
|
alias channels list
|
7
7
|
|
8
|
+
def configured_channels
|
9
|
+
@configured_channels ||= config.fetch("channels", [])
|
10
|
+
end
|
11
|
+
|
12
|
+
def write_channel?(channel)
|
13
|
+
whitelisted_channel = channel["name"] if configured_channels.empty?
|
14
|
+
whitelisted_channel ||= configured_channels.find do |channel_name|
|
15
|
+
channel["name_normalized"] == channel_name or
|
16
|
+
channel["name"] == channel_name
|
17
|
+
end
|
18
|
+
if whitelisted_channel
|
19
|
+
p [name, :channels, "Writing #{whitelisted_channel}"]
|
20
|
+
true
|
21
|
+
else
|
22
|
+
p [name, :channels, "Skipping #{channel["name"]}"]
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
8
27
|
def write!
|
9
28
|
channels.each do |channel|
|
29
|
+
next unless write_channel?(channel)
|
10
30
|
write_messages(channel)
|
11
31
|
end
|
12
32
|
end
|
data/lib/slackup/groups.rb
CHANGED
@@ -30,9 +30,28 @@ class Slackup::Groups < Slackup
|
|
30
30
|
end
|
31
31
|
alias groups list
|
32
32
|
|
33
|
+
def configured_groups
|
34
|
+
@configured_groups ||= config.fetch("groups", [])
|
35
|
+
end
|
36
|
+
|
37
|
+
def write_group?(group)
|
38
|
+
whitelisted_group = group["name"] if configured_groups.empty?
|
39
|
+
whitelisted_group ||= @configured_groups.find do |group_name|
|
40
|
+
group["name"] == group_name
|
41
|
+
end
|
42
|
+
if whitelisted_group
|
43
|
+
p [name, :groups, "Writing #{whitelisted_group}"]
|
44
|
+
true
|
45
|
+
else
|
46
|
+
p [name, :groups, "Skipping #{group["name"]}"]
|
47
|
+
false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
33
51
|
def write!
|
34
52
|
Dir.chdir(groups_dir) do
|
35
53
|
groups.each do |group|
|
54
|
+
next unless write_group?(group)
|
36
55
|
write_messages(group)
|
37
56
|
end
|
38
57
|
end
|
data/lib/slackup/ims.rb
CHANGED
@@ -17,9 +17,21 @@ class Slackup::Ims < Slackup
|
|
17
17
|
end
|
18
18
|
alias ims list
|
19
19
|
|
20
|
+
def write_ims?
|
21
|
+
if config.fetch("ims", true)
|
22
|
+
p [name, :ims, "Writing"]
|
23
|
+
true
|
24
|
+
else
|
25
|
+
p [name, :ims, "Skipping"]
|
26
|
+
false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
20
30
|
def write!
|
31
|
+
return unless write_ims?
|
21
32
|
Dir.chdir(ims_dir) do
|
22
33
|
ims.each do |im|
|
34
|
+
# p [:ims, im.user, format_username(im.user)]
|
23
35
|
write_messages(im)
|
24
36
|
end
|
25
37
|
end
|
data/lib/slackup/stars.rb
CHANGED
@@ -5,7 +5,18 @@ class Slackup::Stars < Slackup
|
|
5
5
|
end
|
6
6
|
alias stars list
|
7
7
|
|
8
|
+
def write_stars?
|
9
|
+
if config.fetch("stars", true)
|
10
|
+
p [name, :stars, "Writing"]
|
11
|
+
true
|
12
|
+
else
|
13
|
+
p [name, :stars, "Skipping"]
|
14
|
+
false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
def write!
|
19
|
+
return unless write_stars?
|
9
20
|
with_messages "stars", list do |messages|
|
10
21
|
File.open(backup_filename("stars"), "w") do |f|
|
11
22
|
f.write(serialize(messages))
|
data/lib/slackup/users.rb
CHANGED
@@ -53,7 +53,18 @@ class Slackup::Users < Slackup
|
|
53
53
|
end
|
54
54
|
alias users list
|
55
55
|
|
56
|
+
def write_users?
|
57
|
+
if config.fetch("users", true)
|
58
|
+
p [name, :users, "Writing"]
|
59
|
+
true
|
60
|
+
else
|
61
|
+
p [name, :users, "Skipping"]
|
62
|
+
false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
56
66
|
def write!
|
67
|
+
return unless write_users?
|
57
68
|
File.open(backup_filename("users"), "w") do |f|
|
58
69
|
f.write(serialize(users.map(&:to_hash)))
|
59
70
|
end
|
data/lib/slackup/version.rb
CHANGED