catbase/bot/users.go

49 lines
831 B
Go
Raw Normal View History

2016-01-17 18:00:44 +00:00
// © 2013 the CatBase Authors under the WTFPL. See AUTHORS for the list of authors.
package bot
// User type stores user history. This is a vehicle that will follow the user for the active
// session
type User struct {
// Current nickname known
Name string
// LastSeen DateTime
// Alternative nicknames seen
Alts []string
Parent string
Admin bool
//bot *bot
}
var users = map[string]*User{}
func (b *bot) GetUser(nick string) *User {
if _, ok := users[nick]; !ok {
users[nick] = &User{
Name: nick,
Admin: b.checkAdmin(nick),
}
}
return users[nick]
}
func (b *bot) NewUser(nick string) *User {
return &User{
Name: nick,
Admin: b.checkAdmin(nick),
}
}
func (b *bot) checkAdmin(nick string) bool {
for _, u := range b.Config().Admins {
if nick == u {
return true
}
}
return false
}