hedwig-im / hedwig

An Adapter-based Bot Framework for Elixir Applications
MIT License
656 stars 73 forks source link

Hedwig 2.0 - Robot Behaviour #70

Open scrogson opened 7 years ago

scrogson commented 7 years ago

This PR starts the process to move away from issues brought up in #60 and #61.

Hedwig 2.0 will aim to provide a very ergonomic API for folks who just need a basic bot:

defmodule MyApp.Robot do
  use Hedwig.Robot, otp_app: :my_app
end

As well as more advanced OTP use-cases:

defmodule MyApp.Robot do
  use Hedwig.Robot, otp_app: :my_app

  def start_link(opts \\ []) do
    Hedwig.Robot.start_link(__MODULE__, nil, name: {:global, "my_app_robot"})
  end

  # ...
end

The API is still a work in progress...

TBD

TODO

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-17.7%) to 74.453% when pulling 6b3ae95bc05429373f968788c212cbdf2b2ea245 on robot_behaviour into 3817edb3d4513068da178794717a6a8085c72b87 on master.

keathley commented 6 years ago

This is looking good to me. Just glancing over it I don't think we allow uses to overwrite init/1 in Robot. Thats something we should probably look at so its easier to configure everything at runtime.

scrogson commented 6 years ago

@keathley are you thinking more in the realm of an init/2 callback for runtime configuration like Ecto.Repo and Phoenix.Endpoint?

If so, that's definitely something I've thought about and I think it's probably a good idea. The init/1 callback can stay private for the behaviour to take care of.

keathley commented 6 years ago

Exactly

michalmuskala commented 6 years ago

I just got around to see this PR. I'd like to ask you to consider a slightly different approach to injecting default callback implementations in __using__. In particular it is to use optional callbacks and handle defaults appropriately in the behaviour module when the callback is not defined. This also probably means injecting almost no code in use besides the @behaviour declaration and the child_spec function. This is most probably how GenServer will work in Elixir 1.8 and how GenStage works already - it might be a good reference on how to go about doing this.

johanb commented 5 years ago

Is this something that's still being worked on ? If so wouldn't mind to lend a hand, just not sure how to get started.

scrogson commented 5 years ago

@johanb thanks for your interest in helping!

I do intend to finish this PR someday soon 😄

I'll probably pick this back up next month.

fire commented 5 years ago

This still seems useful to be worked on.

mhsdef commented 1 year ago

@scrogson what are you thinking on this PR and about Hedwig, generally, these days?

I'm considering putting in some grunt work in your lil' ecosystem (eg, wip, and potentially toss some PRs your way here in this repo); I don't want to be spinning wheels though if Hedwig itself is on its way to mothballed.

scrogson commented 1 year ago

@defmhs hey there 👋

Unfortunately, my work in the last 5+ years has lead me away from working on chat related things, so I haven't had time/energy to maintain this project.

That said, if you're interested in helping push this project forward, feel free to send some PRs, I'll try my best to respond.