Skip to content

Commit d7cbc60

Browse files
Bot now prefers reading the token from file instead of environment
1 parent f0ffe15 commit d7cbc60

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

NotifierBot/Sources/Notifier/main.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ let bot: Bot!
5151

5252
do {
5353

54-
if let t = Enviroment.get("TELEGRAM_BOT_TOKEN") {
54+
if let t = try? String(contentsOfFile: "BOT_TOKEN") {
55+
// Read the token from a the file
56+
token = t
57+
} else if let t = Enviroment.get("TELEGRAM_BOT_TOKEN") {
5558
// Read the token from the environment, if it exists
5659
token = t
5760
} else {
58-
// Read the token from a the file
59-
token = try String(contentsOfFile: "BOT_TOKEN")
61+
exit(1)
6062
}
6163
bot = try Bot(token: token)
6264

0 commit comments

Comments
 (0)