Skip to content

Instantly share code, notes, and snippets.

@wrboyce
Created June 12, 2011 15:51
Show Gist options
  • Select an option

  • Save wrboyce/1021692 to your computer and use it in GitHub Desktop.

Select an option

Save wrboyce/1021692 to your computer and use it in GitHub Desktop.
Response = io_lib:format("~s: ", [Nick]) ++
case ets:lookup(State#state.db, SeenKey) of
[{SeenKey, SeenData}] ->
{SeenAgeDays, {SeenAgeHours,SeenAgeMinutes,SeenAgeSeconds}} = calendar:time_difference(SeenData#data.datetime, calendar:universal_time()),
io_lib:format("~s was last seen", [SeenNick]) ++
string:join("", lists:map(fun({V,L}) ->
case V of
0 ->
"";
_ ->
io_lib:format(" ~p ~s", [V, L])
end
end, [{SeenAgeDays, "days"}, {SeenAgeHours, "hours"}, {SeenAgeMinutes, "minutes"}])) ++ io_lib:format(" ~p seconds ago", [SeenAgeSeconds]);
[] ->
io_lib:format("I haven't seen ~s", [SeenNick])
end,
ok = gen_server:cast({global, erb_dispatcher}, {privmsg, Data#data.destination, Response});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment