2019-01-03 11:34:31 +01:00
|
|
|
defmodule Mix.Tasks.Mobilizon.Toot do
|
|
|
|
@moduledoc """
|
2019-09-22 16:26:23 +02:00
|
|
|
Creates a bot from a source.
|
2019-01-03 11:34:31 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
use Mix.Task
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2019-09-22 18:29:13 +02:00
|
|
|
alias MobilizonWeb.API
|
|
|
|
|
2019-01-03 11:34:31 +01:00
|
|
|
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
|
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
|