Fix a bug to allow channels that do not have AMQP queues
authorMatt Mullins <mmullins@mmlx.us>
Thu, 1 Sep 2011 19:42:22 +0000 (14:42 -0500)
committerMatt Mullins <mmullins@mmlx.us>
Thu, 1 Sep 2011 19:42:22 +0000 (14:42 -0500)
irc/irc_conn.erl

index f4ed6cc..d8d3d5e 100644 (file)
@@ -136,10 +136,12 @@ join_channel(Channel, State) ->
     #irc_state{object_sup = ObjectSup,
                instance = Instance
               } = State,
-
-    {{Instance, Channel}, RoutingKey} = lists:keyfind({Instance, Channel},
-                1, config:get_config(irc_amqp_bind)),
-    {ok, _ChildPid} = irc_object_sup:add_amqp_listener(ObjectSup, self(), Channel, RoutingKey).
+    case lists:keyfind({Instance, Channel}, 1, config:get_config(irc_amqp_bind)) of
+        {{Instance, Channel}, RoutingKey} ->
+            {ok, _ChildPid} = irc_object_sup:add_amqp_listener(
+                    ObjectSup, self(), Channel, RoutingKey);
+        false -> ok
+    end.
 
 %% @doc Splits a buffer into full lines, keeping whatever is left over
 %% Returns either {ok, [Line], Remaining} or none.