mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 11:51:17 +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) {
|
||||
if err := json.NewEncoder(w).Encode(struct {
|
||||
DefaultBotScopes []string
|
||||
IRCBadges []string
|
||||
KnownEvents []*string
|
||||
TemplateFunctions []string
|
||||
TwitchClientID string
|
||||
Version string
|
||||
}{
|
||||
DefaultBotScopes: botDefaultScopes,
|
||||
IRCBadges: twitch.KnownBadges,
|
||||
KnownEvents: knownEvents,
|
||||
TemplateFunctions: tplFuncs.GetFuncNames(),
|
||||
|
|
|
@ -268,6 +268,17 @@
|
|||
<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>
|
||||
</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-form-input
|
||||
placeholder="Loading..."
|
||||
|
@ -421,6 +432,22 @@ export default {
|
|||
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() {
|
||||
return Object.keys(this.authURLs.available_extended_scopes || {})
|
||||
.map(v => ({ text: this.authURLs.available_extended_scopes[v], value: v }))
|
||||
|
|
Loading…
Reference in a new issue