Documentation
¶
Index ¶
- func CommandAdminSay(b *Bot, m *discordgo.Message, rest []string)
- func CommandHelp(b *Bot, m *discordgo.Message, rest []string)
- func CommandLeave(b *Bot, m *discordgo.Message, rest []string)
- func CommandModify(b *Bot, m *discordgo.Message, rest []string)
- type Bot
- func (b *Bot) ConnectDiscord() error
- func (b *Bot) GetMsgChGuild(m *discordgo.Message) (*discordgo.Channel, *discordgo.Guild)
- func (b *Bot) HTTPOAuthCallback(w http.ResponseWriter, r *http.Request)
- func (b *Bot) HTTPOAuthStart(w http.ResponseWriter, r *http.Request)
- func (b *Bot) HandleMentions(s *discordgo.Session, m *discordgo.MessageCreate)
- func (b *Bot) LoadAllBacklogs()
- func (b *Bot) LoadChannelConfigs() error
- func (b *Bot) OAuthStartURL() string
- func (b *Bot) OnChannelCreate(s *discordgo.Session, ch *discordgo.ChannelCreate)
- func (b *Bot) OnChannelPins(s *discordgo.Session, ev *discordgo.ChannelPinsUpdate)
- func (b *Bot) OnMessage(s *discordgo.Session, m *discordgo.MessageCreate)
- func (b *Bot) OnReady(s *discordgo.Session, m *discordgo.Ready)
- func (b *Bot) OnResume(s *discordgo.Session, r *discordgo.Resumed)
- func (b *Bot) QueueLoadBacklog(c *ManagedChannel, didFail bool)
- func (b *Bot) QueueReap(c *ManagedChannel)
- func (b *Bot) ReportToLogChannel(msg string)
- func (b *Bot) SaveAllChannelConfigs() []error
- func (b *Bot) SaveChannelConfig(channelID string) error
- type Config
- type DiskStorage
- type ManagedChannel
- func (c *ManagedChannel) AddMessage(m *discordgo.Message)
- func (c *ManagedChannel) DoNotDeleteMessage(msgID string)
- func (c *ManagedChannel) Enabled() bool
- func (c *ManagedChannel) Export() ManagedChannelMarshal
- func (c *ManagedChannel) GetNextDeletionTime() time.Time
- func (c *ManagedChannel) LoadBacklog() error
- func (c *ManagedChannel) LoadBacklogNow()
- func (c *ManagedChannel) Reap(msgs []string) (int, error)
- func (c *ManagedChannel) SetLiveTime(d time.Duration)
- func (c *ManagedChannel) SetMaxMessages(max int)
- func (c *ManagedChannel) UpdatePins(newLpts string)
- type ManagedChannelMarshal
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommandAdminSay ¶
func CommandAdminHelp(b *Bot, m *discordgo.Message, rest []string) {
plainContent, err := m.ContentWithMoreMentionsReplaced(b.s)
if err != nil {
plainContent = m.Content
}
ch, guild := b.GetMsgChGuild(m)
if guild == nil {
return
}
b.ReportToLogChannel(fmt.Sprintf(
"Adminhelp command from %s (%s#%s) in #%s (ch id %s) of '%s' (guild id %s):\n%s",
m.Author.Mention(), m.Author.Username, m.Author.Discriminator,
ch.Name, m.ChannelID,
guild.Name, guild.ID,
plainContent,
))
}
Types ¶
type Bot ¶
type Bot struct {
Config
// contains filtered or unexported fields
}
func (*Bot) ConnectDiscord ¶
func (*Bot) GetMsgChGuild ¶
func (*Bot) HTTPOAuthCallback ¶
func (b *Bot) HTTPOAuthCallback(w http.ResponseWriter, r *http.Request)
func (*Bot) HTTPOAuthStart ¶
func (b *Bot) HTTPOAuthStart(w http.ResponseWriter, r *http.Request)
func (*Bot) HandleMentions ¶
func (b *Bot) HandleMentions(s *discordgo.Session, m *discordgo.MessageCreate)
func (*Bot) LoadAllBacklogs ¶
func (b *Bot) LoadAllBacklogs()
func (*Bot) LoadChannelConfigs ¶
func (*Bot) OAuthStartURL ¶
func (*Bot) OnChannelCreate ¶
func (b *Bot) OnChannelCreate(s *discordgo.Session, ch *discordgo.ChannelCreate)
func (*Bot) OnChannelPins ¶
func (b *Bot) OnChannelPins(s *discordgo.Session, ev *discordgo.ChannelPinsUpdate)
func (*Bot) QueueLoadBacklog ¶
func (b *Bot) QueueLoadBacklog(c *ManagedChannel, didFail bool)
func (*Bot) QueueReap ¶
func (b *Bot) QueueReap(c *ManagedChannel)
func (*Bot) ReportToLogChannel ¶
func (*Bot) SaveAllChannelConfigs ¶
func (*Bot) SaveChannelConfig ¶
type DiskStorage ¶
type DiskStorage struct {
}
Stores channel configurations on disk as YAML files.
func (*DiskStorage) DeleteChannel ¶
func (s *DiskStorage) DeleteChannel(id string) error
func (*DiskStorage) GetChannel ¶
func (s *DiskStorage) GetChannel(channelID string) (ManagedChannelMarshal, error)
func (*DiskStorage) ListChannels ¶
func (s *DiskStorage) ListChannels() ([]string, error)
func (*DiskStorage) SaveChannel ¶
func (s *DiskStorage) SaveChannel(conf ManagedChannelMarshal) error
type ManagedChannel ¶
type ManagedChannel struct {
Channel *discordgo.Channel
GuildID string
// Messages posted to the channel get deleted after
MessageLiveTime time.Duration
MaxMessages int
KeepMessages []string
// if lower than CriticalMsgSequence, need to send one
LastSentUpdate int
IsDonor bool
// contains filtered or unexported fields
}
func InitChannel ¶
func InitChannel(b *Bot, chConf ManagedChannelMarshal) (*ManagedChannel, error)
func (*ManagedChannel) AddMessage ¶
func (c *ManagedChannel) AddMessage(m *discordgo.Message)
func (*ManagedChannel) DoNotDeleteMessage ¶
func (c *ManagedChannel) DoNotDeleteMessage(msgID string)
DoNotDeleteMessage marks a message ID as not for deletion. only called from UpdatePins()
func (*ManagedChannel) Enabled ¶
func (c *ManagedChannel) Enabled() bool
func (*ManagedChannel) Export ¶
func (c *ManagedChannel) Export() ManagedChannelMarshal
func (*ManagedChannel) GetNextDeletionTime ¶
func (c *ManagedChannel) GetNextDeletionTime() time.Time
func (*ManagedChannel) LoadBacklog ¶
func (c *ManagedChannel) LoadBacklog() error
func (*ManagedChannel) LoadBacklogNow ¶
func (c *ManagedChannel) LoadBacklogNow()
func (*ManagedChannel) SetLiveTime ¶
func (c *ManagedChannel) SetLiveTime(d time.Duration)
func (*ManagedChannel) SetMaxMessages ¶
func (c *ManagedChannel) SetMaxMessages(max int)
func (*ManagedChannel) UpdatePins ¶
func (c *ManagedChannel) UpdatePins(newLpts string)
UpdatePins gets called in two situations - a pin was added, a pin was removed, or more than one of those happened too fast for us to notice.
type ManagedChannelMarshal ¶
type ManagedChannelMarshal struct {
ID string `yaml:"id"`
GuildID string `yaml:"guild_id"`
LiveTime time.Duration `yaml:"live_time"`
MaxMessages int `yaml:"max_messages"`
LastSentUpdate int `yaml:"last_critical_msg"`
HasPins bool `yaml:"has_pins,omitempty"`
IsDonor bool `yaml:"is_donor,omitempty"`
// ConfMessageID is deprecated.
ConfMessageID string `yaml:"conf_message_id,omitempty"`
KeepMessages []string `yaml:"keep_messages"`
}
type Storage ¶
type Storage interface {
ListChannels() ([]string, error)
// Special errors:
// - os.IsNotExist() - no configuration for channel
GetChannel(id string) (ManagedChannelMarshal, error)
SaveChannel(conf ManagedChannelMarshal) error
DeleteChannel(id string) error
}
Interface to the storage systems.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.