summaryrefslogtreecommitdiff
path: root/lib/lsg_telegram
diff options
context:
space:
mode:
authorJordan Bracco <href@random.sh>2022-12-17 13:47:11 +0000
committerJordan Bracco <href@random.sh>2022-12-20 19:29:41 +0100
commitfd4afd7c7acd9b5fda75b628a7e19d0149d8b889 (patch)
treedf571d49fa9dc9c3cd58c94033b9fc81c7b7f8ec /lib/lsg_telegram
parentRename to Nola, pt. 1. Refs T77 (diff)
Nola rename cont. pt. 2. Refs T77.
`find lib -name "*.ex" -type f | xargs sed -i '' 's/LSG/Nola/g'`
Diffstat (limited to '')
-rw-r--r--lib/lsg_telegram/room.ex10
-rw-r--r--lib/lsg_telegram/telegram.ex14
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/lsg_telegram/room.ex b/lib/lsg_telegram/room.ex
index 4e86382..794cca3 100644
--- a/lib/lsg_telegram/room.ex
+++ b/lib/lsg_telegram/room.ex
@@ -1,4 +1,4 @@
-defmodule LSG.TelegramRoom do
+defmodule Nola.TelegramRoom do
require Logger
@behaviour Telegram.ChatBot
alias Telegram.Api
@@ -32,7 +32,7 @@ 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(Nola.Telegram, Integer.parse(id) |> elem(0))
end
@impl Telegram.ChatBot
@@ -125,7 +125,7 @@ defmodule LSG.TelegramRoom do
if Map.get(message.meta, :from) == self() do
else
body = if Map.get(message.meta, :self), do: text, else: "<#{nick}> #{text}"
- LSG.Telegram.send_message(state.id, body)
+ Nola.Telegram.send_message(state.id, body)
end
{:ok, state}
end
@@ -163,14 +163,14 @@ defmodule LSG.TelegramRoom do
path = "https://api.telegram.org/file/bot#{token}/#{file["file_path"]}",
{:ok, %HTTPoison.Response{status_code: 200, body: body}} <- HTTPoison.get(path),
<<smol_body::binary-size(20), _::binary>> = body,
- {:ok, magic} <- GenMagic.Pool.perform(LSG.GenMagic, {:bytes, smol_body}),
+ {:ok, magic} <- GenMagic.Pool.perform(Nola.GenMagic, {:bytes, smol_body}),
bucket = Application.get_env(:lsg, :s3, []) |> Keyword.get(:bucket),
ext = Path.extname(file["file_path"]),
s3path = "#{account.id}/#{file_unique_id}#{ext}",
s3req = ExAws.S3.put_object(bucket, s3path, body, acl: :public_read, content_type: magic.mime_type),
{:ok, _} <- ExAws.request(s3req)
do
- path = LSGWeb.Router.Helpers.url(LSGWeb.Endpoint) <> "/files/#{s3path}"
+ path = NolaWeb.Router.Helpers.url(NolaWeb.Endpoint) <> "/files/#{s3path}"
txt = "#{type}: #{text}#{path}"
connection = IRC.Connection.get_network(state.net)
IRC.send_message_as(account, state.net, state.chan, txt, true)
diff --git a/lib/lsg_telegram/telegram.ex b/lib/lsg_telegram/telegram.ex
index 748a456..ef5c3b8 100644
--- a/lib/lsg_telegram/telegram.ex
+++ b/lib/lsg_telegram/telegram.ex
@@ -1,4 +1,4 @@
-defmodule LSG.Telegram do
+defmodule Nola.Telegram do
require Logger
@behaviour Telegram.ChatBot
@@ -9,13 +9,13 @@ defmodule LSG.Telegram do
def send_message(id, text, md2 \\ false) do
md = if md2, do: "MarkdownV2", else: "Markdown"
token = Keyword.get(Application.get_env(:lsg, :telegram, []), :key)
- Telegram.Bot.ChatBot.Chat.Session.Supervisor.start_child(LSG.Telegram, id)
+ Telegram.Bot.ChatBot.Chat.Session.Supervisor.start_child(Nola.Telegram, id)
Telegram.Api.request(token, "sendMessage", chat_id: id, text: text, parse_mode: "Markdown")
end
@impl Telegram.ChatBot
def init(chat_id) when chat_id < 0 do
- {:ok, state} = LSG.TelegramRoom.init(chat_id)
+ {:ok, state} = Nola.TelegramRoom.init(chat_id)
{:ok, %{room_state: state}}
end
def init(chat_id) do
@@ -27,7 +27,7 @@ defmodule LSG.Telegram do
@impl Telegram.ChatBot
def handle_update(update, token, %{room_state: room_state}) do
- {:ok, room_state} = LSG.TelegramRoom.handle_update(update, token, room_state)
+ {:ok, room_state} = Nola.TelegramRoom.handle_update(update, token, room_state)
{:ok, %{room_state: room_state}}
end
@@ -134,7 +134,7 @@ defmodule LSG.Telegram do
path = "https://api.telegram.org/file/bot#{t}/#{file["file_path"]}",
{:ok, %HTTPoison.Response{status_code: 200, body: body}} <- HTTPoison.get(path),
<<smol_body::binary-size(20), _::binary>> = body,
- {:ok, magic} <- GenMagic.Pool.perform(LSG.GenMagic, {:bytes, smol_body}),
+ {:ok, magic} <- GenMagic.Pool.perform(Nola.GenMagic, {:bytes, smol_body}),
bucket = Application.get_env(:lsg, :s3, []) |> Keyword.get(:bucket),
ext = Path.extname(file["file_path"]),
s3path = "#{account.id}/#{file_unique_id}#{ext}",
@@ -142,7 +142,7 @@ defmodule LSG.Telegram do
s3req = ExAws.S3.put_object(bucket, s3path, body, acl: :public_read, content_type: magic.mime_type),
{:ok, _} <- ExAws.request(s3req)
do
- path = LSGWeb.Router.Helpers.url(LSGWeb.Endpoint) <> "/files/#{s3path}"
+ path = NolaWeb.Router.Helpers.url(NolaWeb.Endpoint) <> "/files/#{s3path}"
sent = for {net, chan} <- target do
txt = "sent#{type}#{text} #{path}"
IRC.send_message_as(account, net, chan, txt)
@@ -176,7 +176,7 @@ defmodule LSG.Telegram do
@impl Telegram.ChatBot
def handle_info(info, %{room_state: room_state}) do
- {:ok, room_state} = LSG.TelegramRoom.handle_info(info, room_state)
+ {:ok, room_state} = Nola.TelegramRoom.handle_info(info, room_state)
{:ok, %{room_state: room_state}}
end