master
Rachel Fae Fox 2022-11-08 00:12:53 -05:00
parent 835079d42b
commit dff5ec0bde
1 changed files with 8 additions and 5 deletions

View File

@ -70,7 +70,7 @@ defmodule Discordirc.IRC do
|> Enum.chunk_while( |> Enum.chunk_while(
[], [],
fn ele, acc -> fn ele, acc ->
if Enum.join(Enum.reverse([ele | acc]), " ") |> String.length() > 512 - pfxlen do if Enum.join(Enum.reverse([ele | acc]), " ") |> byte_size() > 512 - pfxlen do
{:cont, Enum.reverse(acc), [ele]} {:cont, Enum.reverse(acc), [ele]}
else else
{:cont, [ele | acc]} {:cont, [ele | acc]}
@ -83,7 +83,7 @@ defmodule Discordirc.IRC do
) )
|> Enum.map(fn x -> Enum.join(x, " ") end) |> Enum.map(fn x -> Enum.join(x, " ") end)
|> Enum.map(fn x -> |> Enum.map(fn x ->
case String.length(x) do case byte_size(x) do
n when is_integer(n) and n > 512 -> n when is_integer(n) and n > 512 ->
x x
|> String.to_charlist() |> String.to_charlist()
@ -99,8 +99,8 @@ defmodule Discordirc.IRC do
end end
def discord_ircsplit(msg, nick, target) do def discord_ircsplit(msg, nick, target) do
pfx = "PRIVMSG #{target} :" |> String.length() pfx = "PRIVMSG #{target} :" |> byte_size()
nkl = "<#{nick}> " |> String.length() nkl = "<#{nick}> " |> byte_size()
msg msg
|> String.split("\n") |> String.split("\n")
@ -140,13 +140,16 @@ defmodule Discordirc.IRC do
def handle_info({:discord_cmd, :kick, users}) do def handle_info({:discord_cmd, :kick, users}) do
end end
def handle_info({:discord_cmd, :ban, users}) do def handle_info({:discord_cmd, :ban, users}) do
end end
def handle_info({:discord_cmd, :mode, modestr}) do def handle_info({:discord_cmd, :mode, modestr}) do
end end
def handle_info({:discord_cmd, :topic, topic}) do def handle_info({:discord_cmd, :topic, topic}) do
end end
def handle_info({:connected, server, port}, state) do def handle_info({:connected, server, port}, state) do
Logger.debug("Connected to #{server}:#{port}") Logger.debug("Connected to #{server}:#{port}")
Logger.debug("Logging to #{server}:#{port} as #{state.nick}..") Logger.debug("Logging to #{server}:#{port} as #{state.nick}..")