discord message attachments.
parent
37feac6295
commit
65dad89f5e
|
@ -117,14 +117,35 @@ defmodule Discordirc.Formatter do
|
|||
end
|
||||
end
|
||||
|
||||
def from_discord(user, msg) do
|
||||
usr = "#{user.username}\##{user.discriminator}"
|
||||
def format_member_nick(msg) do
|
||||
user = msg.author
|
||||
{:ok, member} = DiscordAPI.get_guild_member(msg.guild_id, user.id())
|
||||
|
||||
messages =
|
||||
msg
|
||||
if is_binary(member.nick) do
|
||||
member.nick
|
||||
else
|
||||
"#{user.username}\##{user.discriminator}"
|
||||
end
|
||||
end
|
||||
|
||||
def from_discord(msg) do
|
||||
content = msg.content
|
||||
attachments = msg.attachments
|
||||
usr = format_member_nick(msg)
|
||||
|
||||
cpart =
|
||||
content
|
||||
|> String.split("\n")
|
||||
|> Enum.map(&fixdiscordidstrings(&1))
|
||||
|
||||
apart =
|
||||
attachments
|
||||
|> Enum.map(& &1.url)
|
||||
|
||||
messages =
|
||||
(cpart ++ apart)
|
||||
|> Enum.filter(&(&1 != ""))
|
||||
|
||||
# discord may give... many lines. split and format.
|
||||
case Enum.count(messages) do
|
||||
0 ->
|
||||
|
|
|
@ -67,7 +67,7 @@ defmodule Discordirc.IRC do
|
|||
|
||||
def handle_info({:discordmsg, msg}, state) do
|
||||
channel = ChannelMap.irc(msg.channel_id)
|
||||
response = Formatter.from_discord(msg.author, msg.content)
|
||||
response = Formatter.from_discord(msg)
|
||||
|
||||
case channel do
|
||||
{:ok, _, chan} ->
|
||||
|
|
Loading…
Reference in New Issue