summaryrefslogtreecommitdiff
path: root/lib/lsg_irc/alcolog_plugin.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2021-09-07 08:14:46 +0200
committerhref <href@random.sh>2021-09-07 08:14:46 +0200
commit4b87c93fd13cda5f80720058e979b722028f940c (patch)
treeb7046da7006482a02352fcc317dfa439127b5dde /lib/lsg_irc/alcolog_plugin.ex
parentlive fixes/improvements (diff)
various fixes
Diffstat (limited to 'lib/lsg_irc/alcolog_plugin.ex')
-rw-r--r--lib/lsg_irc/alcolog_plugin.ex11
1 files changed, 8 insertions, 3 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}"