Documentation ¶
Index ¶
- Constants
- Variables
- type Channel
- func (c *Channel) Ban(uid string) error
- func (c *Channel) Channel() *gateway.Channel
- func (c *Channel) ChannelUsers() []gateway.User
- func (c *Channel) FindTrigger(s string) *gateway.Trigger
- func (c *Channel) Kick(uid string) error
- func (c *Channel) Ping(uid string) (time.Duration, error)
- func (c *Channel) Relay(ev *network.Event, from gateway.Gateway) error
- func (c *Channel) Run(ctx context.Context) error
- func (c *Channel) Say(s string) error
- func (c *Channel) SayPrivate(uid string, s string) error
- func (c *Channel) SetUserAccess(uid string, a gateway.AccessLevel) (*gateway.AccessLevel, error)
- func (c *Channel) Unban(uid string) error
- func (c *Channel) User(uid string) (*gateway.User, error)
- func (c *Channel) Users() map[string]gateway.AccessLevel
- func (c *Channel) WebhookOrSay(p *discordgo.WebhookParams) error
- type ChannelConfig
- type Config
- type Gateway
- func (d *Gateway) Ban(uid string) error
- func (d *Gateway) Channel() *gateway.Channel
- func (d *Gateway) ChannelUsers() []gateway.User
- func (d *Gateway) InitDefaultHandlers()
- func (d *Gateway) Kick(uid string) error
- func (d *Gateway) Ping(uid string) (time.Duration, error)
- func (d *Gateway) Relay(ev *network.Event, from gateway.Gateway) error
- func (d *Gateway) Run(ctx context.Context) error
- func (d *Gateway) Say(s string) error
- func (d *Gateway) SayPrivate(uid string, s string) error
- func (d *Gateway) SetUserAccess(uid string, a gateway.AccessLevel) (*gateway.AccessLevel, error)
- func (d *Gateway) Unban(uid string) error
- func (d *Gateway) User(uid string) (*gateway.User, error)
- func (d *Gateway) Users() map[string]gateway.AccessLevel
- type RelayJoinMode
Constants ¶
const ( RelayJoinsSay = 1 << iota RelayJoinsList RelayJoinsBoth = RelayJoinsSay | RelayJoinsList )
RelayJoins
Variables ¶
var ( ErrSayBufferFull = errors.New("gw-discord: Say buffer full") ErrInvalidGuild = errors.New("gw-discord: Invalid guild ID") )
Errors
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { gateway.Common network.EventEmitter // Set once before Run(), read-only after that *ChannelConfig // contains filtered or unexported fields }
Channel manages a Discord channel
func NewChannel ¶ added in v0.9.1
func NewChannel(s *discordgo.Session, conf *ChannelConfig) (*Channel, error)
NewChannel initializes a new Channel struct
func (*Channel) ChannelUsers ¶ added in v0.9.0
ChannelUsers online
func (*Channel) FindTrigger ¶ added in v0.9.0
FindTrigger checks if s starts with trigger, return Trigger{} if true
func (*Channel) SayPrivate ¶ added in v0.9.0
SayPrivate sends a private chat message to uid
func (*Channel) SetUserAccess ¶ added in v0.9.0
func (c *Channel) SetUserAccess(uid string, a gateway.AccessLevel) (*gateway.AccessLevel, error)
SetUserAccess overrides accesslevel for a specific user
func (*Channel) Users ¶ added in v0.9.0
func (c *Channel) Users() map[string]gateway.AccessLevel
Users with non-default access level
func (*Channel) WebhookOrSay ¶
func (c *Channel) WebhookOrSay(p *discordgo.WebhookParams) error
WebhookOrSay sends a chat message preferably via webhook
type ChannelConfig ¶
type ChannelConfig struct { gateway.Config ChannelID string Webhook string OnlineListID string BufSize uint8 RelayJoins RelayJoinMode AccessMentions gateway.AccessLevel AccessTalk gateway.AccessLevel AccessRole map[string]gateway.AccessLevel AccessUser map[string]gateway.AccessLevel }
ChannelConfig stores the configuration of a single Discord channel
type Config ¶
type Config struct { gateway.Config AuthToken string Channels map[string]*ChannelConfig Presence string AccessDM gateway.AccessLevel AccessUser map[string]gateway.AccessLevel }
Config stores the configuration of a Discord session
type Gateway ¶
type Gateway struct { gateway.Common network.EventEmitter *discordgo.Session // Set once before Run(), read-only after that *Config Channels map[string]*Channel // contains filtered or unexported fields }
Gateway manages a Discord connection
func (*Gateway) ChannelUsers ¶ added in v0.9.0
ChannelUsers online
func (*Gateway) InitDefaultHandlers ¶
func (d *Gateway) InitDefaultHandlers()
InitDefaultHandlers adds the default callbacks for relevant packets
func (*Gateway) Relay ¶
Relay placeholder to implement Gateway interface Events should instead be relayed directly to a Channel
func (*Gateway) SayPrivate ¶ added in v0.9.0
SayPrivate sends a private chat message to uid
func (*Gateway) SetUserAccess ¶ added in v0.9.0
func (d *Gateway) SetUserAccess(uid string, a gateway.AccessLevel) (*gateway.AccessLevel, error)
SetUserAccess overrides accesslevel for a specific user
type RelayJoinMode ¶
type RelayJoinMode int32
RelayJoinMode enum
func (RelayJoinMode) MarshalText ¶ added in v0.9.0
func (r RelayJoinMode) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler
func (RelayJoinMode) String ¶ added in v0.9.0
func (r RelayJoinMode) String() string
func (*RelayJoinMode) UnmarshalText ¶ added in v0.9.0
func (r *RelayJoinMode) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler