Documentation ¶
Index ¶
- Variables
- func GetMembers() []*discordgo.Member
- func IsUserIDAdmin(userID string) (bool, error)
- func IsUserIDVerified(userID string) (bool, error)
- func Member(id string) (*discordgo.Member, error)
- type Channel
- type ChannelCategory
- type DiscordAPI
- func (d *DiscordAPI) Connect() error
- func (d *DiscordAPI) FindGuildRole(roleID string) (*discordgo.Role, error)
- func (d *DiscordAPI) FindGuildRoleByName(name string) (*discordgo.Role, error)
- func (d *DiscordAPI) FindIDByUsername(username string) (string, string)
- func (d *DiscordAPI) FindIDByUsernameStartingAt(username string, snowflake string) (string, string)
- func (d *DiscordAPI) MindGuild()
- func (d *DiscordAPI) PostJoinEventMessage(e *db.Event, member string) error
- func (d *DiscordAPI) PostNewEventMessage(e *db.Event) error
- func (d DiscordAPI) PostStreamMessage(sm messaging.StreamMessage) error
- func (d *DiscordAPI) SendDM(userID string, message string)
- func (d *DiscordAPI) Shutdown()
- func (d *DiscordAPI) StartRoleHandlers()
- type DiscordCfg
- type DiscordData
- func (d *DiscordData) ChannelByID(id string) (*discordgo.Channel, error)
- func (d *DiscordData) GetChannels() []*discordgo.Channel
- func (d *DiscordData) GetMembers() []*discordgo.Member
- func (d *DiscordData) IsUserIDAdmin(id string) (bool, error)
- func (d *DiscordData) Member(id string) (*discordgo.Member, error)
- func (d *DiscordData) MemberByNick(username string) (*discordgo.Member, error)
- func (d *DiscordData) RoleByName(group string) (*discordgo.Role, error)
- type DiscordEmojiRoleGroup
- type DiscordRoleCfg
- type EmojiRole
- type GuildChannels
Constants ¶
This section is empty.
Variables ¶
var DB *db.DB
var ErrChannelNotFound = fmt.Errorf("Unable to find any channel by that name")
var ErrDiscordAPIUnresponsive = fmt.Errorf("The Discord api returned no data. Error assumed")
ErrSlackAPIUnresponsive means that on boot up we were unable to fetch any users from the slack api so we assume that the api is unresponsive. It needs to be there at least when starting up to get initial lists of users, groups, and channels
var ErrRoleNotFound = fmt.Errorf("Unable to find any role by that name")
var ErrUsernameNotFound = fmt.Errorf("Unable to find any user by that name")
ErrUsernameNotFound represents being unable to find a user by a given name (they can change)
var LogLevel = zap.InfoLevel
LogLevel sets the logging verbosity for the package
var Logger *zap.Logger
var StartupNotice = false
var Logger *zap.Logger
var UpdateRequest = make(chan struct{})
var UpdateTimer = 30 * time.Minute
UpdateTimer sets how often to check for updated users, group, and channel lists in slack
Functions ¶
func GetMembers ¶
func IsUserIDAdmin ¶
IsUserIDAdmin checks the given Discord ID to check if the user has an admin role as defined in the bot package
func IsUserIDVerified ¶
IsUserIDVerified checks if the Discord user with the id given has the verified role as defined in the bot package
Types ¶
type ChannelCategory ¶
type DiscordAPI ¶
type DiscordAPI struct { Config DiscordCfg // contains filtered or unexported fields }
func NewDiscordAPI ¶
func NewDiscordAPI(cfg DiscordCfg, yt *youtube.Service) *DiscordAPI
func StartDiscord ¶
func StartDiscord(cfg DiscordCfg, yt *youtube.Service) (*DiscordAPI, error)
StartDiscord starts Discord API bot
func (*DiscordAPI) Connect ¶
func (d *DiscordAPI) Connect() error
Connect Needs to be called before any other API function work
func (*DiscordAPI) FindGuildRole ¶
func (d *DiscordAPI) FindGuildRole(roleID string) (*discordgo.Role, error)
FindGuildRole searches the configured guild roles to find the one that matches the given roleID
func (*DiscordAPI) FindGuildRoleByName ¶
func (d *DiscordAPI) FindGuildRoleByName(name string) (*discordgo.Role, error)
func (*DiscordAPI) FindIDByUsername ¶
func (d *DiscordAPI) FindIDByUsername(username string) (string, string)
FindIDByUsername searches the server for a user with the specified username. Returns the ID and username
func (*DiscordAPI) FindIDByUsernameStartingAt ¶
func (d *DiscordAPI) FindIDByUsernameStartingAt(username string, snowflake string) (string, string)
FindIDByUsernameStartingAt searches the server for a user with the specified username starting at the id/snowflake. Returns the ID and username
func (*DiscordAPI) MindGuild ¶
func (d *DiscordAPI) MindGuild()
MindGuild starts routines to monitor Discord things like channels
func (*DiscordAPI) PostJoinEventMessage ¶
func (d *DiscordAPI) PostJoinEventMessage(e *db.Event, member string) error
PostJoinEventMessage sends a new message to Discord when a user joins an event
func (*DiscordAPI) PostNewEventMessage ¶
func (d *DiscordAPI) PostNewEventMessage(e *db.Event) error
PostNewEventMessage
func (DiscordAPI) PostStreamMessage ¶
func (d DiscordAPI) PostStreamMessage(sm messaging.StreamMessage) error
func (*DiscordAPI) SendDM ¶
func (d *DiscordAPI) SendDM(userID string, message string)
SendDM sends a DM to a user from the bot
func (*DiscordAPI) Shutdown ¶
func (d *DiscordAPI) Shutdown()
Needs to be called to disconnect from discord
func (*DiscordAPI) StartRoleHandlers ¶
func (d *DiscordAPI) StartRoleHandlers()
type DiscordCfg ¶
type DiscordCfg struct { ClientId string `yaml:"appClientId"` Token string `yaml:"botToken"` StreamChannelId string `yaml:"streamChannelId"` GuildId string `yaml:"guildId"` RoleCfg DiscordRoleCfg `yaml:"roleConfig"` }
type DiscordData ¶
type DiscordData struct { sync.RWMutex Users []*discordgo.Member Roles []*discordgo.Role ChannelCategories []*discordgo.Channel Channels []*discordgo.Channel }
SlackData is the structure for the state that we are geeping "up to date" during runtime. It is ephemeral and goes away to be repopulated on program shutdown
func (*DiscordData) ChannelByID ¶
func (d *DiscordData) ChannelByID(id string) (*discordgo.Channel, error)
func (*DiscordData) GetChannels ¶
func (d *DiscordData) GetChannels() []*discordgo.Channel
GetChannels returns a list of all slack.Channels
func (*DiscordData) GetMembers ¶
func (d *DiscordData) GetMembers() []*discordgo.Member
GetUsers returns a list of all slack.User
func (*DiscordData) IsUserIDAdmin ¶
func (d *DiscordData) IsUserIDAdmin(id string) (bool, error)
func (*DiscordData) MemberByNick ¶
func (d *DiscordData) MemberByNick(username string) (*discordgo.Member, error)
UserByName is a helper function to find the slack.User for a given username (@{{username}})
func (*DiscordData) RoleByName ¶
func (d *DiscordData) RoleByName(group string) (*discordgo.Role, error)
type DiscordEmojiRoleGroup ¶
type DiscordRoleCfg ¶
type DiscordRoleCfg struct { ChannelId string `yaml:"channelId"` EmojiRoleGroups []DiscordEmojiRoleGroup `yaml:"emojiRoles"` }
type GuildChannels ¶
type GuildChannels struct {
Categories []ChannelCategory
}