hedwig-im / hedwig

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

Responders can set bot identity via module attributes #62

Closed rjanja closed 7 years ago

rjanja commented 7 years ago

First go at implementing bot identities in responders. Responders can define @bot_name, @bot_emoji, @bot_thumbnail attributes that will be used with their messages when doing a send or emote (but not reply). The name must be overridden for this to take effect.

Identity is used (name only) in the console adapter.

Additionally, bot_identity/2 can be overridden by the individual responder to allow for custom behavior. See labzero/hedwig_simple_responders@6ff56081cf6a82e1f3e7e77c1dcc1c058968c572 for an example of this.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 91.795% when pulling b27f67c68d1d645d1163a89b2e0a3e75979ba45c on labzero:master into a385e12e3d2f88d8d09cefe086562e947184688f on hedwig-im:master.

scrogson commented 7 years ago

Hello @rjanja,

First off, thank you for your interest in helping to improve Hedwig! It is much appreciated.

This PR has a couple issues that I'll outline here.

Since module attributes are baked in at compile-time, if you're running multiple bots, and each are configured to use those responders, it won't work as intended.

This is a problem with one of the main goals of Hedwig (allows many bots to be running at a time).

The second issue is that things like emoji and thumbnail don't necessarily translate well to all different chat services (Slack, XMPP, IRC, etc.).

I would prefer to build a different abstraction for this. I have some things in mind, but I haven't started working on them yet. I am currently reworking the Hedwig.Robot so that it is a proper OTP behaviour and will allow greater flexibility for users.

Those changes are coming in 2.0 (no target date yet, but I have started work on that).

In the future, please feel free to create an issue to start a discussion.