you didn't see anything
parent
1bd4e6a6c5
commit
93fa51a9b6
|
@ -1,4 +1,4 @@
|
||||||
# CarrierPidgeon
|
# Homing Pigeon
|
||||||
|
|
||||||
Relay your discord server to irc via avian carrier.
|
Relay your discord server to irc via avian carrier.
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ you need to configure this with a dev.exs / prod.exs like such
|
||||||
```elixir
|
```elixir
|
||||||
import Config
|
import Config
|
||||||
|
|
||||||
config :discordirc,
|
config :homingpigeon,
|
||||||
channels: [
|
channels: [
|
||||||
%{ircnetwork: "net1",
|
%{ircnetwork: "net1",
|
||||||
ircchannel: "#mychannel",
|
ircchannel: "#mychannel",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Config
|
import Config
|
||||||
|
|
||||||
config :carrierpidgeon,
|
config :homingpigeon,
|
||||||
channels: [
|
channels: [
|
||||||
],
|
],
|
||||||
networks: [
|
networks: [
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
defmodule CarrierPidgeon.DiscordHandler do
|
defmodule HomingPigeon.DiscordHandler do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
discord bot
|
discord bot
|
||||||
"""
|
"""
|
||||||
use Nostrum.Consumer
|
use Nostrum.Consumer
|
||||||
alias Nostrum.Api
|
alias Nostrum.Api
|
||||||
alias CarrierPidgeon.ChannelMap
|
alias HomingPigeon.ChannelMap
|
||||||
|
|
||||||
def start_link do
|
def start_link do
|
||||||
Consumer.start_link(__MODULE__)
|
Consumer.start_link(__MODULE__)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule CarrierPidgeon.DiscordInfo do
|
defmodule HomingPigeon.DiscordInfo do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
helper functions for discord text things
|
helper functions for discord text things
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule CarrierPidgeon.WebhookService do
|
defmodule HomingPigeon.WebhookService do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
This module manages the webhooks that we output
|
This module manages the webhooks that we output
|
||||||
to discord channels with
|
to discord channels with
|
||||||
|
@ -29,7 +29,7 @@ defmodule CarrierPidgeon.WebhookService do
|
||||||
|
|
||||||
case DiscordAPI.create_webhook(
|
case DiscordAPI.create_webhook(
|
||||||
channel_id,
|
channel_id,
|
||||||
%{name: "CarrierPidgeon relay hook", avatar: avatar},
|
%{name: "HomingPigeon relay hook", avatar: avatar},
|
||||||
"irc relay hook"
|
"irc relay hook"
|
||||||
) do
|
) do
|
||||||
{:ok, hook} ->
|
{:ok, hook} ->
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
defmodule CarrierPidgeon do
|
defmodule HomingPigeon do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Entrypoint
|
Entrypoint
|
||||||
"""
|
"""
|
||||||
use Application
|
use Application
|
||||||
|
|
||||||
alias CarrierPidgeon.IrcNetworkSupervisor
|
alias HomingPigeon.IrcNetworkSupervisor
|
||||||
alias CarrierPidgeon.DiscordHandler
|
alias HomingPigeon.DiscordHandler
|
||||||
alias CarrierPidgeon.WebhookService
|
alias HomingPigeon.WebhookService
|
||||||
|
|
||||||
def start(_type, _args) do
|
def start(_type, _args) do
|
||||||
children = [
|
children = [
|
|
@ -1,10 +1,10 @@
|
||||||
defmodule CarrierPidgeon.ChannelMap do
|
defmodule HomingPigeon.ChannelMap do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
maps discord channels to irc channels
|
maps discord channels to irc channels
|
||||||
"""
|
"""
|
||||||
def discord(network, channel) do
|
def discord(network, channel) do
|
||||||
id =
|
id =
|
||||||
Application.fetch_env!(:carrierpidgeon, :channels)
|
Application.fetch_env!(:homingpigeon, :channels)
|
||||||
|> Enum.filter(&(&1.ircnetwork == network and &1.ircchannel == channel))
|
|> Enum.filter(&(&1.ircnetwork == network and &1.ircchannel == channel))
|
||||||
|> List.first()
|
|> List.first()
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ defmodule CarrierPidgeon.ChannelMap do
|
||||||
|
|
||||||
def irc(id) do
|
def irc(id) do
|
||||||
channel =
|
channel =
|
||||||
Application.fetch_env!(:carrierpidgeon, :channels)
|
Application.fetch_env!(:homingpigeon, :channels)
|
||||||
|> Enum.filter(&(&1.discordid == id))
|
|> Enum.filter(&(&1.discordid == id))
|
||||||
|> List.first()
|
|> List.first()
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ defmodule CarrierPidgeon.ChannelMap do
|
||||||
end
|
end
|
||||||
|
|
||||||
def getircchannels(network) do
|
def getircchannels(network) do
|
||||||
Application.fetch_env!(:carrierpidgeon, :channels)
|
Application.fetch_env!(:homingpigeon, :channels)
|
||||||
|> Enum.filter(&(&1.ircnetwork == network))
|
|> Enum.filter(&(&1.ircnetwork == network))
|
||||||
|> Enum.map(& &1.ircchannel)
|
|> Enum.map(& &1.ircchannel)
|
||||||
end
|
end
|
|
@ -1,8 +1,8 @@
|
||||||
defmodule CarrierPidgeon.Formatter do
|
defmodule HomingPigeon.Formatter do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Transforms messages to/from discord from/to irc
|
Transforms messages to/from discord from/to irc
|
||||||
"""
|
"""
|
||||||
alias CarrierPidgeon.DiscordInfo
|
alias HomingPigeon.DiscordInfo
|
||||||
|
|
||||||
@discordcdn "https://cdn.discordapp.com/"
|
@discordcdn "https://cdn.discordapp.com/"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
defmodule CarrierPidgeon.IRC do
|
defmodule HomingPigeon.IRC do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
IRC bot portion
|
IRC bot portion
|
||||||
"""
|
"""
|
||||||
use GenServer
|
use GenServer
|
||||||
require Logger
|
require Logger
|
||||||
import CarrierPidgeon.ByteSplit
|
import HomingPigeon.ByteSplit
|
||||||
|
|
||||||
defmodule State do
|
defmodule State do
|
||||||
defstruct server: nil,
|
defstruct server: nil,
|
||||||
|
@ -32,8 +32,8 @@ defmodule CarrierPidgeon.IRC do
|
||||||
alias ExIRC.Client
|
alias ExIRC.Client
|
||||||
alias ExIRC.SenderInfo
|
alias ExIRC.SenderInfo
|
||||||
alias ExIRC.Whois
|
alias ExIRC.Whois
|
||||||
alias CarrierPidgeon.ChannelMap
|
alias HomingPigeon.ChannelMap
|
||||||
alias CarrierPidgeon.Formatter
|
alias HomingPigeon.Formatter
|
||||||
|
|
||||||
def start_link(%{:network => network} = params) when is_map(params) do
|
def start_link(%{:network => network} = params) when is_map(params) do
|
||||||
state = %State{State.from_params(params) | :channels => ChannelMap.getircchannels(network)}
|
state = %State{State.from_params(params) | :channels => ChannelMap.getircchannels(network)}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
defmodule CarrierPidgeon.IrcNetworkSupervisor do
|
defmodule HomingPigeon.IrcNetworkSupervisor do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Supervises all of the IRC networks.
|
Supervises all of the IRC networks.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
use Supervisor
|
use Supervisor
|
||||||
|
|
||||||
alias CarrierPidgeon.IRC
|
alias HomingPigeon.IRC
|
||||||
|
|
||||||
def start_link(init_arg) do
|
def start_link(init_arg) do
|
||||||
Supervisor.start_link(__MODULE__, init_arg, name: __MODULE__)
|
Supervisor.start_link(__MODULE__, init_arg, name: __MODULE__)
|
||||||
|
@ -14,7 +14,7 @@ defmodule CarrierPidgeon.IrcNetworkSupervisor do
|
||||||
@impl true
|
@impl true
|
||||||
def init(_init_arg) do
|
def init(_init_arg) do
|
||||||
networks =
|
networks =
|
||||||
Application.get_env(:carrierpidgeon, :networks)
|
Application.get_env(:homingpigeon, :networks)
|
||||||
|> Enum.map(&%{start: {IRC, :start_link, [&1]}, id: &1.network})
|
|> Enum.map(&%{start: {IRC, :start_link, [&1]}, id: &1.network})
|
||||||
|
|
||||||
Supervisor.init(networks, strategy: :one_for_one)
|
Supervisor.init(networks, strategy: :one_for_one)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule CarrierPidgeon.ByteSplit do
|
defmodule HomingPigeon.ByteSplit do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Module that splits text by bytes, Unicode Aware.
|
Module that splits text by bytes, Unicode Aware.
|
||||||
"""
|
"""
|
||||||
|
|
6
mix.exs
6
mix.exs
|
@ -1,9 +1,9 @@
|
||||||
defmodule CarrierPidgeon.MixProject do
|
defmodule HomingPigeon.MixProject do
|
||||||
use Mix.Project
|
use Mix.Project
|
||||||
|
|
||||||
def project do
|
def project do
|
||||||
[
|
[
|
||||||
app: :carrierpidgeon,
|
app: :homingpigeon,
|
||||||
version: "0.1.0",
|
version: "0.1.0",
|
||||||
elixir: "~> 1.10",
|
elixir: "~> 1.10",
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
|
@ -15,7 +15,7 @@ defmodule CarrierPidgeon.MixProject do
|
||||||
# Run "mix help compile.app" to learn about applications.
|
# Run "mix help compile.app" to learn about applications.
|
||||||
def application do
|
def application do
|
||||||
[
|
[
|
||||||
mod: {CarrierPidgeon, []},
|
mod: {HomingPigeon, []},
|
||||||
extra_applications: [:logger]
|
extra_applications: [:logger]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
defmodule CarrierPidgeon.SplitterTest do
|
defmodule HomingPigeon.SplitterTest do
|
||||||
use ExUnit.Case
|
use ExUnit.Case
|
||||||
import CarrierPidgeon.ByteSplit
|
import HomingPigeon.ByteSplit
|
||||||
doctest CarrierPidgeon.ByteSplit
|
doctest HomingPigeon.ByteSplit
|
||||||
|
|
||||||
test "split by bytes" do
|
test "split by bytes" do
|
||||||
assert byte_split("test", 2) == ["te", "st"]
|
assert byte_split("test", 2) == ["te", "st"]
|
||||||
|
|
Loading…
Reference in New Issue