mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-30 00:21:16 +00:00
[editor] Add notification in case bot is missing default-scopes
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
4477874330
commit
5b608b46e9
2 changed files with 29 additions and 0 deletions
|
@ -55,12 +55,14 @@ func registerEditorFrontend() {
|
||||||
|
|
||||||
router.HandleFunc("/editor/vars.json", func(w http.ResponseWriter, r *http.Request) {
|
router.HandleFunc("/editor/vars.json", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if err := json.NewEncoder(w).Encode(struct {
|
if err := json.NewEncoder(w).Encode(struct {
|
||||||
|
DefaultBotScopes []string
|
||||||
IRCBadges []string
|
IRCBadges []string
|
||||||
KnownEvents []*string
|
KnownEvents []*string
|
||||||
TemplateFunctions []string
|
TemplateFunctions []string
|
||||||
TwitchClientID string
|
TwitchClientID string
|
||||||
Version string
|
Version string
|
||||||
}{
|
}{
|
||||||
|
DefaultBotScopes: botDefaultScopes,
|
||||||
IRCBadges: twitch.KnownBadges,
|
IRCBadges: twitch.KnownBadges,
|
||||||
KnownEvents: knownEvents,
|
KnownEvents: knownEvents,
|
||||||
TemplateFunctions: tplFuncs.GetFuncNames(),
|
TemplateFunctions: tplFuncs.GetFuncNames(),
|
||||||
|
|
|
@ -268,6 +268,17 @@
|
||||||
<li>Open the copied URL, sign in with the bot account and accept the permissions</li>
|
<li>Open the copied URL, sign in with the bot account and accept the permissions</li>
|
||||||
<li>The bot will display a message containing the authorized account. If this account is wrong, just start over, the token will be overwritten.</li>
|
<li>The bot will display a message containing the authorized account. If this account is wrong, just start over, the token will be overwritten.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<p
|
||||||
|
v-if="botMissingScopes > 0"
|
||||||
|
class="text-warning"
|
||||||
|
>
|
||||||
|
<font-awesome-icon
|
||||||
|
fixed-width
|
||||||
|
class="mr-1"
|
||||||
|
:icon="['fas', 'exclamation-triangle']"
|
||||||
|
/>
|
||||||
|
Bot is missing {{ botMissingScopes }} of its default scopes, please re-authorize the bot.
|
||||||
|
</p>
|
||||||
<b-input-group>
|
<b-input-group>
|
||||||
<b-form-input
|
<b-form-input
|
||||||
placeholder="Loading..."
|
placeholder="Loading..."
|
||||||
|
@ -421,6 +432,22 @@ export default {
|
||||||
return 'warning'
|
return 'warning'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
botMissingScopes() {
|
||||||
|
let missing = 0
|
||||||
|
|
||||||
|
if (!this.generalConfig || !this.generalConfig.channel_scopes || !this.generalConfig.bot_name || !this.generalConfig.channel_scopes[this.generalConfig.bot_name]) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const scope of this.$root.vars.DefaultBotScopes) {
|
||||||
|
if (!this.generalConfig.channel_scopes[this.generalConfig.bot_name].includes(scope)) {
|
||||||
|
missing++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return missing
|
||||||
|
},
|
||||||
|
|
||||||
extendedPermissions() {
|
extendedPermissions() {
|
||||||
return Object.keys(this.authURLs.available_extended_scopes || {})
|
return Object.keys(this.authURLs.available_extended_scopes || {})
|
||||||
.map(v => ({ text: this.authURLs.available_extended_scopes[v], value: v }))
|
.map(v => ({ text: this.authURLs.available_extended_scopes[v], value: v }))
|
||||||
|
|
Loading…
Reference in a new issue