join_channel(Channel, State) ->
Command = #irc_command{command = "JOIN", middles = [Channel]},
send_command(Command),
- #irc_state{ object_sup = ObjectSup } = State,
- {ok, _ChildPid} = irc_object_sup:add_amqp_listener(ObjectSup, self(), Channel).
+ #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).
%% @doc Splits a buffer into full lines, keeping whatever is left over
%% Returns either {ok, [Line], Remaining} or none.
-export([
start_link/3,
- add_amqp_listener/3
+ add_amqp_listener/4
]).
-export([init/1]).
RestartStrategy = {one_for_one, 5, 60},
{ok, {RestartStrategy, Children}}.
-add_amqp_listener(ObjectSup, ConnectionPid, Channel) ->
+add_amqp_listener(ObjectSup, ConnectionPid, Channel, RoutingKey) ->
Child = {"amqp_" ++ Channel,
% TODO: ↓ fix the routing key
- {irc_amqp_listener, start_link, [ConnectionPid, Channel, "foobar"]},
+ {irc_amqp_listener, start_link, [ConnectionPid, Channel, RoutingKey]},
transient,
brutal_kill,
worker,