Created
June 12, 2011 15:51
-
-
Save wrboyce/1021692 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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