Couple of months ago, file attachments was treated differently, than
now - API provides attached files as a list, instead of single object,
and is directly coupled with a message object. This change provides
support for such cases.
There was a rule for command line switches, and for ini file options,
where in command line options words are separated with hyphen and in ini
files options are separated with underscore. This rule wasn't always
enforced, fixed it now.
Using url_file_attachment user can specify if he like to change objects
like 'file_share' marked as external (in Slack servers point of view)
to attachments, so the only value would be remembered URL for the
"uploaded" document as an attachment. Or, treat it as is, and let the
slack-backup to produce file which contain the URLs and corresponding
local file names for such files.
Currently, if message contain shared file, slack-backup will try to
download it. If it fail, than empty file will remain, which will be at
least confusing. This will mostly happen for shares which are not
uploaded to the slack servers.
New option will be used to indicate if slack-backup should convert such
share as an attachment, or to save the list of URL and their
destination in local file system to be download manually by the user.
Currently, if messages are generated using bot users, such messages will
crash slack_backup, since user.list API method returns only regular
users. In this commit there is detected a situation, where we have
'bot_id' in the data, and in case there is no such user in local
database, create it using data from bot.info API call.
In case of user replacement there was a bunch of regular expressions
used, which was an overkill. Substituted them with one generic regexp.
Moved method which is responsible for substitution to the base class.
Last change is a cosmetic one - uploaded files are represented as
absolute path with file:// prefix, so that it is easier to open it with
xdg-open for example.
Till now, if we download certain files (like those attached to the
conversation) and we already have the file with the same name, number in
format '%03d' was added just before extension. That way there could be
possibility, that the very same file will be downloaded and stored
multiple times, like:
file.png
file.001.png
file.002.png
...
This commit prevents that by adding comparison between files we already
have and file which is downloaded from slack. Adding another file with
additional number will only have place when stored file and downloaded
have different content.
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.
For some reason, database key was treated differently in configparser object
in python 3.4.2. In Python 3.4.5 everything is fine. Fixed the defaults to
make sure all string options are treated equally.