bot

package
v0.0.0-...-f16325d Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NiaBot

type NiaBot struct {
	DiscordConnection *discord.EventSource
	DBConnection      *db.Connection
	TwitchConnection  *twitch.EventSource
}

NiaBot represents an instance of the discord bot, containing handles to the various external connections.

func Init

func Init() (*NiaBot, error)

Init creates a new NiaBot instance

func (*NiaBot) BotAddURL

func (b *NiaBot) BotAddURL() (*url.URL, error)

BotAddURL generates a URL that can be used to add the bot to a server

func (*NiaBot) Close

func (b *NiaBot) Close()

Close cleanly terminates the bot instance

func (*NiaBot) DiscordSession

func (b *NiaBot) DiscordSession() *discordgo.Session

DiscordSession returns a handle to the underlying discord session

func (*NiaBot) HandleAddAdminMessage

func (b *NiaBot) HandleAddAdminMessage(msg *discordgo.MessageCreate)

HandleAddAdminMessage handles a message containing an add admin role command command format: !addadminrole <role>

func (*NiaBot) HandleAddManagedRoleMessage

func (b *NiaBot) HandleAddManagedRoleMessage(msg *discordgo.MessageCreate)

HandleAddManagedRoleMessage handles a message starting with the !addmanagedrole command syntax: !addmanagedrole "<role>" <type> [typeopts]

func (*NiaBot) HandleInitReactionsMessage

func (b *NiaBot) HandleInitReactionsMessage(msg *discordgo.MessageCreate)

HandleInitReactionsMessage handles a message containing an add initial reactions command command format: !initreactions

func (*NiaBot) HandleMessage

func (b *NiaBot) HandleMessage(msg *discordgo.MessageCreate)

HandleMessage is called upon every recieved message. It checks if the message is a command, and executes it.

func (*NiaBot) HandlePurgeRoleMessage

func (b *NiaBot) HandlePurgeRoleMessage(msg *discordgo.MessageCreate)

HandlePurgeRoleMessage handles a message containing a purge role command command format: !purgerole <role>

func (*NiaBot) HandleReactionAdd

func (b *NiaBot) HandleReactionAdd(reaction *discordgo.MessageReaction)

HandleReactionAdd recieves a MessageReaction struct generated by a MessageReactionAdd Discord gateway event and handles any changes that are needed.

func (*NiaBot) HandleReactionRemove

func (b *NiaBot) HandleReactionRemove(reaction *discordgo.MessageReaction)

HandleReactionRemove recieves a MessageReaction struct generated by a MessageReactionRemove Discord gateway event and handles any changes that need to be made.

func (*NiaBot) HandleRegisterTwitchCommandMessage

func (b *NiaBot) HandleRegisterTwitchCommandMessage(msg *discordgo.MessageCreate)

HandleRegisterTwitchCommandMessage takes a message from any server member and registers a twitch channel for them

func (*NiaBot) HandleResetTwitchEventsub

func (b *NiaBot) HandleResetTwitchEventsub(msg *discordgo.MessageCreate)

HandleResetTwitchEventsub unsubscribes from all twitch eventsub events then recreates subscriptions for every subscribed stream in the database

func (*NiaBot) HandleSetNotificationChannel

func (b *NiaBot) HandleSetNotificationChannel(msg *discordgo.MessageCreate)

HandleSetNotificationChannel handles a message from an admin setting a certain channel as the target for alert messages

func (*NiaBot) HandleTwitchStreamOffline

func (b *NiaBot) HandleTwitchStreamOffline(e *messages.StreamOfflineEvent)

HandleTwitchStreamOffline handles a streamoffline event generated by the Twitch EventSub API

func (*NiaBot) HandleTwitchStreamOnline

func (b *NiaBot) HandleTwitchStreamOnline(e *messages.StreamOnlineEvent)

HandleTwitchStreamOnline handles a streamonline event generated by the Twitch EventSub API

func (*NiaBot) SetUserStreaming

func (b *NiaBot) SetUserStreaming(tuid, uid, gid string) error

SetUserStreaming assigns the provided correct role and makes an announcement post (if needed) for the given stream in the given discord guild

type NiaResponse

type NiaResponse interface {
	DiscordResponse() *discordgo.MessageSend
	WriteToLog()
}

NiaResponse represents the result of a command which can be both communicated over discord and written to the log.

type NiaResponseFeatureNotEnabled

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

NiaResponseFeatureNotEnabled will be returned when a user tried to run a command which requires an unloaded module

func (NiaResponseFeatureNotEnabled) DiscordResponse

func (r NiaResponseFeatureNotEnabled) DiscordResponse() *discordgo.MessageSend

DiscordResponse builds a MessageSend object which can be sent back to whoever sent a command message.

func (NiaResponseFeatureNotEnabled) WriteToLog

func (r NiaResponseFeatureNotEnabled) WriteToLog()

WriteToLog dumps data on a discord command response to the log

type NiaResponseInternalError

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

NiaResponseInternalError will be returned when there was some kind of error within the bot or when communicating with APIs

func (NiaResponseInternalError) DiscordResponse

func (r NiaResponseInternalError) DiscordResponse() *discordgo.MessageSend

DiscordResponse builds a MessageSend object which can be sent back to whoever sent a command message.

func (NiaResponseInternalError) WriteToLog

func (r NiaResponseInternalError) WriteToLog()

WriteToLog dumps data on a discord command response to the log

type NiaResponseNotAllowed

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

NiaResponseNotAllowed will be returned when a user tried to run a command that they do not have the correct role for

func (NiaResponseNotAllowed) DiscordResponse

func (r NiaResponseNotAllowed) DiscordResponse() *discordgo.MessageSend

DiscordResponse builds a MessageSend object which can be sent back to whoever sent a command message.

func (NiaResponseNotAllowed) WriteToLog

func (r NiaResponseNotAllowed) WriteToLog()

WriteToLog dumps data on a discord command response to the log

type NiaResponsePartialSuccess

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

NiaResponsePartialSuccess will be returned when a command has executed but with issues

func (NiaResponsePartialSuccess) DiscordResponse

func (r NiaResponsePartialSuccess) DiscordResponse() *discordgo.MessageSend

DiscordResponse builds a MessageSend object which can be sent back to whoever sent a command message.

func (NiaResponsePartialSuccess) WriteToLog

func (r NiaResponsePartialSuccess) WriteToLog()

WriteToLog dumps data on a discord command response to the log

type NiaResponseSuccess

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

NiaResponseSuccess will be returned when a command has been successfully completed

func (NiaResponseSuccess) DiscordResponse

func (r NiaResponseSuccess) DiscordResponse() *discordgo.MessageSend

DiscordResponse builds a MessageSend object which can be sent back to whoever sent a command message.

func (NiaResponseSuccess) WriteToLog

func (r NiaResponseSuccess) WriteToLog()

WriteToLog dumps data on a discord command response to the log

type NiaResponseSyntaxError

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

NiaResponseSyntaxError will be returned when there was an issue with the user's input

func (NiaResponseSyntaxError) DiscordResponse

func (r NiaResponseSyntaxError) DiscordResponse() *discordgo.MessageSend

DiscordResponse builds a MessageSend object which can be sent back to whoever sent a command message.

func (NiaResponseSyntaxError) WriteToLog

func (r NiaResponseSyntaxError) WriteToLog()

WriteToLog dumps data on a discord command response to the log

Jump to

Keyboard shortcuts

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