From: Matt Mullins Date: Sun, 22 May 2011 06:26:00 +0000 (-0500) Subject: Added botsnack functionality to the irc application X-Git-Tag: v4~2 X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=4a58aa67cab65320c7039abf28fb65f73c8a2913;p=erlbot.git Added botsnack functionality to the irc application --- diff --git a/irc/irc_conn.erl b/irc/irc_conn.erl index 8a062c6..f15cb8f 100644 --- a/irc/irc_conn.erl +++ b/irc/irc_conn.erl @@ -79,12 +79,27 @@ do_line(Line, State) -> {_, _, _, _, 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.