HomingPigeon/lib/discordhandler.ex

29 lines
624 B
Elixir
Raw Normal View History

2020-07-16 23:11:18 -04:00
defmodule Discordirc.DiscordHandler do
use Nostrum.Consumer
alias Nostrum.Api
alias Discordirc.ChannelMap
def start_link do
Consumer.start_link(__MODULE__)
end
def handle_event({:MESSAGE_CREATE, msg, _ws_state}) do
2020-07-17 02:35:27 -04:00
{:ok, me} = Api.get_current_user()
unless msg.author.username == me.username and msg.author.discriminator == me.discriminator do
2020-07-16 23:11:18 -04:00
case ChannelMap.irc(msg.channel_id) do
{:ok, net, _} ->
pid = String.to_atom(net)
send(pid, {:discordmsg, msg})
_ ->
:ignore
end
end
end
def handle_event(_event) do
:noop
end
end