Permalink
Browse files

Fix call to on_ping and on_raw and warn if a callback is not exported

  • Loading branch information...
1 parent d1685e9 commit bb112ae4de56f6f330aa57cfc6c5f02e23d23f8e @mazenharake committed Apr 17, 2011
Showing with 6 additions and 4 deletions.
  1. +1 −1 src/eirc_example_bot.erl
  2. +5 −3 src/gen_eircbot.erl
@@ -165,7 +165,7 @@ on_raw(Cmd, Args, State) ->
{ok, State}.
handle_call({msg, To, Msg}, _From, State) ->
- eirc_cl:msg(State#botstate.cl, privmsg, To, Msg),
+ eirc:privmsg(State#botstate.cl, To, Msg),
{reply, ok, State};
handle_call(print_state, _From, State) ->
CState = eirc:state(State#botstate.cl),
View
@@ -107,7 +107,8 @@ safe_callback(Args, State) ->
[{_, on_ctcp, _}|_] ->
handle_default_ctcp(Args, State),
{noreply, State};
- [{_, Cb, _}|_] when ?MISSING_CALLBACKS ->
+ [{Mod, Cb, _}|_] when ?MISSING_CALLBACKS ->
+ error_logger:warning_report([{unexported_callback, {Mod, Cb}}]),
{noreply, State};
StackTrace ->
erlang:error(undef, StackTrace)
@@ -153,7 +154,7 @@ get_call_tuple(#ircmsg{ cmd = "TOPIC" } = IrcMsg, State) ->
[Channel|Topic] = IrcMsg#ircmsg.args,
{State, on_topic, [Nick, Channel, hd(Topic)]};
get_call_tuple(#ircmsg{ cmd = "PING" }, State) ->
- {State, on_ping, [State#st.cbstate]};
+ {State, on_ping, []};
get_call_tuple(#ircmsg{ cmd = "KICK" } = IrcMsg, State) ->
Nick = IrcMsg#ircmsg.nick,
[Channel, TargetUser, Reason|_] = IrcMsg#ircmsg.args,
@@ -218,7 +219,8 @@ callback({State, on_logon, IrcMsg}) ->
throw({stop, Reason, State#st{ cbstate = CBState }})
end;
callback({State, on_raw, IrcMsg}) ->
- case erlang:apply(State#st.cbmod, on_raw, [IrcMsg#ircmsg.cmd, State#st.cbstate]) of
+ case erlang:apply(State#st.cbmod, on_raw, [IrcMsg#ircmsg.cmd, IrcMsg#ircmsg.args,
+ State#st.cbstate]) of
{ok, CBState} ->
{noreply, State#st{ cbstate = CBState }};
{stop, Reason, CBState} ->

0 comments on commit bb112ae

Please sign in to comment.