Skip to content

Commit 985f864

Browse files
Fixed token containing newlines
1 parent d7cbc60 commit 985f864

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

NotifierBot/Sources/Notifier/main.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@ let bot: Bot!
5151

5252
do {
5353

54-
if let t = try? String(contentsOfFile: "BOT_TOKEN") {
54+
if let t = try? String(contentsOfFile: "BOT_TOKEN").components(separatedBy: .newlines).first {
5555
// Read the token from a the file
56+
print("Reading token from file.")
5657
token = t
5758
} else if let t = Enviroment.get("TELEGRAM_BOT_TOKEN") {
5859
// Read the token from the environment, if it exists
60+
print("Reading token from environment.")
5961
token = t
6062
} else {
63+
print("Error: Unable to read token.")
6164
exit(1)
6265
}
6366
bot = try Bot(token: token)

0 commit comments

Comments
 (0)