avoid redoing webhooks
parent
a29fe329c2
commit
fd7908d432
|
@ -7,10 +7,28 @@ defmodule Discordirc.DiscordHandler do
|
|||
Consumer.start_link(__MODULE__)
|
||||
end
|
||||
|
||||
|
||||
def is_me_or_my_webhook(msg) do
|
||||
{:ok, me} = api.get_current_user()
|
||||
|
||||
is_me = msg.author.username == me.username and msg.author.discriminator == me.discriminator
|
||||
is_webhook = msg.webhook_id != nil
|
||||
|
||||
is_my_webhook =
|
||||
if is_webhook do
|
||||
{:ok, wh} = api.get_webhook(msg.webhook_id)
|
||||
wh.user.id == nostrum.snowflake.dump(me.id)
|
||||
else
|
||||
false
|
||||
end
|
||||
|
||||
is_me or is_my_webhook
|
||||
end
|
||||
|
||||
def handle_event({:MESSAGE_CREATE, msg, _ws_state}) do
|
||||
{:ok, me} = Api.get_current_user()
|
||||
|
||||
unless msg.author.username == me.username and msg.author.discriminator == me.discriminator do
|
||||
unless is_me_or_my_webhook(msg) do
|
||||
case ChannelMap.irc(msg.channel_id) do
|
||||
{:ok, net, _} ->
|
||||
pid = String.to_atom(net)
|
||||
|
|
Loading…
Reference in New Issue