diff options
Diffstat (limited to '')
-rw-r--r-- | lib/lsg_irc/alcolog_plugin.ex | 11 | ||||
-rw-r--r-- | lib/lsg_irc/buffer_plugin.ex | 2 | ||||
-rw-r--r-- | lib/lsg_irc/tell_plugin.ex | 2 |
3 files changed, 11 insertions, 4 deletions
diff --git a/lib/lsg_irc/alcolog_plugin.ex b/lib/lsg_irc/alcolog_plugin.ex index 1fc67f0..685b061 100644 --- a/lib/lsg_irc/alcolog_plugin.ex +++ b/lib/lsg_irc/alcolog_plugin.ex @@ -69,8 +69,9 @@ defmodule LSG.IRC.AlcoologPlugin do object = {nick, date, volumes, active, cl, deg, name, comment, meta} -> :ets.insert(ets, {{nick, date}, volumes, active, cl, deg, name, comment, meta}) dets + _ -> + dets end - dets end :dets.foldl(traverse_fun, dets, dets) state = %{dets: dets, meta: meta, ets: ets} @@ -431,7 +432,7 @@ defmodule LSG.IRC.AlcoologPlugin do for {net, chan} <- IRC.Membership.notify_channels(m.account) do user = IRC.UserTrack.find_by_account(net, m.account) nick = if(user, do: user.nick, else: m.account.name) - IRC.Connection.broadcast_message(net, chan, "#{nick}: #{msg}") + IRC.Connection.broadcast_message(net, chan, "#{nick}: #{miss}") end end end @@ -1119,7 +1120,11 @@ defmodule LSG.IRC.AlcoologPlugin do k = if meta.sex, do: 0.7, else: 0.6 weight = meta.weight peak = (10*volume)/(k*weight) - date = DateTime.from_unix!(date, :millisecond) + date = case date do + date when is_binary(date) -> DateTime.from_unix!(date, :millisecond) + date = %NaiveDateTime{} -> DateTime.from_naive!(date, "Etc/UTC") + date = %DateTime{} -> date + end last_at = last_at || date mins_since = round(DateTime.diff(now, date)/60.0) #IO.puts "Drink: #{inspect({date, volume})} - mins since: #{inspect mins_since} - last drink at #{inspect last_at}" diff --git a/lib/lsg_irc/buffer_plugin.ex b/lib/lsg_irc/buffer_plugin.ex index 8d3cacd..d278151 100644 --- a/lib/lsg_irc/buffer_plugin.ex +++ b/lib/lsg_irc/buffer_plugin.ex @@ -31,6 +31,8 @@ defmodule LSG.IRC.BufferPlugin do {:noreply, ets} end + defp ts(nil), do: ts(NaiveDateTime.utc_now()) + defp ts(naive = %NaiveDateTime{}) do ts = naive |> DateTime.from_naive!("Etc/UTC") diff --git a/lib/lsg_irc/tell_plugin.ex b/lib/lsg_irc/tell_plugin.ex index 2c9e3c8..baaa0c5 100644 --- a/lib/lsg_irc/tell_plugin.ex +++ b/lib/lsg_irc/tell_plugin.ex @@ -56,7 +56,7 @@ defmodule LSG.IRC.TellPlugin do def handle_info({:account_change, old_id, new_id}, state) do #:ets.fun2ms(fn({ {_net, _chan, target_id}, from_id, _, _} = obj) when (target_id == old_id) or (from_id == old_id) -> obj end) spec = [{{{:"$1", :"$2", :"$3"}, :"$4", :_, :_}, [{:orelse, {:==, :"$3", {:const, old_id}}, {:==, :"$4", {:const, old_id}}}], [:"$_"]}] - Util.Util.ets_mutate_select_each(:dets, state.dets, spec, fn(table, obj) -> + Util.ets_mutate_select_each(:dets, state.dets, spec, fn(table, obj) -> case obj do { {net, chan, ^old_id}, from_id, message, at } = obj -> :dets.delete(obj) |