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