From a6fc4a092c5896a620549c5049887345a865ecdd Mon Sep 17 00:00:00 2001 From: Jacob Gable Date: Wed, 18 Jul 2012 21:39:40 -0500 Subject: [PATCH] Adding some helpful errors for missing environment variables --- src/irc.coffee | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/irc.coffee b/src/irc.coffee index 6864702..312033e 100644 --- a/src/irc.coffee +++ b/src/irc.coffee @@ -73,9 +73,19 @@ class IrcBot extends Adapter command: (command, strings...) -> @bot.send command, strings... + checkCanStart: -> + if not process.env.HUBOT_IRC_NICK or @robot.name + throw new Error("HUBOT_IRC_NICK is not defined; try: export HUBOT_IRC_NICK='mybot'") + else if not process.env.HUBOT_IRC_ROOMS + throw new Error("HUBOT_IRC_ROOMS is not defined; try: export HUBOT_IRC_ROOMS='#myroom'") + else if not process.env.HUBOT_IRC_SERVER + throw new Error("HUBOT_IRC_SERVER is not defined: try: export HUBOT_IRC_SERVER='irc.myserver.com'") + run: -> self = @ + do @checkCanStart + options = nick: process.env.HUBOT_IRC_NICK or @robot.name port: process.env.HUBOT_IRC_PORT