hedwig-im / hedwig_slack Goto Github PK
View Code? Open in Web Editor NEWSlack Adapter for Hedwig
License: MIT License
Slack Adapter for Hedwig
License: MIT License
Its possible to only hear when the bot is mentioned unless in its own chat? This would only affect responders. I would be much nicer in slack to write @bot help
instead of bot help
.
If you make a new Slack app and try to use Hedwig, it won't work, you'll just get this very confusing error:
[error] GenServer #PID<0.592.0> terminating
** (MatchError) no match of right hand side value: {:error, :no_scheme}
(hedwig_slack 1.0.0) lib/hedwig_slack/connection.ex:16: HedwigSlack.Connection.start/1
(hedwig_slack 1.0.0) lib/hedwig_slack/adapter.ex:48: Hedwig.Adapters.Slack.handle_info/2
(stdlib 3.15.2) gen_server.erl:695: :gen_server.try_dispatch/4
(stdlib 3.15.2) gen_server.erl:771: :gen_server.handle_msg/6
(stdlib 3.15.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: {:EXIT, #PID<0.590.0>, {{:badmatch, {:error, :no_scheme}}, [{HedwigSlack.Connection, :start, 1, [file: 'lib/hedwig_slack/connection.ex', line: 16]}, {Hedwig.Adapters.Slack, :handle_info, 2, [file: 'lib/hedwig_slack/adapter.ex', line: 48]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 695]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 771]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 226]}]}}
State: {:state, {#PID<0.592.0>, Supervisor.Default}, :simple_one_for_one, {[Hedwig.Responder], %{Hedwig.Responder => {:child, :undefined, Hedwig.Responder, {Hedwig.Responder, :start_link, []}, :transient, false, 5000, :worker, [Hedwig.Responder]}}}, {:maps, %{#PID<0.593.0> => [Hedwig.Responders.Help, {nil, "DubzCat", [], #PID<0.590.0>}], #PID<0.594.0> => [Hedwig.Responders.Ping, {nil, "DubzCat", [], #PID<0.590.0>}], #PID<0.595.0> => [DubzCat.Responders.Meow, {nil, "DubzCat", [], #PID<0.590.0>}]}}, 3, 5, [], 0, :never, Supervisor.Default, {:ok, {%{intensity: 3, period: 5, strategy: :simple_one_for_one}, [{Hedwig.Responder, {Hedwig.Responder, :start_link, []}, :transient, 5000, :worker, [Hedwig.Responder]}]}}}
The issue is that Slack has deprecated the RTM API, in favour of the Events API - see https://api.slack.com/authentication/basics
If you use IO.inspect on the data
you get back here https://github.com/hedwig-im/hedwig_slack/blob/master/lib/hedwig_slack/adapter.ex#L45
you'll see %{"error" => "invalid_auth", "ok" => false}
I think the only way to fix this for new apps (my old app seems to still work) will be to upgrade this adapter to not use the RTM API
Using Hedwig behind a firewall does not connect to the Slack RTM api.
Issue:
When connecting, hedwig will receive a {:error, :nxdomain} message.
Requested Usage:
Add configuration options for proxy and accompanying settings.
Examples:
config :alfred,
Alfred.Robot,
adapter: Hedwig.Adapters.Slack,
name: "aflred",
aka: "/",
token: System.get_env("SLACK_API_TOKEN"),
rooms: [],
proxy: System.get_env("HTTP_PROXY"),
ssl_options: [insecure: true, ssl_options: [protocol: 'tlsv1.2']]
responders: [
{Hedwig.Responders.Help, []},
{Hedwig.Responders.Ping, []}
]
mix run --no-halt
warning: :simple_one_for_one strategy is deprecated, please use DynamicSupervisor instead
(elixir 1.10.4) lib/supervisor.ex:604: Supervisor.init/2
(elixir 1.10.4) lib/supervisor.ex:556: Supervisor.start_link/2
(alfred 0.1.0) lib/hedwig/robot.ex:89: Alfred.Robot.init/1
(stdlib 3.8) gen_server.erl:374: :gen_server.init_it/2
(stdlib 3.8) gen_server.erl:342: :gen_server.init_it/6
For example, I would like to start hearing every message after a specific message has been mentioned. I would like to continue this for the next 2 minutes and then stop listening to everything and only to fixed patterns.
Since the adapter is a genserver, it would be handy if it could respond to queries for information about users, channels, etc. that is being stored in the state object.
I attempted to include Hedwig with Slack in an umbrella which also included a Phoenix project and there are dependency conflicts:
โ omgbot mix deps.update --all
Running dependency resolution
Failed to use "cowlib" (versions 1.0.0 to 1.0.2) because
cowboy (versions 1.0.0 to 1.0.4) requires ~> 1.0.0
gun (version 1.0.0-pre.1) requires 1.3.0
Failed to use "poison" (versions 1.3.0 to 1.5.2) because
ecto (version 1.1.9) requires ~> 1.0 or ~> 2.0
hedwig_slack (version 0.1.0) requires ~> 2.0
phoenix (versions 1.1.1 and 1.1.2) requires ~> 1.3
phoenix_ecto (version 2.0.2) requires ~> 1.3 or ~> 2.0
Failed to use "ranch" (versions 1.2.0 and 1.2.1) because
cowboy (versions 1.0.0 to 1.0.4) requires ~> 1.0
gun (version 1.0.0-pre.1) requires 1.1.0
** (Mix) Hex dependency resolution failed, relax the version requirements of your dependencies or unlock them (by using mix deps.update or mix deps.unlock)
It appears that cowboy requires an older version of ranch and cowlib than gun, which is required by hedwig_slack. It also appears that the newer version of cowlib is not backwards compatible and I was unable to get it to work with cowboy. There is no more recent version of cowboy.
Not sure how I can get around this problem.
Project stays a little behind current dependencies versions.
Hi, thanks for the great project!
Is there any way to respond to user's input with slack attachments?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.