summaryrefslogtreecommitdiff
path: root/lib/lsg_irc/txt_handler.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lsg_irc/txt_handler.ex')
-rw-r--r--lib/lsg_irc/txt_handler.ex14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/lsg_irc/txt_handler.ex b/lib/lsg_irc/txt_handler.ex
index efe2b68..032c11c 100644
--- a/lib/lsg_irc/txt_handler.ex
+++ b/lib/lsg_irc/txt_handler.ex
@@ -1,5 +1,5 @@
defmodule LSG.IRC.TxtHandler do
- alias LSG.IRC.UserTrack
+ alias IRC.UserTrack
require Logger
@moduledoc """
@@ -213,6 +213,14 @@ defmodule LSG.IRC.TxtHandler do
{:noreply, state}
end
+ def terminate(_reason, state) do
+ if state.locks do
+ :dets.sync(state.locks)
+ :dets.close(state.locks)
+ end
+ :ok
+ end
+
# Load/Reloads text files from disk
defp load() do
triggers = Path.wildcard(directory() <> "/*.txt")
@@ -331,8 +339,8 @@ defmodule LSG.IRC.TxtHandler do
end
defp can_write?(state = %__MODULE__{rw: rw?, locks: locks}, channel, sender, trigger) do
- admin? = LSG.IRC.admin?(sender)
- operator? = LSG.IRC.UserTrack.operator?(channel, sender.nick)
+ admin? = IRC.admin?(sender)
+ operator? = IRC.UserTrack.operator?(channel, sender.nick)
locked? = case :dets.lookup(locks, trigger) do
[{trigger}] -> true
_ -> false