Add HasPermission(), some formatting

This commit is contained in:
Matthieu Grieger 2014-12-15 16:40:31 -08:00
parent 7f6d764821
commit 369e1287ba

17
main.go
View file

@ -21,6 +21,7 @@ type mumbledj struct {
keepAlive chan bool keepAlive chan bool
defaultChannel string defaultChannel string
conf DjConfig conf DjConfig
queue SongQueue
} }
func (dj *mumbledj) OnConnect(e *gumble.ConnectEvent) { func (dj *mumbledj) OnConnect(e *gumble.ConnectEvent) {
@ -44,7 +45,20 @@ func (dj *mumbledj) OnDisconnect(e *gumble.DisconnectEvent) {
func (dj *mumbledj) OnTextMessage(e *gumble.TextMessageEvent) { func (dj *mumbledj) OnTextMessage(e *gumble.TextMessageEvent) {
if e.Message[0] == '!' { if e.Message[0] == '!' {
parseCommand(e.Sender.Name(), e.Message[1:]) parseCommand(e.Sender, e.Sender.Name(), e.Message[1:])
}
}
func (dj *mumbledj) HasPermission(username string, command bool) bool {
if dj.conf.Permissions.AdminsEnabled && command {
for _, adminName := range dj.conf.Permissions.Admins {
if username == adminName {
return true
}
}
return false
} else {
return true
} }
} }
@ -84,4 +98,3 @@ func main() {
<-dj.keepAlive <-dj.keepAlive
} }