summaryrefslogtreecommitdiff
path: root/lib/lsg_irc/preums_plugin.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2021-09-01 12:30:41 +0200
committerhref <href@random.sh>2021-09-01 12:30:41 +0200
commit6e68d8d53c28ee6007ca226db47c2b73eb7536c9 (patch)
tree685b5e7792bc97ce401bbd3bd173be3c14aada7a /lib/lsg_irc/preums_plugin.ex
parentSmall readme update + Admin cli (diff)
preums: remove migration code
Diffstat (limited to '')
-rw-r--r--lib/lsg_irc/preums_plugin.ex33
1 files changed, 2 insertions, 31 deletions
diff --git a/lib/lsg_irc/preums_plugin.ex b/lib/lsg_irc/preums_plugin.ex
index 7bb2c78..31615e6 100644
--- a/lib/lsg_irc/preums_plugin.ex
+++ b/lib/lsg_irc/preums_plugin.ex
@@ -89,35 +89,6 @@ defmodule LSG.IRC.PreumsPlugin do
{:ok, _} = Registry.register(IRC.PubSub, "account", regopts)
{:ok, _} = Registry.register(IRC.PubSub, "message", regopts)
{:ok, _} = Registry.register(IRC.PubSub, "triggers", regopts)
- {:ok, dets} = :dets.open_file(dets(), [{:repair, :force}])
- Util.ets_mutate_select_each(:dets, dets, [{:"$1", [], [:"$1"]}], fn(table, obj) ->
- {key, nick, now, perfect, text} = obj
- case key do
- {{net, {bork,chan}}, date} ->
- :dets.delete(table, key)
- nick = if IRC.Account.get(nick) do
- nick
- else
- if acct = IRC.Account.find_always_by_nick(net, nil, nick) do
- acct.id
- else
- nick
- end
- end
- :dets.insert(table, { { {net,chan}, date }, nick, now, perfect, text})
- {{_net, nil}, _} ->
- :dets.delete(table, key)
- {{net, chan}, date} ->
- if !IRC.Account.get(nick) do
- if acct = IRC.Account.find_always_by_nick(net, chan, nick) do
- :dets.delete(table, key)
- :dets.insert(table, { { {net,chan}, date }, acct.id, now, perfect, text})
- end
- end
- _ ->
- Logger.debug("DID NOT FIX: #{inspect key}")
- end
- end)
{:ok, %{dets: dets}}
end
@@ -155,11 +126,11 @@ defmodule LSG.IRC.PreumsPlugin do
channel = {m.network, m.channel}
state = handle_preums(m, state)
top = topnicks(state.dets, channel, sort_by: :score)
- |> Enum.map(fn({account_id, {count, score}}) ->
+ |> Enum.map(fn({account_id, {count, _score}}) ->
account = IRC.Account.get(account_id)
user = IRC.UserTrack.find_by_account(m.network, account)
nick = if(user, do: user.nick, else: account.name)
- "#{nick}: #{score} (#{count})"
+ "#{nick}: #{count}"
end)
|> Enum.intersperse(", ")
|> Enum.join("")