anchor.diff:      serversend(State, #irc_cmd{name=nomotd}), % XXX probably need to ask parent server for a MOTD
       {next_state, connected, State}.
   
  -connected({irc, _, C = #irc_cmd{name=quit}}, State) ->
  -    serversend(State, C#irc_cmd{name=error}),
  +connected({irc, _, #irc_cmd{name=quit}}, State) ->
       {stop, normal, State};
   connected({irc, _, #irc_cmd{name=ping}}, State = #state{irc_server=S}) ->
       serversend(State, #irc_cmd{name=pong, args=[{servers, {S#irc_server.host, S#irc_server.net}}]}),
  +    {next_state, connected, State};
  +connected({irc, _, #irc_cmd{name=join,args=[{channels, Chans}]}}, State) ->
  +    join(Chans, State);
  +connected({irc, _, #irc_cmd{name=invalid_cmd}}, State) ->
  +    serversend(State, #irc_cmd{name=error, args=[{message, "Invalid command"}]}),
       {next_state, connected, State};
   connected({irc, _, #irc_cmd{name=Cmd}} = Event, State) ->
       ?INFO("Got ~p in state connected.", [Event]),
  
positive.code: %%% Internal functions
  %%--------------------------------------------------------------------
  
  numreply(Where, Numeric, Message) when is_atom(Numeric) ->
      csend(Where, #irc_cmd{name=Numeric, args=[{message, Message}]}).
  
  
negative.code: 
  serverpid(S = #state{}) -> serverpid(server(S));
  serverpid(#irc_server{pid=P}) -> P.
  
  nick(#state{user=U}) -> nick(U);
  nick(#user{nick=N}) -> nick(N);
  nick(N) when is_list(N) -> N.
  