Package: slackpile
The project aim is to collect conversations from Slack using its API and
optionally user account information, and provides convenient way to represent
as a log.RequirementsThis project is written in Python 3, 3.4 to be precise, although it may work on
earlier version of Python3. Sorry no support for Python2.Other than that, required packages are as follows:slackclient 1.0.2SQLAlchemy 1.0.10InstallationYou can install it usingpip installslack-backupcommand. Recommended way
is to create virtualenv, like so:user@localhost $virtualenv-ppython3myenvRunning virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in foobar/bin/python3
Also creating executable in foobar/bin/python
Installing setuptools, pip, wheel...done.user@localhost $.myenv/bin/activate(myenv)user@localhost $pipinstallslack-backupYou can also get this repository and install from it, like:user@localhost ~ $virtualenv-ppython3myenvRunning virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in foobar/bin/python3
Also creating executable in foobar/bin/python
Installing setuptools, pip, wheel...done.user@localhost $.myenv/bin/activate(myenv)user@localhost ~ $cdmyenv(myenv)user@localhost ~/myenv $gitclonehttps://github.com/gryf/slack-backup(myenv)user@localhost ~/myenv $cdslack-backup(myenv)user@localhost ~/myenv/slack-backup $pipinstall.UsageThere is a commandline tool calledslack-backup, which typical use would get
to gather the data and generate logs. Using example from above, here is a
typical session:(myenv)user@localhost ~/myenv/slack-backup $mkdir~/mylogs&&cd~/mylogs(myenv)user@localhost ~/mylogs $slack-backupfetch\--tokenxxxx-1111111111-222222222222-333333333333-r4nd0ms7uff\--usersome@email.address.org--passwordsecret--teammyteam\-qq-dmydatabase.sqlitewhere:--tokenis generated onSlack side tokenfor interaction with the API.
It’s required.--useris your slack account username…--password…and password. Those two are needed if you care about files
posted on the channels, which are hosted on Slack servers. They can be
skipped, if you don’t care about such files. Avatars still be downloaded
though. External resources will not be downloaded - they have URL anyway.--teamteam name. It is the part of the URL for your slack team; in other
words in URL likehttp://foobar.slack.comfoobaris the team name.-q(or--quiet) will suppress any messages from program. In contrary
there can be used--verboseto increase verbosity. Using this option
several times (up to three, above the number will have no effect) will amplify
effectiveness of either be quite or be verbose behaviour.-dor--databaseis the file path for database (which for now at least
is an sqlite database file). It can be omitted - in-memory db would be
created, but you’ll (obviously) lost all the records. Besides the db file,
assets directory might be created for downloadable items.During DB creation, all available messages are stored in the database. On the
next run,fetchwould only take those records, which are older from
currently oldest in DB. So that it will only fetch a subset of the overall of
the messages. As for the channels and users - complete information will be
downloaded every timefetchcommand would be used.Next, to generate a log files:(myenv)user@localhost ~/mylogs $slack-backupgenerate\-v-dmydatabase.sqlite--formattext-ologswhere:--formatis the desired format of the logs. For now onlytextformat
of the logs is supported (IRC style format). Formatnonewill produce
nothing.-oor--outputis the destination directory, where logs and possible
assets will land.The rest of the options (-dand-v) have same meaning as infetchcommand.See help for theslack-backupcommand for complete list of options.ConfigurationFor convenience, you can place all of needed options into configuration file
(aka .ini), which all options (with their defaults) will look like:[common]channels=database=quiet=0verbose=0[generate]output=format=texttheme=plain[fetch]user=password=team=token=Note, that you don’t have to put every option. To illustratefetchexample
from above, here is a corresponding config file:[common]database=mydatabase.sqlitequiet=2[fetch]user=some@email.address.orgpassword=secretteam=myteamtoken=xxxx-1111111111-222222222222-333333333333-r4nd0ms7uffNote, that only[common]and[fetch]sections are provided, so it is
enough to invokeslack-backupcommand as:(myenv)user@localhost ~/mylogs $slack-backupfetchThere are couple of places, where configuration file would be searched for, in
particular order:file provided via argument-ior--configslack-backup.iniin current directory$XDG_CONFIG_HOME/slack-backup.ini, where$XDG_CONFIG_HOMEusually
defaults to$HOME/.configDetailsDuring first run, database with provided name is generated. For ease of use
sqlite database is used, although it is easy to switch the engine, since there
is an ORM (SQLAlchemy) used.Slack users, channels and messages are mapped to SQLAlchemy models, as well as
other information, like:user profileschannel topicchannel purposemessage reactionsmessage attachmentsand filesChannels and users are always synchronized in every run, so every modification
to the user or channels are overwriting old data. During first run, all messages
are retrieved for all/selected channels. Every other run will only fetch those
messages, which are older then newest message in the database - so that we don’t
loose any old messages, which might be automatically removed from Slack servers.
The drawback of this behaviour is that all past messages which was altered in
the meantime will not be updated.LicenseThis work is licensed on 3-clause BSD license. See LICENSE file for details.