Documentation ¶
Index ¶
Constants ¶
View Source
const Delimiter = ":"
Delimiter between main/sub gateway name in ID (i.e. discord:{CHANNELID})
Variables ¶
View Source
var ( AccessMax = AccessLevel(math.MaxInt32) AccessOwner = AccessLevel(1000) AccessAdmin = AccessLevel(300) AccessOperator = AccessLevel(200) AccessWhitelist = AccessLevel(100) AccessVoice = AccessLevel(1) AccessDefault = AccessLevel(0) AccessIgnore = AccessLevel(-1) AccessKick = AccessLevel(-100) AccessBan = AccessLevel(-200) AccessBlacklist = AccessLevel(-300) AccessMin = AccessLevel(math.MinInt32) ConStrings = []string{"max", "owner", "admin", "operator", "whitelist", "voice", "", "ignore", "kick", "ban", "blacklist", "min"} ConLevels = []AccessLevel{AccessMax, AccessOwner, AccessAdmin, AccessOperator, AccessWhitelist, AccessVoice, AccessDefault, AccessIgnore, AccessKick, AccessBan, AccessBlacklist, AccessMin} )
Access constants
View Source
var ( ErrUnknownEvent = errors.New("gw: Unknown event") ErrUnknownAccess = errors.New("gw: Unknown access level") ErrNoChannel = errors.New("gw: No channel") ErrNoUser = errors.New("gw: No user") ErrNoPermission = errors.New("gw: No permission") ErrNotImplemented = errors.New("gw: Not implemented") )
Errors
View Source
var RelayEvents = []interface{}{ &network.AsyncError{}, &Clear{}, &Connected{}, &Disconnected{}, &SystemMessage{}, &Channel{}, &Chat{}, &PrivateChat{}, &Say{}, &Join{}, &Leave{}, &User{}, }
RelayEvents types
Functions ¶
This section is empty.
Types ¶
type AccessLevel ¶
type AccessLevel int32
AccessLevel for user
func (AccessLevel) MarshalText ¶ added in v0.9.0
func (l AccessLevel) MarshalText() (text []byte, err error)
MarshalText implements encoding.TextMarshaler
func (AccessLevel) String ¶ added in v0.9.0
func (l AccessLevel) String() string
func (*AccessLevel) UnmarshalText ¶ added in v0.9.0
func (l *AccessLevel) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler
type Common ¶ added in v0.9.0
type Common struct {
// contains filtered or unexported fields
}
Common gateway struct
func (*Common) Discriminator ¶ added in v0.9.0
Discriminator tag
type Config ¶ added in v0.9.0
type Config struct {
Commands TriggerConfig
}
Config common struct
func (*Config) FindTrigger ¶ added in v0.9.0
FindTrigger checks if s starts with trigger, return Trigger{} if true
type Gateway ¶
type Gateway interface { network.Emitter network.Listener ID() string SetID(id string) Discriminator() string Channel() *Channel ChannelUsers() []User User(uid string) (*User, error) Users() map[string]AccessLevel SetUserAccess(uid string, a AccessLevel) (*AccessLevel, error) Trigger() string Say(s string) error SayPrivate(uid string, s string) error Kick(uid string) error Ban(uid string) error Unban(uid string) error Ping(uid string) (time.Duration, error) Responder(gw Gateway, uid string, forcePrivate bool) Responder Run(ctx context.Context) error Relay(ev *network.Event, from Gateway) error }
Gateway interface
type Trigger ¶ added in v0.9.0
Trigger event
func FindTrigger ¶ added in v0.9.0
FindTrigger checks if s starts with trigger t, return Trigger{} if true
type TriggerConfig ¶ added in v0.9.0
type TriggerConfig struct { Trigger string Access AccessLevel RespondPrivate bool }
TriggerConfig for commands
type User ¶
type User struct { ID string Name string Access AccessLevel AvatarURL string }
User struct
func FindUserInChannel ¶ added in v0.9.0
FindUserInChannel finds user(s) by pattern
Click to show internal directories.
Click to hide internal directories.