From 02a281159a5d10c66dc95cd280f11146176b2ee0 Mon Sep 17 00:00:00 2001 From: Yaroslav Zemlyanuhin Date: Thu, 1 Feb 2018 23:14:49 +0300 Subject: [PATCH] wip --- lib/agala_echo/application.ex | 21 +++++++++++++++-- lib/agala_echo/email_echo_handler.ex | 14 ++++++++++++ mix.exs | 5 ++-- mix.lock | 34 ++++++++++++++++------------ 4 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 lib/agala_echo/email_echo_handler.ex diff --git a/lib/agala_echo/application.ex b/lib/agala_echo/application.ex index e23044c..c22bebe 100644 --- a/lib/agala_echo/application.ex +++ b/lib/agala_echo/application.ex @@ -6,8 +6,10 @@ defmodule AgalaEcho.Application do # Add here as many bot instances as you want. Dont forget to name there uniqly. children = [ - supervisor(Agala.Bot, [telegram_bot_configuration()], id: :telegram), - supervisor(Agala.Bot, [vk_bot_configuration()], id: :vk) +# supervisor(Agala.Bot, [telegram_bot_configuration()], id: :telegram), +# supervisor(Agala.Bot, [vk_bot_configuration()], id: :vk) + supervisor(Agala.Bot, [email_bot_configuration()], id: :vk) + ] opts = [strategy: :one_for_one, name: AgalaEcho.Supervisor] @@ -37,4 +39,19 @@ defmodule AgalaEcho.Application do } } end + + def email_bot_configuration do + %Agala.BotParams{ + name: "agala_echo_email", + provider: Agala.Provider.Email, + handler: AgalaEcho.EmailEchoHandler, + provider_params: %{ + login: '', + password: '', + server: 'pop.yandex.ru', + port: 995, + email: '' + } + } + end end diff --git a/lib/agala_echo/email_echo_handler.ex b/lib/agala_echo/email_echo_handler.ex new file mode 100644 index 0000000..4be10ba --- /dev/null +++ b/lib/agala_echo/email_echo_handler.ex @@ -0,0 +1,14 @@ +defmodule AgalaEcho.EmailEchoHandler do + require Logger + use Agala.Chain.Builder + + chain Agala.Chain.Loopback + chain :handle + + def handle(conn, a) do + Logger.warn(fn -> "Unhandled message!" end) + Logger.warn(fn -> inspect conn end) + Logger.warn(fn -> inspect a end) + conn |> Agala.Conn.halt() + end +end diff --git a/mix.exs b/mix.exs index 203154d..3908d71 100644 --- a/mix.exs +++ b/mix.exs @@ -11,14 +11,15 @@ defmodule AgalaEcho.Mixfile do end def application do - [extra_applications: [:logger, :agala_vk, :agala_telegram], + [extra_applications: [:logger, :agala_vk, :agala_telegram, :agala_email], mod: {AgalaEcho.Application, []}] end defp deps do [ {:agala_telegram, "~> 0.1.0"}, - {:agala_vk, "~> 0.1.0"} + {:agala_vk, "~> 0.1.0"}, + {:agala_email, path: "../agala_email"} ] end end diff --git a/mix.lock b/mix.lock index 7679ffe..33b730e 100644 --- a/mix.lock +++ b/mix.lock @@ -1,15 +1,19 @@ -%{"agala": {:hex, :agala, "2.0.1", "7a74c0b8df24e52101a333501b9381bcd2da28ff4edc93e5a6c5c5ba458e4192", [], [{:excoveralls, "~> 0.7.4", [hex: :excoveralls, repo: "hexpm", optional: false]}], "hexpm"}, - "agala_telegram": {:hex, :agala_telegram, "0.1.0", "0267fbe8fecf29cad73edd9c2a2634c1c848c8a82e06e8ef93a821ec32dec914", [], [{:agala, "~> 2.0.1", [hex: :agala, repo: "hexpm", optional: false]}, {:httpoison, "~> 0.12", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, "~> 3.1", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "agala_vk": {:hex, :agala_vk, "0.1.0", "24cadb6017bfc2c17c2d9f5088c941b213cb99e9586dd1de6e925198c8baff00", [], [{:agala, "~> 2.0.1", [hex: :agala, repo: "hexpm", optional: false]}, {:httpoison, "~> 0.12", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, ">= 1.5.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [], [], "hexpm"}, - "excoveralls": {:hex, :excoveralls, "0.7.5", "339e433e5d3bce09400dc8de7b9040741a409c93917849916c136a0f51fdc183", [], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, - "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"}, - "hackney": {:hex, :hackney, "1.10.1", "c38d0ca52ea80254936a32c45bb7eb414e7a96a521b4ce76d00a69753b157f21", [], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, - "httpoison": {:hex, :httpoison, "0.13.0", "bfaf44d9f133a6599886720f3937a7699466d23bb0cd7a88b6ba011f53c6f562", [], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, - "idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, - "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [], [], "hexpm"}, - "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [], [], "hexpm"}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], [], "hexpm"}, - "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [], [], "hexpm"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [], [], "hexpm"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [], [], "hexpm"}} +%{ + "agala": {:hex, :agala, "2.0.2", "9a4706cafb4f371ceca503a60b317c33b78fc7e618676ffa5bffba7bcf931748", [:mix], [{:excoveralls, "~> 0.7.4", [hex: :excoveralls, repo: "hexpm", optional: false]}], "hexpm"}, + "agala_telegram": {:hex, :agala_telegram, "0.1.0", "0267fbe8fecf29cad73edd9c2a2634c1c848c8a82e06e8ef93a821ec32dec914", [:mix], [{:agala, "~> 2.0.1", [hex: :agala, repo: "hexpm", optional: false]}, {:httpoison, "~> 0.12", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, "~> 3.1", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, + "agala_vk": {:hex, :agala_vk, "0.1.0", "24cadb6017bfc2c17c2d9f5088c941b213cb99e9586dd1de6e925198c8baff00", [:mix], [{:agala, "~> 2.0.1", [hex: :agala, repo: "hexpm", optional: false]}, {:httpoison, "~> 0.12", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, ">= 1.5.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, + "certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"}, + "erlpop": {:git, "https://github.com/nico-amsterdam/erlpop.git", "7a2ece268f5a57b9425b2bf7520a26326932b319", []}, + "excoveralls": {:hex, :excoveralls, "0.7.5", "339e433e5d3bce09400dc8de7b9040741a409c93917849916c136a0f51fdc183", [:mix], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"}, + "hackney": {:hex, :hackney, "1.11.0", "4951ee019df102492dabba66a09e305f61919a8a183a7860236c0fde586134b6", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, + "httpoison": {:hex, :httpoison, "0.13.0", "bfaf44d9f133a6599886720f3937a7699466d23bb0cd7a88b6ba011f53c6f562", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, + "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, + "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"}, + "pop3mail": {:hex, :pop3mail, "1.3.0", "5eba88226a54572debe30667ceadd2f8e4ea104f3309fea8f74a768d71ee512c", [:mix], [], "hexpm"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}, +}