bot

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const EventLoggerPeriodDuration = time.Second * 10
View Source
const (
	// How long after removing a guild the config for it gets cleared
	GuildRemoveConfigExpire = 60 * 60 * 24 // <- 1 day
)

Variables

View Source
var (
	// When the bot was started
	Started      = time.Now()
	Running      bool
	State        *dstate.State
	ShardManager *dshardmanager.Manager

	StateHandlerPtr *eventsystem.Handler
)
View Source
var (
	ErrStartingUp    = errors.New("Starting up, caches are being filled...")
	ErrGuildNotFound = errors.New("Guild not found")
)
View Source
var (
	Cache = cache.New(time.Minute, time.Minute)
)
View Source
var (
	EventLogger = &eventLogger{}
)
View Source
var (
	MemberFetcher = &memberFetcher{
		fetching:    make(map[int64]*MemberFetchGuildQueue),
		notFetching: make(map[int64]*MemberFetchGuildQueue),
	}
)

Functions

func AdminOrPerm

func AdminOrPerm(needed int, userID, channelID int64) (bool, error)

func ConcurrentEventHandler

func ConcurrentEventHandler(inner eventsystem.Handler) eventsystem.Handler

func ContextRedis

func ContextRedis(ctx context.Context) *redis.Client

func ContextSession

func ContextSession(ctx context.Context) *discordgo.Session

func EmitGuildRemoved

func EmitGuildRemoved(guildID int64)

func GetCreatePrivateChannel

func GetCreatePrivateChannel(user int64) (*discordgo.Channel, error)

func GetMember

func GetMember(guildID, userID int64) (*discordgo.Member, error)

func GetMembers

func GetMembers(guildID int64, userIDs ...int64) ([]*discordgo.Member, error)

func GuildCountsFunc

func GuildCountsFunc() []int

func GuildName added in v0.29.1

func GuildName(gID int64) (name string)

GuildName is a convenience function for getting the name of a guild

func HandleChannelCreate

func HandleChannelCreate(evt *eventsystem.EventData)

func HandleChannelDelete

func HandleChannelDelete(evt *eventsystem.EventData)

func HandleChannelUpdate

func HandleChannelUpdate(evt *eventsystem.EventData)

func HandleGuildCreate

func HandleGuildCreate(evt *eventsystem.EventData)

func HandleGuildDelete

func HandleGuildDelete(evt *eventsystem.EventData)

func HandleGuildMemberUpdate

func HandleGuildMemberUpdate(evt *eventsystem.EventData)

func HandleGuildRoleCreate

func HandleGuildRoleCreate(evt *eventsystem.EventData)

func HandleGuildRoleRemove

func HandleGuildRoleRemove(evt *eventsystem.EventData)

func HandleGuildRoleUpdate

func HandleGuildRoleUpdate(evt *eventsystem.EventData)

func HandleGuildUpdate

func HandleGuildUpdate(evt *eventsystem.EventData)

func HandlePresenceUpdate

func HandlePresenceUpdate(evt *eventsystem.EventData)

Makes sure the member is always in state when coming online

func HandleReady

func HandleReady(evt *eventsystem.EventData)

func InvalidateCache

func InvalidateCache(client *redis.Client, guildID, userID int64)

func MonitorLoading

func MonitorLoading()

func QueueMergedMessage

func QueueMergedMessage(channelID int64, message string)

func RedisWrapper

func RedisWrapper(inner eventsystem.Handler) eventsystem.Handler

func Run

func Run()

func SendDM

func SendDM(user int64, msg string) error

func Setup

func Setup()

func StateHandler

func StateHandler(evt *eventsystem.EventData)

StateHandler updates the world state use AddHandlerBefore to add handler before this one, otherwise they will alwyas be after

func Stop

func Stop(wg *sync.WaitGroup)

Types

type BotStartedHandler

type BotStartedHandler interface {
	BotStarted()
}

Fired after the bot has connected all shards

type BotStarterHandler

type BotStarterHandler interface {
	StartBot()
}

Fired when the bot it starting up, not for the webserver

type BotStopperHandler

type BotStopperHandler interface {
	StopBot(wg *sync.WaitGroup)
}

type DiscordMessages

type DiscordMessages []*dstate.MessageState

func (DiscordMessages) Len

func (d DiscordMessages) Len() int

Len is the number of elements in the collection.

func (DiscordMessages) Less

func (d DiscordMessages) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (DiscordMessages) Swap

func (d DiscordMessages) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type MemberFetchGuildQueue

type MemberFetchGuildQueue struct {
	Queue []*MemberFetchRequest
}

type MemberFetchRequest

type MemberFetchRequest struct {
	Member          int64
	Guild           int64
	WaitingChannels []chan MemberFetchResult
}

type MemberFetchResult

type MemberFetchResult struct {
	Err    error
	Member *discordgo.Member
}

type NewGuildHandler

type NewGuildHandler interface {
	NewGuild(client *redis.Client, guild *discordgo.Guild) error
}

Used for intializing stuff for new servers

type Plugin

type Plugin interface {
	// Called when the plugin is supposed to be initialized
	// That is add comnands, discord event handlers
	InitBot()
	Name() string
}

type RemoveGuildHandler

type RemoveGuildHandler interface {
	RemoveGuild(client *redis.Client, guildID int64) error
}

Used for deleting configuration about servers

type WrappedMessage

type WrappedMessage struct {
	*discordgo.Message
	Deleted bool
}

func GetMessages

func GetMessages(channelID int64, limit int, deleted bool) ([]*WrappedMessage, error)

GetMessages Gets messages from state if possible, if not then it retrieves from the discord api Puts the messages in the state aswell

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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