Documentation ¶
Index ¶
- func AcknowledgeChannel(session *discordgo.Session, channelID string) error
- func CompareChannels(a, b *discordgo.Channel) bool
- func FindDMChannelWithUser(state *discordgo.State, userID string) *discordgo.Channel
- func FindEmojiInGuild(session *discordgo.Session, guild *discordgo.Guild, omitGWCheck bool, ...) string
- func GenerateQuote(message, author string, time discordgo.Timestamp, ...) (string, error)
- func GetMemberColor(state *discordgo.State, member *discordgo.Member) string
- func GetMemberName(member *discordgo.Member) string
- func GetPrivateChannelName(channel *discordgo.Channel) string
- func GetPrivateChannelNameUnescaped(channel *discordgo.Channel) string
- func GetRoleColor(role *discordgo.Role) string
- func GetUserColor(user *discordgo.User) string
- func GetUserName(user *discordgo.User) string
- func HandleReactionAdd(state *discordgo.State, message *discordgo.Message, ...)
- func HandleReactionRemove(state *discordgo.State, message *discordgo.Message, ...)
- func HandleReactionRemoveAll(state *discordgo.State, message *discordgo.Message)
- func HasReadMessagesPermission(channelID string, state *discordgo.State) bool
- func IsBlocked(state *discordgo.State, user *discordgo.User) bool
- func LoadGuilds(guildLoader GuildLoader) ([]*discordgo.UserGuild, error)
- func MentionsCurrentUserExplicitly(state *discordgo.State, message *discordgo.Message) bool
- func MessageToPlainText(message *discordgo.Message) string
- func ReplaceMentions(message *discordgo.Message) string
- func ResolveFilePathAndSendFile(session *discordgo.Session, message, targetChannelID string) error
- func SendMessageAsFile(session *discordgo.Session, message string, channel string, ...)
- func SortGuilds(settings *discordgo.Settings, guilds []*discordgo.Guild)
- func SortMessagesByTimestamp(messages []*discordgo.Message)
- func SortPrivateChannels(channels []*discordgo.Channel)
- func SortUserRoles(roles []string, guildRoles []*discordgo.Role)
- type GuildLoader
- type MessageDataSupplier
- type MessageLoader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcknowledgeChannel ¶
AcknowledgeChannel acknowledges all messages in the given channel. If the channel is a category, all children will be acknowledged.
func CompareChannels ¶
CompareChannels checks which channel is smaller. Smaller meaning it is the one with the more recent message.
func FindDMChannelWithUser ¶
FindDMChannelWithUser tries to find a DM channel with the specified user as one of its two recipients. If no channel is found, nil is returned.
func FindEmojiInGuild ¶
func FindEmojiInGuild(session *discordgo.Session, guild *discordgo.Guild, omitGWCheck bool, emojiSequence string) string
FindEmojiInGuild searches for a fitting emoji. Fitting means the correct name (case insensitive), not animated and the correct permissions. If the result is an empty string, it means no result was found.
func GenerateQuote ¶
func GenerateQuote(message, author string, time discordgo.Timestamp, attachments []*discordgo.MessageAttachment, messageAfterQuote string) (string, error)
GenerateQuote formats a message quote using the given Input. The `messageAfterQuote` will be appended after the quote in case it is not empty.
func GetMemberColor ¶
GetMemberColor gets the members color according the members role. If role colors aren't enabled, or the member is a bot, we fallthrough to GetUserColor.
func GetMemberName ¶
GetMemberName returns the name to use for representing this user. This is either the username or the nickname. In case the member is a bot, the bot prefix will be prepended.
func GetPrivateChannelName ¶
GetPrivateChannelName generates a name for a private channel.
func GetPrivateChannelNameUnescaped ¶
GetPrivateChannelNameUnescaped generates a name for a private channel. The name won't be escaped view tviewutil and therefore shouldn't be used for displaying it in tview components.
func GetRoleColor ¶
GetRoleColor returns the roles color in the format #RRGGBB or an empty string if there's no color.
func GetUserColor ¶
GetUserColor gers a user color according to the configuration. If "random" is the setting, then a new random color is retrieved and cached for this session and this user.
func GetUserName ¶
GetUserName returns the users username, prepending the bot prefix in case he is a bot.
func HandleReactionAdd ¶
func HandleReactionAdd(state *discordgo.State, message *discordgo.Message, newReaction *discordgo.MessageReactionAdd)
HandleReactionAdd adds a new reaction to a message or updates the count if that message already has a reaction with that same emoji.
func HandleReactionRemove ¶
func HandleReactionRemove(state *discordgo.State, message *discordgo.Message, newReaction *discordgo.MessageReactionRemove)
HandleReactionRemove removes an existing reaction to a message or updates the count if the same message still has reactions with the same emoji left.
func HandleReactionRemoveAll ¶
HandleReactionRemoveAll removes all reactions from all users in a message.
func HasReadMessagesPermission ¶
HasReadMessagesPermission checks if the user has permission to view a specific channel.
func IsBlocked ¶
IsBlocked checks whether the state contains any relationship that says the given user has been blocked.
func LoadGuilds ¶
func LoadGuilds(guildLoader GuildLoader) ([]*discordgo.UserGuild, error)
LoadGuilds loads all guilds the current user is part of.
func MentionsCurrentUserExplicitly ¶
MentionsCurrentUserExplicitly checks whether the message contains any explicit mentions for the user associated with the currently logged in user.
func MessageToPlainText ¶
MessageToPlainText converts a discord message to a human readable text. Markdown characters are reserved and file attachments are added as URLs. Embeds are currently not being handled, nor are other special elements.
func ReplaceMentions ¶
ReplaceMentions replaces both user mentions and global mentions like @here and @everyone.
func ResolveFilePathAndSendFile ¶
ResolveFilePathAndSendFile will attempt to resolve the message and see if it points to a file on the users harddrive. If so, it's sent to the given channel using it's basename as the discord filename.
func SendMessageAsFile ¶
func SendMessageAsFile(session *discordgo.Session, message string, channel string, onFailure func(error))
SendMessageAsFile sends the given message into the given channel using the passed discord Session. If an error occurs, onFailure gets called.
func SortGuilds ¶
SortGuilds sorts the guilds according to the users settings.
func SortMessagesByTimestamp ¶
SortMessagesByTimestamp sorts all messages in the given array according to their creation date.
func SortPrivateChannels ¶
SortPrivateChannels sorts private channels depending on their last message.
func SortUserRoles ¶
SortUserRoles sorts an array of roleIDs according to the guilds roles.
Types ¶
type GuildLoader ¶
GuildLoader reflects an instance that allows loading guilds from a discord backend.
type MessageDataSupplier ¶
type MessageDataSupplier interface { // ChannelMessages fetches up to 100 messages for a channel. // The parameter beforeID defines whether message only older than // a specific message should be returned. The parameter afterID does // the same but for newer messages. The parameter aroundID is a mix of // both. ChannelMessages(channelID string, limit int, beforeID string, afterID string, aroundID string) ([]*discordgo.Message, error) }
MessageDataSupplier defines the method that is necessary for requesting channels. This is satisfied by the discordgo.Session struct and can be used in order to make testing easier.
type MessageLoader ¶
type MessageLoader struct {
// contains filtered or unexported fields
}
MessageLoader represents a util object that remember which channels have already been cached and which not.
func CreateMessageLoader ¶
func CreateMessageLoader(messageDataSupplier MessageDataSupplier) *MessageLoader
CreateMessageLoader creates a MessageLoader using the given MessageDataSupplier. It is empty and can be used right away.
func (*MessageLoader) DeleteFromCache ¶
func (l *MessageLoader) DeleteFromCache(channelID string)
DeleteFromCache deletes the entry that indicates the channel has been cached. The next call to LoadMessages with the same ID will ask for data from the MessageDataSupplier.
func (*MessageLoader) IsCached ¶
func (l *MessageLoader) IsCached(channelID string) bool
IsCached checks whether the channel has already been requested from the backend once.
func (*MessageLoader) LoadMessages ¶
LoadMessages returns the last 100 messages for a channel. If less messages were sent, less will be returned. As soon as a channel has been loaded once it won't ever be loaded again, instead a global cache will be accessed.