parent
9574dc10b6
commit
0b7944fe71
@ -0,0 +1,87 @@
|
|||||||
|
package bot
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
// UserEmoji holds a guild emoji information for a user
|
||||||
|
type UserEmoji struct {
|
||||||
|
ID string
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
type userPrivacy uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
userPrivacyNone userPrivacy = 0
|
||||||
|
userPrivacyPart userPrivacy = 1 << iota
|
||||||
|
userPrivacyJoin userPrivacy = 1 << iota
|
||||||
|
userPrivacyStatus userPrivacy = 1 << iota
|
||||||
|
userPrivacyAll userPrivacy = 0xFF
|
||||||
|
)
|
||||||
|
|
||||||
|
func upSet(b, flag userPrivacy) userPrivacy { return b | flag }
|
||||||
|
func upClear(b, flag userPrivacy) userPrivacy { return b &^ flag }
|
||||||
|
func upToggle(b, flag userPrivacy) userPrivacy { return b ^ flag }
|
||||||
|
func upHas(b, flag userPrivacy) bool { return b&flag != 0 }
|
||||||
|
|
||||||
|
func (up userPrivacy) String() string {
|
||||||
|
switch up {
|
||||||
|
case userPrivacyPart:
|
||||||
|
return "part"
|
||||||
|
case userPrivacyJoin:
|
||||||
|
return "join"
|
||||||
|
case userPrivacyStatus:
|
||||||
|
return "status"
|
||||||
|
case userPrivacyAll:
|
||||||
|
return "all"
|
||||||
|
case userPrivacyNone:
|
||||||
|
return "none"
|
||||||
|
}
|
||||||
|
return "none"
|
||||||
|
}
|
||||||
|
|
||||||
|
func userPrivacyFromString(up string) userPrivacy {
|
||||||
|
switch up {
|
||||||
|
case userPrivacyPart.String():
|
||||||
|
return userPrivacyPart
|
||||||
|
case userPrivacyJoin.String():
|
||||||
|
return userPrivacyJoin
|
||||||
|
case userPrivacyStatus.String():
|
||||||
|
return userPrivacyStatus
|
||||||
|
case userPrivacyAll.String():
|
||||||
|
return userPrivacyAll
|
||||||
|
case userPrivacyNone.String():
|
||||||
|
return userPrivacyNone
|
||||||
|
}
|
||||||
|
return userPrivacyNone
|
||||||
|
}
|
||||||
|
|
||||||
|
const userPrivacyDefault = userPrivacyNone
|
||||||
|
|
||||||
|
// User is the structure for a single bot user
|
||||||
|
type User struct {
|
||||||
|
AltVRUserID string
|
||||||
|
DiscordID string
|
||||||
|
DiscordName string
|
||||||
|
DiscordEmoji UserEmoji
|
||||||
|
Role Roles
|
||||||
|
MsgMode msgMode
|
||||||
|
Privacy userPrivacy
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDiscordEmoji If it exists, builds a discord emoji for the user
|
||||||
|
func (u *User) GetDiscordEmoji() string {
|
||||||
|
if u.DiscordEmoji.ID != "" {
|
||||||
|
return fmt.Sprintf("<:%s:%s> ", u.DiscordEmoji.Name, u.DiscordEmoji.ID)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Roles determines the bot user roles
|
||||||
|
type Roles uint
|
||||||
|
|
||||||
|
// Bot user roles
|
||||||
|
const (
|
||||||
|
RoleUser Roles = iota
|
||||||
|
RoleModerator
|
||||||
|
RoleAdmin
|
||||||
|
)
|
||||||
Loading…
Reference in new issue