bot

package
v0.0.0-...-ba02d07 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	// SetupRequired tells whether the command can be run before the bot was configured for the server.
	SetupRequired bool
	AdminOnly     bool
	Handler       CommandHandler
}

Command defines the logic and conditions required for a command to run.

type CommandHandler

type CommandHandler func(*CommandHandlerContext) error

CommandHandler is a handler func called when a command is successfully parsed. An error returned by the handler will cause the bot to exit with a log.Fatal.

type CommandHandlerContext

type CommandHandlerContext struct {
	Session *discordgo.Session
	Event   *discordgo.MessageCreate

	BotUserID state.DiscordID

	ServerID   state.DiscordID
	ServerData state.ServerData

	CommandName string
	CommandArgs []string
	// contains filtered or unexported fields
}

CommandHandlerContext are the parameters passed to a command handler.

func NewCommandHandlerContext

func NewCommandHandlerContext(session *discordgo.Session, event *discordgo.MessageCreate, botUserID state.DiscordID) *CommandHandlerContext

NewCommandHandlerContext initializes a new instance of CommandHandlerContext.

type TempChannel

type TempChannel struct {
	// contains filtered or unexported fields
}

TempChannel is a temporary text channel created by the bot.

func NewTempChannel

func NewTempChannel(context *CommandHandlerContext, voiceChannelID state.DiscordID, userIDs []state.DiscordID) (*TempChannel, error)

NewTempChannel creates a temporary channel for the given users.

func (*TempChannel) AllowUserAccess

func (c *TempChannel) AllowUserAccess(userID state.DiscordID) error

AllowUserAccess gives a user access to the temporary channel.

func (*TempChannel) Delete

func (c *TempChannel) Delete() error

Delete deletes the temporary channel.

func (*TempChannel) DenyUserAccess

func (c *TempChannel) DenyUserAccess(userID state.DiscordID) (bool, error)

DenyUserAccess removes the user's permission to read the channel.

Returns whether the channel is empty.

type TempChannelBot

type TempChannelBot struct {
	// Whether to parse commands given by other bots.
	// Used for running the tests
	AllowBots bool
	// contains filtered or unexported fields
}

TempChannelBot contains all the handlers to discord events for the bot to operate.

func NewTempChannelBot

func NewTempChannelBot(session *discordgo.Session, store state.ServerStore) (*TempChannelBot, error)

NewTempChannelBot initializes a new instance of TempChannelBot.

func (*TempChannelBot) ChannelDelete

func (b *TempChannelBot) ChannelDelete(s *discordgo.Session, m *discordgo.ChannelDelete)

ChannelDelete is called whenever a channel is deleted in a server the bot is in.

func (*TempChannelBot) CleanChannels

func (b *TempChannelBot) CleanChannels()

CleanChannels deletes all the temp channels created by the bot.

func (*TempChannelBot) MessageCreate

func (b *TempChannelBot) MessageCreate(s *discordgo.Session, m *discordgo.MessageCreate)

MessageCreate is called whenever a message arrives in a server the bot is in.

func (*TempChannelBot) VoiceStatusUpdate

func (b *TempChannelBot) VoiceStatusUpdate(s *discordgo.Session, vsu *discordgo.VoiceStateUpdate)

VoiceStatusUpdate is called whenever a user joins/leaves/moves a voice channel.

type TempChannelList

type TempChannelList struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

TempChannelList manages the list of temporary channels created by the bot.

func NewTempChannelList

func NewTempChannelList(session *discordgo.Session) *TempChannelList

NewTempChannelList initializes a new instance of TempChannelList

func (*TempChannelList) AddTempChannel

func (l *TempChannelList) AddTempChannel(tempChannel *TempChannel)

AddTempChannel adds a new temp channel to the list.

func (*TempChannelList) AssignUserToTempChannel

func (l *TempChannelList) AssignUserToTempChannel(userID state.DiscordID, voiceChannelID state.DiscordID) error

AssignUserToTempChannel gives a user access to a temp voice channel. It will remove access from a previous chat, if the user was in one.

func (*TempChannelList) DeleteAllChannels

func (l *TempChannelList) DeleteAllChannels()

DeleteAllChannels deletes all temp channels.

func (*TempChannelList) GetTempChannelForVoiceChat

func (l *TempChannelList) GetTempChannelForVoiceChat(voiceChannelID state.DiscordID) (*TempChannel, bool)

GetTempChannelForVoiceChat returns the temporary text channel that is assigned to the given voice channel ID.

func (*TempChannelList) RemoveTempChannelByID

func (l *TempChannelList) RemoveTempChannelByID(tempChannelID state.DiscordID) (*TempChannel, bool)

RemoveTempChannelByID deletes a temp channel if it exists. Returns whether a channel was found and removed.

func (*TempChannelList) RemoveTempChannelByVoiceChat

func (l *TempChannelList) RemoveTempChannelByVoiceChat(voiceChannelID state.DiscordID) (*TempChannel, bool)

RemoveTempChannelByVoiceChat deletes a temp channel bound to the given voice channel ID, if it exists. Returns whether a channel was found and removed.

func (*TempChannelList) RemoveUserFromChannel

func (l *TempChannelList) RemoveUserFromChannel(userID state.DiscordID) error

RemoveUserFromChannel removes a user when from a voice chat when the user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL