|
27 | 27 |
|
28 | 28 | SCLACK_SUBTYPE = 'sclack_message' |
29 | 29 |
|
30 | | -def get_token_file(): |
31 | | - base = os.path.expanduser(os.environ.get('XDG_DATA_HOME', '~')) |
32 | | - return os.path.join(base, 'sclack') |
33 | | - |
34 | | -TOKEN_FILE = get_token_file() |
35 | | - |
36 | 30 |
|
37 | 31 | class SclackEventLoop(urwid.AsyncioEventLoop): |
38 | 32 | def run(self): |
@@ -671,17 +665,17 @@ def quit_application(self): |
671 | 665 | sys.exit() |
672 | 666 |
|
673 | 667 | def ask_for_token(json_config): |
674 | | - if os.path.isfile(TOKEN_FILE): |
675 | | - with open(TOKEN_FILE, 'r') as user_file: |
| 668 | + if os.path.isfile(os.path.expanduser('~/.sclack')): |
| 669 | + with open(os.path.expanduser('~/.sclack'), 'r') as user_file: |
676 | 670 | # Compatible with legacy configuration file |
677 | 671 | new_config = json.load(user_file) |
678 | 672 | if not 'workspaces' in new_config: |
679 | 673 | new_config['workspaces'] = {'default': new_config['token']} |
680 | 674 | json_config.update(new_config) |
681 | 675 | else: |
682 | | - print('There is no %s file. Let\'s create one!' % TOKEN_FILE) |
| 676 | + print('There is no ~/.sclack file. Let\'s create one!') |
683 | 677 | token = input('What is your Slack workspace token? ') |
684 | | - with open(TOKEN_FILE, 'w') as config_file: |
| 678 | + with open(os.path.expanduser('~/.sclack'), 'w') as config_file: |
685 | 679 | token_config = {'workspaces': {'default': token}} |
686 | 680 | config_file.write(json.dumps(token_config, indent=False)) |
687 | 681 | json_config.update(token_config) |
|
0 commit comments