slackup 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/lib/slackup.rb +50 -0
- data/lib/slackup/version.rb +1 -1
- metadata +2 -3
- data/Gemfile.lock +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 227551c418ddd3f0a6eeabe2fd4695302f336bad
|
4
|
+
data.tar.gz: d1df8e777fd3f2a3056cb52bee0e81c671851455
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6195c397e38e9c35938c59b83d36befd34ed4953d2eed8ff0c7e1a5636379294c7aad8e3da94a5b2b6c3c0c4b99ddd4fd2cc2c58829fc3f55f4141d4d8b22733
|
7
|
+
data.tar.gz: 255e5b4e693b5717f3533eeb5b97c6bb6d40af1782f8948f50444b3f5c595b130361ffba1f4ab5db6f2f3ec08e6deba492010dcb0a2efb8d724b1c0896ecd351
|
data/.gitignore
CHANGED
data/lib/slackup.rb
CHANGED
@@ -46,6 +46,11 @@ class Slackup
|
|
46
46
|
channels.each do |channel|
|
47
47
|
write_channel_messages(channel)
|
48
48
|
end
|
49
|
+
Dir.chdir(groups_dir) do
|
50
|
+
groups.each do |group|
|
51
|
+
write_group_messages(group)
|
52
|
+
end
|
53
|
+
end
|
49
54
|
write_stars
|
50
55
|
write_users
|
51
56
|
Dir.chdir(ims_dir) do
|
@@ -130,6 +135,35 @@ class Slackup
|
|
130
135
|
@channels ||= Slack.channels_list["channels"]
|
131
136
|
end
|
132
137
|
|
138
|
+
# {
|
139
|
+
# "ok": true,
|
140
|
+
# "groups": [
|
141
|
+
# {
|
142
|
+
# "id": "G0ABC",
|
143
|
+
# "name": "some-group",
|
144
|
+
# "is_group": true,
|
145
|
+
# "created": 1436923155,
|
146
|
+
# "creator": "UABC",
|
147
|
+
# "is_archived": false,
|
148
|
+
# "members": [
|
149
|
+
# ],
|
150
|
+
# "topic": {
|
151
|
+
# "value": "",
|
152
|
+
# "creator": "",
|
153
|
+
# "last_set": 0
|
154
|
+
# },
|
155
|
+
# "purpose": {
|
156
|
+
# "value": "Some group",
|
157
|
+
# "creator": "UABC",
|
158
|
+
# "last_set": 1437105751
|
159
|
+
# }
|
160
|
+
# }
|
161
|
+
# ]
|
162
|
+
# }
|
163
|
+
def groups
|
164
|
+
@groups ||= Slack.groups_list["groups"]
|
165
|
+
end
|
166
|
+
|
133
167
|
Im = Struct.new(:im_hash) do
|
134
168
|
def id; im_hash["id"]; end
|
135
169
|
|
@@ -174,6 +208,15 @@ class Slackup
|
|
174
208
|
end
|
175
209
|
end
|
176
210
|
|
211
|
+
# https://api.slack.com/methods/groups.history
|
212
|
+
def write_group_messages(group)
|
213
|
+
messages = Slack.groups_history(channel: group["id"], count: "1000")["messages"]
|
214
|
+
File.open(backup_filename(group["name"]), "w") do |f|
|
215
|
+
formatted_messages = format_group_messages(messages)
|
216
|
+
f.write serialize(formatted_messages)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
177
220
|
def format_messages(messages)
|
178
221
|
messages.reverse.map { |msg|
|
179
222
|
if msg.has_key?("text") && msg.has_key?("user")
|
@@ -190,6 +233,7 @@ class Slackup
|
|
190
233
|
end
|
191
234
|
|
192
235
|
alias_method :format_channel_messages, :format_messages
|
236
|
+
alias_method :format_group_messages, :format_messages
|
193
237
|
alias_method :format_im_messages, :format_messages
|
194
238
|
|
195
239
|
# gets user name for an id, if mapping is known, else returns the input
|
@@ -235,6 +279,12 @@ class Slackup
|
|
235
279
|
@ims_dir
|
236
280
|
end
|
237
281
|
|
282
|
+
def groups_dir
|
283
|
+
@groups_dir ||= "groups"
|
284
|
+
FileUtils.mkdir_p(@groups_dir)
|
285
|
+
@groups_dir
|
286
|
+
end
|
287
|
+
|
238
288
|
def backup_filename(name)
|
239
289
|
"#{name}.yml"
|
240
290
|
end
|
data/lib/slackup/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slackup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Fleischer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-api
|
@@ -69,7 +69,6 @@ files:
|
|
69
69
|
- ".gitignore"
|
70
70
|
- CODE_OF_CONDUCT.md
|
71
71
|
- Gemfile
|
72
|
-
- Gemfile.lock
|
73
72
|
- LICENSE
|
74
73
|
- README.md
|
75
74
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
slackup (0.0.5)
|
5
|
-
slack-api (~> 1.1, >= 1.1.3)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
eventmachine (1.0.7)
|
11
|
-
faraday (0.9.1)
|
12
|
-
multipart-post (>= 1.2, < 3)
|
13
|
-
faraday_middleware (0.9.1)
|
14
|
-
faraday (>= 0.7.4, < 0.10)
|
15
|
-
faye-websocket (0.9.2)
|
16
|
-
eventmachine (>= 0.12.0)
|
17
|
-
websocket-driver (>= 0.5.1)
|
18
|
-
multi_json (1.11.1)
|
19
|
-
multipart-post (2.0.0)
|
20
|
-
rake (10.4.2)
|
21
|
-
slack-api (1.1.6)
|
22
|
-
faraday (>= 0.7, < 0.10)
|
23
|
-
faraday_middleware (~> 0.8)
|
24
|
-
faye-websocket (~> 0.9.2)
|
25
|
-
multi_json (~> 1.0, >= 1.0.3)
|
26
|
-
websocket-driver (0.5.4)
|
27
|
-
websocket-extensions (>= 0.1.0)
|
28
|
-
websocket-extensions (0.1.2)
|
29
|
-
|
30
|
-
PLATFORMS
|
31
|
-
ruby
|
32
|
-
|
33
|
-
DEPENDENCIES
|
34
|
-
bundler (~> 1.9)
|
35
|
-
rake (~> 10.0)
|
36
|
-
slackup!
|