M bot.go => bot.go +3 -2
@@ 17,8 17,9 @@ type bot struct {
db *database.DB
}
-func (b *bot) isAuthorized(user *twitch.User) bool {
- return user.Badges["broadcaster"] == 1
+func (b *bot) isAuthorized(user *twitch.User, channel string) bool {
+ return user.Badges["broadcaster"] == 1 ||
+ (b.cfg.Channels[channel].ModsAreAdmins && user.Badges["moderator"] == 1)
}
func (b *bot) say(msg *twitch.PrivateMessage, text string) {
M config.go => config.go +16 -1
@@ 16,7 16,8 @@ type config struct {
}
type channel struct {
- UseReply bool
+ UseReply bool
+ ModsAreAdmins bool
}
func readConfig(path string) (*config, error) {
@@ 81,6 82,20 @@ func readConfig(path string) (*config, error) {
}
}
+ // By default mods should be allowed to edit commands
+ channel.ModsAreAdmins = true
+ d = channelDir.Children.Get("mods-are-admins")
+ if d != nil {
+ var modsAreAdmins string
+ if err := d.ParseParams(&modsAreAdmins); err != nil {
+ return nil, err
+ }
+
+ if modsAreAdmins == "false" {
+ channel.ModsAreAdmins = false
+ }
+ }
+
channels[name] = *channel
}
config.Channels = channels
M settings.go => settings.go +1 -1
@@ 7,7 7,7 @@ import (
)
func (b *bot) handleSet(parsed []string, msg *twitch.PrivateMessage) error {
- if !b.isAuthorized(&msg.User) {
+ if !b.isAuthorized(&msg.User, msg.Channel) {
return errNotAuthorized
}
M static_commands.go => static_commands.go +1 -1
@@ 12,7 12,7 @@ import (
var errTooShort = errors.New("input too short")
func (b *bot) handleCommands(parsed []string, msg *twitch.PrivateMessage) error {
- if !b.isAuthorized(&msg.User) {
+ if !b.isAuthorized(&msg.User, msg.Channel) {
return errNotAuthorized
}