common

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdPlaceHolder      = "{{cmd}}"
	NumErrorPlaceHolder = "{{numError}}"
	RolePlaceHolder     = "{{role}}"
)
View Source
const MemberCallLimit = 1000

max number of members returned by Discord API (as stated in Session.GuildMembers documentation)

Variables

This section is empty.

Functions

func AddNonEmpty

func AddNonEmpty[T any](m map[string]T, name string, value T)

func AuthorizedCmd added in v1.4.0

func AuthorizedCmd(s *discordgo.Session, i *discordgo.InteractionCreate, infos GuildAndConfInfo, cmdEffect func() string)

func BuildMsgWithNameValueList

func BuildMsgWithNameValueList(baseMsg string, nameToValue map[string]string) string

func CleanMessage added in v1.4.0

func CleanMessage(msg string) string

Remove "{{cmd}}" place holder and replace multiple space in row by one space

func ExtractNick

func ExtractNick(member *discordgo.Member) (nick string)

func IdInSet

func IdInSet(ids []string, idSet StringSet) bool

func InitChecker

func InitChecker(rule string) func(string) bool

func LaunchTickers

func LaunchTickers(number int, interval time.Duration) []chan time.Time

func LogBeforeShutdown added in v1.4.0

func LogBeforeShutdown()

func MembersCmd

func MembersCmd(s *discordgo.Session, i *discordgo.InteractionCreate, messageSender chan<- MultipartMessage, infos GuildAndConfInfo, msgs Messages, userMonitor *IdMonitor, cmdEffect func(*discordgo.Member) int)

func ProcessMembers added in v1.4.0

func ProcessMembers(guildMembers []*discordgo.Member, userMonitor *IdMonitor, cmdEffect func(*discordgo.Member) int) int

func SendTick

func SendTick(tickSender chan<- bool, interval time.Duration)

func UpdateGameStatus

func UpdateGameStatus(session *discordgo.Session, games []string, interval time.Duration)

Types

type ChannelSenderManager

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

func MakeChannelSenderManager

func MakeChannelSenderManager(session *discordgo.Session) ChannelSenderManager

func (ChannelSenderManager) AddChannel

func (m ChannelSenderManager) AddChannel(channelId string)

func (ChannelSenderManager) Get

func (m ChannelSenderManager) Get(channelId string) chan<- MultipartMessage

type Config

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

func ReadConfig

func ReadConfig() Config

func (Config) GetChatResponsesConfig added in v1.5.0

func (c Config) GetChatResponsesConfig() (string, map[string]string)

func (Config) GetCommandConfig added in v1.4.0

func (c Config) GetCommandConfig() map[string][2]string

func (Config) GetDelayMins

func (c Config) GetDelayMins(valuesConfName string) []time.Duration

func (Config) GetDurationSec

func (c Config) GetDurationSec(valueConfName string) time.Duration

func (Config) GetIdSet

func (c Config) GetIdSet(namesConfName string, nameToId map[string]string) StringSet

func (Config) GetPath

func (c Config) GetPath(pathConfName string) string

func (Config) GetPrefixConfig

func (c Config) GetPrefixConfig() (map[string]string, []string, [][2]string, []string)

func (Config) GetSlice

func (c Config) GetSlice(valuesConfName string) []any

func (Config) GetString

func (c Config) GetString(valueConfName string) string

func (Config) GetStringSlice

func (c Config) GetStringSlice(valuesConfName string) []string

func (Config) Require

func (c Config) Require(valueConfName string) string

type Empty

type Empty = struct{}

type GuildAndConfInfo

type GuildAndConfInfo struct {
	GuildId                    string
	OwnerId                    string
	DefaultRoleId              string
	AuthorizedRoleIds          StringSet
	ForbiddenRoleIds           StringSet
	IgnoredRoleIds             StringSet
	ForbiddenAndignoredRoleIds StringSet
	AdminitrativeRoleIds       StringSet
	CmdRoleIds                 StringSet
	SpecialRoleIds             StringSet
	RoleIdToPrefix             map[string]string
	Prefixes                   []string
	RoleIdToDisplayName        map[string]string
	Msgs                       Messages
}

type IdMonitor

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

func MakeIdMonitor

func MakeIdMonitor() IdMonitor

func (*IdMonitor) StartProcessing

func (m *IdMonitor) StartProcessing(id string) bool

func (*IdMonitor) StopProcessing

func (m *IdMonitor) StopProcessing(id string)

type Messages added in v1.4.0

type Messages struct {
	Ok              string
	ErrUnauthorized string
	ErrGlobalCmd    string
	ErrPartialCmd   string
	Count           string
	Prefix          string
	NoChange        string
	EndedCmd        string
	Owner           string
	ErrGlobal       string
	ErrPartial      string
}

func (Messages) ReplaceCmdPlaceHolder added in v1.4.0

func (m Messages) ReplaceCmdPlaceHolder(cmdName string) Messages

type MultipartMessage

type MultipartMessage struct {
	Message    string
	FileName   string
	FileData   string
	ErrorMsg   string
	AllowMerge bool
}

type StringSet

type StringSet = map[string]Empty

func InitIdSet

func InitIdSet(names []string, nameToId map[string]string) StringSet

Jump to

Keyboard shortcuts

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