Skip to content

Commit 491216d

Browse files
committed
Merge pull request #106 from strugee/better-env-warnings
Handle missing environment variables
2 parents 61caf0e + ef84c07 commit 491216d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/xmpp.coffee

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class XmppBot extends Adapter
2121
String::startsWith ?= (s) -> @slice(0, s.length) == s
2222

2323
run: ->
24+
do @checkCanStart
25+
2426
options =
2527
username: process.env.HUBOT_XMPP_USERNAME
2628
password: '********'
@@ -441,5 +443,13 @@ class XmppBot extends Adapter
441443
offline: =>
442444
@robot.logger.debug "Received offline event"
443445

446+
checkCanStart: =>
447+
if not process.env.HUBOT_XMPP_USERNAME
448+
throw new Error("HUBOT_XMPP_USERNAME is not defined; try: export HUBOT_XMPP_USERNAME='user@xmpp.service'")
449+
else if not process.env.HUBOT_XMPP_PASSWORD
450+
throw new Error("HUBOT_XMPP_PASSWORD is not defined; try: export HUBOT_XMPP_PASSWORD='password'")
451+
else if not process.env.HUBOT_XMPP_ROOMS
452+
throw new Error("HUBOT_XMPP_ROOMS is not defined: try: export HUBOT_XMPP_ROOMS='room@conference.xmpp.service'")
453+
444454
exports.use = (robot) ->
445455
new XmppBot robot

0 commit comments

Comments
 (0)