1
0
mirror of https://github.com/gryf/slack-backup.git synced 2025-12-17 19:40:21 +01:00

5 Commits
v0.4.4 ... v0.5

Author SHA1 Message Date
64d4b09468 Fix for handling messages of different types than 'message' 2017-08-06 09:22:38 +02:00
5f9f290ba4 Fix for message comment.
If comment is sent by the user, different structure of the data is sent.
First of all, the type of this message is "message", but it contain
dictionary under 'comment' key, which can be confusing, which contain
needed data (like user id). For this kind of messages, in case of lack
of 'user' in main dict, dict['comment']['user'] will be used for getting
user identifier, while dict['text'] remains as a message text.
2017-02-13 19:57:31 +01:00
Roman Dobosz
08a0a82435 Changed absolute to relative for filepaths stored in File objects 2016-12-03 18:43:49 +01:00
Roman Dobosz
a42506dff9 Fix for new fnames in case of already existing ones 2016-12-03 18:14:28 +01:00
Roman Dobosz
0d7607cf3c Added log for updating specific channel messages 2016-12-02 17:46:27 +01:00
4 changed files with 23 additions and 9 deletions

View File

@@ -10,7 +10,7 @@ except ImportError:
setup(name="slack-backup", setup(name="slack-backup",
packages=["slack_backup"], packages=["slack_backup"],
version="0.4.4", version="0.5",
description="Make copy of slack converstaions", description="Make copy of slack converstaions",
author="Roman Dobosz", author="Roman Dobosz",
author_email="gryf73@gmail.com", author_email="gryf73@gmail.com",

View File

@@ -112,6 +112,7 @@ class Client(object):
channels = all_channels channels = all_channels
for channel in channels: for channel in channels:
logging.info("Getting messages for channel `%s'", channel.name)
latest = self.q(o.Message).\ latest = self.q(o.Message).\
filter(o.Message.channel == channel).\ filter(o.Message.channel == channel).\
order_by(o.Message.ts.desc()).first() order_by(o.Message.ts.desc()).first()
@@ -146,10 +147,18 @@ class Client(object):
Create message with corresponding possible metadata, like reactions, Create message with corresponding possible metadata, like reactions,
files etc. files etc.
""" """
if data['type'] != 'message':
logging.info("Skipping message of type `%s'.", data['type'])
return
try:
user = self.q(o.User).\ user = self.q(o.User).\
filter(o.User.slackid == data['user']).one() filter(o.User.slackid == data['user']).one()
except KeyError:
user = self.q(o.User).\
filter(o.User.slackid == data['comment']['user']).one()
if data['type'] == 'message' and not data['text'].strip(): if not data['text'].strip():
logging.info("Skipping message from `%s' since it's empty", logging.info("Skipping message from `%s' since it's empty",
user.name) user.name)
return return
@@ -255,7 +264,7 @@ class Client(object):
if not database: if not database:
return 'assets' return 'assets'
path = os.path.dirname(os.path.abspath(database)) path = os.path.dirname(database)
return os.path.join(path, 'assets') return os.path.join(path, 'assets')
def _channels_list(self): def _channels_list(self):

View File

@@ -79,8 +79,10 @@ class Download(object):
count = 1 count = 1
while filetype != 'avatar' and os.path.exists(path): while filetype != 'avatar' and os.path.exists(path):
if count == 1:
base, ext = os.path.splitext(path) base, ext = os.path.splitext(path)
path = base + "%0.3d" % count + ext path = base + ".%0.3d" % count + ext
count += 1
return path return path

View File

@@ -324,7 +324,10 @@ MSGS = {'messages': [{"type": "message",
"<https://esm64.slack.com/files/name2/F3405RRB5/" "<https://esm64.slack.com/files/name2/F3405RRB5/"
"screenshot.png|Screenshot.png>", "screenshot.png|Screenshot.png>",
"ts": "1478107371.000052", "ts": "1478107371.000052",
"upload": True}], "upload": True},
{'type': 'something else',
'ts': '1502003415232.000001',
"wibblr": True}],
"ok": True, "ok": True,
"latest": "1479501075.000020", "latest": "1479501075.000020",
"has_more": True} "has_more": True}
@@ -389,7 +392,7 @@ class TestApiCalls(TestCase):
"C00000001").one() "C00000001").one()
msg, ts = cl._channels_history(channel, 0) msg, ts = cl._channels_history(channel, 0)
self.assertEqual(len(msg), 5) self.assertEqual(len(msg), 6)
self.assertEqual(ts, '1479501074.000032') self.assertEqual(ts, '1479501074.000032')
msg, ts = cl._channels_history(channel, ts) msg, ts = cl._channels_history(channel, ts)