mirror of
https://github.com/gryf/slack-backup.git
synced 2025-12-17 11:30:25 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 64d4b09468 | |||
| 5f9f290ba4 | |||
|
|
08a0a82435 | ||
|
|
a42506dff9 | ||
|
|
0d7607cf3c |
2
setup.py
2
setup.py
@@ -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",
|
||||||
|
|||||||
@@ -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.
|
||||||
"""
|
"""
|
||||||
user = self.q(o.User).\
|
if data['type'] != 'message':
|
||||||
filter(o.User.slackid == data['user']).one()
|
logging.info("Skipping message of type `%s'.", data['type'])
|
||||||
|
return
|
||||||
|
|
||||||
if data['type'] == 'message' and not data['text'].strip():
|
try:
|
||||||
|
user = self.q(o.User).\
|
||||||
|
filter(o.User.slackid == data['user']).one()
|
||||||
|
except KeyError:
|
||||||
|
user = self.q(o.User).\
|
||||||
|
filter(o.User.slackid == data['comment']['user']).one()
|
||||||
|
|
||||||
|
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):
|
||||||
|
|||||||
@@ -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):
|
||||||
base, ext = os.path.splitext(path)
|
if count == 1:
|
||||||
path = base + "%0.3d" % count + ext
|
base, ext = os.path.splitext(path)
|
||||||
|
path = base + ".%0.3d" % count + ext
|
||||||
|
count += 1
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user