{_, _, _, _, Channels} = State#irc_state.config,
lists:foreach(fun join_channel/1, Channels),
State#irc_state{joined = true};
+ "PRIVMSG" ->
+ do_privmsg(Command),
+ State;
_ ->
% for now, just know that it happened
error_logger:info_msg("Received a line ~p~n", [Line]),
State
end.
+do_privmsg(_Command = #irc_command{middles = Middles, trailing = Text}) ->
+ case Text of
+ "!botsnack" ++ _ ->
+ Choices = {"*chomp*", ":P", "yay", "meh", "\\o/"},
+ Index = random:uniform(size(Choices)),
+ NewCommand = #irc_command{command = "PRIVMSG",
+ middles = Middles,
+ trailing = element(Index, Choices)},
+ send_command(NewCommand);
+ _ -> ok
+ end.
+
terminate(_Reason, _State) ->
ok.