diff options
Diffstat (limited to 'lib/plugins/account.ex')
-rw-r--r-- | lib/plugins/account.ex | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/plugins/account.ex b/lib/plugins/account.ex index 245710a..747fbc7 100644 --- a/lib/plugins/account.ex +++ b/lib/plugins/account.ex @@ -40,7 +40,7 @@ defmodule Nola.Plugins.Account do def handle_info({:irc, :text, m = %IRC.Message{account: account, text: "auth"}}, state) do spec = [{{:"$1", :"$2"}, [{:==, :"$2", {:const, account.id}}], [:"$1"]}] - predicates = :dets.select(IRC.Account.file("predicates"), spec) + predicates = :dets.select(Nola.Account.file("predicates"), spec) text = for {net, {key, value}} <- predicates, do: "#{net}: #{to_string(key)}: #{value}" m.replyfun.(text) {:noreply, state} @@ -57,7 +57,7 @@ defmodule Nola.Plugins.Account do end def handle_info({:irc, :text, m = %IRC.Message{account: account, text: "account"}}, state) do - account = IRC.Account.lookup(m.sender) + account = Nola.Account.lookup(m.sender) text = ["Account Id: #{account.id}", "Authenticate to this account from another network: \"auth #{account.id} #{account.token}\" to the other bot!"] m.replyfun.(text) @@ -65,7 +65,7 @@ defmodule Nola.Plugins.Account do end def handle_info({:irc, :text, m = %IRC.Message{sender: sender, text: "auth"<>_}}, state) do - #account = IRC.Account.lookup(m.sender) + #account = Nola.Account.lookup(m.sender) case String.split(m.text, " ") do ["auth", id, token] -> join_account(m, id, token) @@ -76,14 +76,14 @@ defmodule Nola.Plugins.Account do end def handle_info({:irc, :text, m = %IRC.Message{account: account, text: "set-name "<>name}}, state) do - IRC.Account.update_account_name(account, name) + Nola.Account.update_account_name(account, name) m.replyfun.("Name changed: #{name}") {:noreply, state} end def handle_info({:irc, :text, m = %IRC.Message{text: "disable-sms"}}, state) do - if IRC.Account.get_meta(m.account, "sms-number") do - IRC.Account.delete_meta(m.account, "sms-number") + if Nola.Account.get_meta(m.account, "sms-number") do + Nola.Account.delete_meta(m.account, "sms-number") m.replfyun.("SMS disabled.") else m.replyfun.("SMS already disabled.") @@ -100,8 +100,8 @@ defmodule Nola.Plugins.Account do def handle_info({:irc, :text, m = %IRC.Message{text: "enable-sms"}}, state) do code = String.downcase(EntropyString.small_id()) - IRC.Account.put_meta(m.account, "sms-validation-code", code) - IRC.Account.put_meta(m.account, "sms-validation-target", m.network) + Nola.Account.put_meta(m.account, "sms-validation-code", code) + Nola.Account.put_meta(m.account, "sms-validation-target", m.network) number = Nola.IRC.Sms.my_number() text = "To enable or change your number for SMS messaging, please send:" <> " \"enable #{code}\" to #{number}" @@ -111,9 +111,9 @@ defmodule Nola.Plugins.Account do def handle_info({:irc, :text, m = %IRC.Message{text: "enable-telegram"}}, state) do code = String.downcase(EntropyString.small_id()) - IRC.Account.delete_meta(m.account, "telegram-id") - IRC.Account.put_meta(m.account, "telegram-validation-code", code) - IRC.Account.put_meta(m.account, "telegram-validation-target", m.network) + Nola.Account.delete_meta(m.account, "telegram-id") + Nola.Account.put_meta(m.account, "telegram-validation-code", code) + Nola.Account.put_meta(m.account, "telegram-validation-target", m.network) text = "To enable or change your number for telegram messaging, please open #{Nola.Telegram.my_path()} and send:" <> " \"/enable #{code}\"" m.replyfun.(text) @@ -130,14 +130,14 @@ defmodule Nola.Plugins.Account do def handle_info({:irc, :text, m = %IRC.Message{text: "getmeta"<>_}}, state) do result = case String.split(m.text, " ") do ["getmeta"] -> - for {k, v} <- IRC.Account.get_all_meta(m.account) do + for {k, v} <- Nola.Account.get_all_meta(m.account) do case k do "u:"<>key -> "(user) #{key}: #{v}" key -> "#{key}: #{v}" end end ["getmeta", key] -> - value = IRC.Account.get_meta(m.account, key) + value = Nola.Account.get_meta(m.account, key) text = if value do "#{key}: #{value}" else @@ -153,7 +153,7 @@ defmodule Nola.Plugins.Account do def handle_info({:irc, :text, m = %IRC.Message{text: "setusermeta"<>_}}, state) do result = case String.split(m.text, " ") do ["setusermeta", key, value] -> - IRC.Account.put_user_meta(m.account, key, value) + Nola.Account.put_user_meta(m.account, key, value) "ok" _ -> "usage: setusermeta <key> <value>" @@ -167,10 +167,10 @@ defmodule Nola.Plugins.Account do end defp join_account(m, id, token) do - old_account = IRC.Account.lookup(m.sender) - new_account = IRC.Account.get(id) + old_account = Nola.Account.lookup(m.sender) + new_account = Nola.Account.get(id) if new_account && token == new_account.token do - case IRC.Account.merge_account(old_account.id, new_account.id) do + case Nola.Account.merge_account(old_account.id, new_account.id) do :ok -> if old_account.id == new_account.id do m.replyfun.("Already authenticated, but hello") |