mobilizon.chapril.org-mobil.../lib/mix/tasks/mobilizon/toot.ex

28 lines
535 B
Elixir
Raw Normal View History

defmodule Mix.Tasks.Mobilizon.Toot do
@moduledoc """
2019-09-22 16:26:23 +02:00
Creates a bot from a source.
"""
use Mix.Task
2019-09-22 16:26:23 +02:00
2019-09-22 18:29:13 +02:00
alias MobilizonWeb.API
require Logger
@shortdoc "Toot to an user"
def run([from, content]) do
Mix.Task.run("app.start")
2019-09-22 18:29:13 +02:00
case API.Comments.create_comment(from, content) do
{:ok, _, _} ->
Mix.shell().info("Tooted")
{:local_actor, _, _} ->
Mix.shell().error("Failed to toot.\nActor #{from} doesn't exist")
_ ->
Mix.shell().error("Failed to toot.")
end
end
end