brainiac-discord 0.0.23 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b8cac77bcff754559623d7dc4b787a4fb405c8e34924b59fcd24a9d3db58d70
4
- data.tar.gz: 027f50b17e55e46aa58c7305e62834b953054515c77da6a803ece5f90b5c3d35
3
+ metadata.gz: 7111ffc72dd19a6df6442ba8634e288c5085f06d696d51941a9fe64f9223a7db
4
+ data.tar.gz: 6748908008c71f05cdf84eff403bfdeee5ef30bc950acb327de7e5556bbdfc3d
5
5
  SHA512:
6
- metadata.gz: 80215591d21d89f226ae08f7c1ef246a7730bb36b9e71592f3b5ad06fdeee750c3e68508b8fd25071fb450754401946b614e8b28b9665660b8bf16f1b6a4a5c5
7
- data.tar.gz: 543f0b0d398e220b8e9927b0638a2e67780f6bdf48375456d13a741faed14bc4bc2b51ac95a6fce3a2f2c85f846591b4c08381d0579d2b567a43a0860849d279
6
+ metadata.gz: a01f1a444b3714dce15727b9c6572295f20b77d1891abaac462da1ee49ebcc3cefedcf44a7e18d00e2eeb339c0a3c70d3513a481a4c8524751aa91d3d7fc59f1
7
+ data.tar.gz: 72e2b469f446a22464134230c5d16a0c7d2d4ea3fee06adb450e795441b4061f87e9f0346ef8be50be573e9f355f6a15857e944ccc5469f3a40d337644f8fa71
@@ -3,7 +3,7 @@
3
3
  module Brainiac
4
4
  module Plugins
5
5
  module Discord
6
- VERSION = "0.0.23"
6
+ VERSION = "0.0.24"
7
7
  end
8
8
  end
9
9
  end
@@ -65,6 +65,21 @@ module Brainiac
65
65
  end
66
66
  end
67
67
 
68
+ # `agent create` writes the agent before the Discord step saves its token,
69
+ # so the server can see the agent first and only get the token here.
70
+ Brainiac.on(:agent_updated) do |ctx|
71
+ agent_key = ctx[:agent_key]
72
+ token = ((ctx[:entry].is_a?(Hash) && ctx[:entry]["env"]) || {})["DISCORD_BOT_TOKEN"]
73
+ next if token == Gateway.bot_token(agent_key)
74
+
75
+ Config.reload! # pick up the user_mappings entry the setup step wrote
76
+ Gateway.stop_bot!(agent_key)
77
+ if token
78
+ Gateway.start_bot!(agent_key, token)
79
+ LOG.info "[Discord] Started bot for #{ctx[:display_name]} (token added/changed)" if defined?(LOG)
80
+ end
81
+ end
82
+
68
83
  Brainiac.on(:agent_removed) do |ctx|
69
84
  agent_key = ctx[:agent_key]
70
85
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainiac-discord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis