mirror of
https://github.com/gryf/slack-backup.git
synced 2025-12-17 19:40:21 +01:00
Added channels and format options
This commit is contained in:
@@ -4,24 +4,34 @@
|
|||||||
Create backup for certain date for specified channel in slack
|
Create backup for certain date for specified channel in slack
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
import pprint
|
import json
|
||||||
|
|
||||||
from slack_backup import client
|
from slack_backup import client
|
||||||
|
|
||||||
|
|
||||||
|
def channel_list(string):
|
||||||
|
return string.split(',')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main function"""
|
"""Main function"""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("token", help="Slack token - a string, which can be"
|
parser.add_argument('-t', '--token', required=True, help='Slack token - '
|
||||||
" generated/obtained via "
|
'a string, which can be generated/obtained via '
|
||||||
"https://api.slack.com/docs/oauth-test-tokens page")
|
'https://api.slack.com/docs/oauth-test-tokens page')
|
||||||
parser.add_argument('-d', '--database', default='',
|
parser.add_argument('-d', '--database', default='',
|
||||||
help='Path to the database file')
|
help='Path to the database file')
|
||||||
|
parser.add_argument('-f', '--format', default='text',
|
||||||
|
choices=('text', 'json', 'html', 'none'),
|
||||||
|
help='Output format. Default is none; only database '
|
||||||
|
'is updated by latest messages for all/selected '
|
||||||
|
'channels.')
|
||||||
|
parser.add_argument('-c', '--channels', default=[], nargs='+',
|
||||||
|
help='List of channels to perform actions on. '
|
||||||
|
'Default is all channels')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
slack = client.Client(args.token, args.database)
|
slack = client.Client(args.token, args.database)
|
||||||
|
slack.update_history(selected_channels=args.channels)
|
||||||
pprint.pprint(slack.get_hisotry(selected_channels=['elysium']))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user