summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Bracco <href@random.sh>2022-12-11 19:07:09 +0000
committerJordan Bracco <href@random.sh>2022-12-11 19:07:09 +0000
commitbc3d5b7f4f54d88a2ebf1cadbcd7e2816f07deaa (patch)
treee4880c66b7a2c79de59fd24107c498ba3b0e518b
parentfeat(telegram): create account for telegram user (diff)
Fix the fixes.
Diffstat (limited to '')
-rw-r--r--lib/irc/account.ex2
-rw-r--r--lib/irc/connection.ex2
-rw-r--r--lib/lsg_irc/base_plugin.ex4
-rw-r--r--lib/lsg_telegram/room.ex6
-rw-r--r--lib/util.ex2
-rw-r--r--mix.exs5
6 files changed, 11 insertions, 10 deletions
diff --git a/lib/irc/account.ex b/lib/irc/account.ex
index beb8daa..46c7f6e 100644
--- a/lib/irc/account.ex
+++ b/lib/irc/account.ex
@@ -242,7 +242,7 @@ defmodule IRC.Account do
get(id)
end
- defp new_account(%{nick: nick, network: server}) do
+ def new_account(%{nick: nick, network: server}) do
id = EntropyString.large_id()
:dets.insert(file("db"), {id, nick, EntropyString.token()})
:dets.insert(file("predicates"), {{server, {:nick, nick}}, id})
diff --git a/lib/irc/connection.ex b/lib/irc/connection.ex
index 1e94003..9382714 100644
--- a/lib/irc/connection.ex
+++ b/lib/irc/connection.ex
@@ -311,7 +311,7 @@ defmodule IRC.Connection do
def handle_info({:received, text, sender}, state) do
reply_fun = fn(text) -> irc_reply(state, {sender.nick, sender}, text) end
account = IRC.Account.lookup(sender)
- message = %IRC.Message{id: FlakeId.get(), transport: irc, text: text, network: state.network, at: NaiveDateTime.utc_now(),
+ message = %IRC.Message{id: FlakeId.get(), transport: :irc, text: text, network: state.network, at: NaiveDateTime.utc_now(),
account: account, sender: sender, replyfun: reply_fun, trigger: extract_trigger(text)}
message = case IRC.UserTrack.messaged(message) do
:ok -> message
diff --git a/lib/lsg_irc/base_plugin.ex b/lib/lsg_irc/base_plugin.ex
index ca2e8f3..7153c70 100644
--- a/lib/lsg_irc/base_plugin.ex
+++ b/lib/lsg_irc/base_plugin.ex
@@ -116,8 +116,8 @@ defmodule LSG.IRC.BasePlugin do
otp_ver = :erlang.system_info(:system_version) |> to_string() |> String.trim()
system = :erlang.system_info(:system_architecture) |> to_string()
message.replyfun.([
- <<"🤖 I am a robot running", 2, "beautte, version #{ver}", 2, " — source: #{LSG.source_url()},
- "🦾 Elixir #{elixir_ver} #{otp_ver} on #{system}"
+ <<"🤖 I am a robot running", 2, "beautte, version #{ver}", 2, " — source: #{LSG.source_url()}">>,
+ "🦾 Elixir #{elixir_ver} #{otp_ver} on #{system}",
"👷‍♀️ Owner: href <href@random.sh>",
"🌍 Web interface: #{url}"
])
diff --git a/lib/lsg_telegram/room.ex b/lib/lsg_telegram/room.ex
index da774c8..4e86382 100644
--- a/lib/lsg_telegram/room.ex
+++ b/lib/lsg_telegram/room.ex
@@ -32,11 +32,13 @@ defmodule LSG.TelegramRoom do
end
def after_start() do
- for id <- room_ids(), do: Telegram.Bot.ChatBot.Chat.Session.Supervisor.start_child(LSG.Telegram, Integer.parse(id) |> elem(0))
+ for id <- room(:ids), do: Telegram.Bot.ChatBot.Chat.Session.Supervisor.start_child(LSG.Telegram, Integer.parse(id) |> elem(0))
end
@impl Telegram.ChatBot
def init(id) when is_integer(id) and id < 0 do
+ token = Keyword.get(Application.get_env(:lsg, :telegram, []), :key)
+ {:ok, chat} = Api.request(token, "getChat", chat_id: id)
Logger.metadata(transport: :telegram, id: id, telegram_room_id: id)
tg_room = case room(id) do
{:ok, tg_room = %{"network" => _net, "channel" => _chan}} -> tg_room
@@ -50,10 +52,8 @@ defmodule LSG.TelegramRoom do
{:ok, tg_room} = room(id)
tg_room
end
- token = Keyword.get(Application.get_env(:lsg, :telegram, []), :key)
%{"network" => net, "channel" => chan} = tg_room
Logger.info("Starting ChatBot for room #{id} \"#{chat["title"]}\" #{inspect tg_room}")
- {:ok, chat} = Api.request(token, "getChat", chat_id: id)
irc_plumbed = if net && chan do
{:ok, _} = Registry.register(IRC.PubSub, "#{net}/#{chan}:messages", plugin: __MODULE__)
{:ok, _} = Registry.register(IRC.PubSub, "#{net}/#{chan}:triggers", plugin: __MODULE__)
diff --git a/lib/util.ex b/lib/util.ex
index ce46174..8bd3b9d 100644
--- a/lib/util.ex
+++ b/lib/util.ex
@@ -11,7 +11,7 @@ defmodule Util do
def to_date_time(naive_or_timestamp, timezone \\ "Europe/Paris")
def to_date_time(date = %DateTime{}, timezone) do
- DateTime.shift_zone!(data, timezone, Tzdata.TimeZoneDatabase)
+ DateTime.shift_zone!(date, timezone, Tzdata.TimeZoneDatabase)
end
def to_date_time(naive = %NaiveDateTime{}, timezone) do
diff --git a/mix.exs b/mix.exs
index 05dd026..c9f2827 100644
--- a/mix.exs
+++ b/mix.exs
@@ -89,9 +89,10 @@ defmodule LSG.Mixfile do
Mix.env() == :prod -> ""
true -> "." <> to_string(Mix.env())
end
- build_date_tag = Timex.format!(DateTime.utc_now(), ".build%y%m%d@%H%M", :strftime)
+ #build_date_tag = Timex.format!(DateTime.utc_now(), ".build%y%m%d@%H%M", :strftime)
+ build_date_tag = ".build"
- v <> "+" <> info <> env <> <> build_date_tag
+ v <> "+" <> info <> env <> build_date_tag
end
end