From b40556cec295c1e8a0d809e8d022cda3772d655a Mon Sep 17 00:00:00 2001
From: Seb Seager <seb.seager@gmail.com>
Date: Tue, 5 Jan 2021 18:07:45 -0600
Subject: [PATCH] .env optional for standalone exporter

---
 README.md   | 8 +++++++-
 exporter.py | 6 ++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index b3feca8..f33c831 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,13 @@ There are two ways to use `slack-exporter` (detailed below). Both require a Slac
 
 `exporter.py` can create an archive of all conversation history in your workspace which is accessible to your user account.
 
-1. Run the following (replacing the value with the user token you obtained in the [Authentication with Slack](#authentication-with-slack) section above).
+1. Either add 
+
+    ```text
+    SLACK_USER_TOKEN = xoxp-xxxxxxxxxxxxx...
+    ```
+    
+    to a file named `.env` in the same directory as `exporter.py`, or run the following in your shell (replacing the value with the user token you obtained in the [Authentication with Slack](#authentication-with-slack) section above).
 
     ```shell script
     export SLACK_USER_TOKEN=xoxp-xxxxxxxxxxxxx...
diff --git a/exporter.py b/exporter.py
index cad317c..e2a324d 100644
--- a/exporter.py
+++ b/exporter.py
@@ -4,9 +4,11 @@ import requests
 import json
 from datetime import datetime
 import argparse
-
 from dotenv import load_dotenv
-load_dotenv(os.path.join(os.path.dirname(__file__), '.env'))
+
+env_file = os.path.join(os.path.dirname(__file__), '.env')
+if os.path.isfile(env_file):
+    load_dotenv(env_file)
 
 
 # pagination handling