debianize-mobilizon/lib/mix/tasks/mobilizon/toot.ex
2019-09-26 17:45:47 +02:00

28 lines
535 B
Elixir

defmodule Mix.Tasks.Mobilizon.Toot do
@moduledoc """
Creates a bot from a source.
"""
use Mix.Task
alias MobilizonWeb.API
require Logger
@shortdoc "Toot to an user"
def run([from, content]) do
Mix.Task.run("app.start")
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