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 +4 -4
- data/lib/brainiac/plugins/discord/version.rb +1 -1
- data/lib/brainiac/plugins/discord.rb +15 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7111ffc72dd19a6df6442ba8634e288c5085f06d696d51941a9fe64f9223a7db
|
|
4
|
+
data.tar.gz: 6748908008c71f05cdf84eff403bfdeee5ef30bc950acb327de7e5556bbdfc3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a01f1a444b3714dce15727b9c6572295f20b77d1891abaac462da1ee49ebcc3cefedcf44a7e18d00e2eeb339c0a3c70d3513a481a4c8524751aa91d3d7fc59f1
|
|
7
|
+
data.tar.gz: 72e2b469f446a22464134230c5d16a0c7d2d4ea3fee06adb450e795441b4061f87e9f0346ef8be50be573e9f355f6a15857e944ccc5469f3a40d337644f8fa71
|
|
@@ -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
|
|