Documentation ¶
Index ¶
- Constants
- Variables
- func CommandHelp(service Service, command, arguments, help string) []string
- func MatchesCommand(service Service, commandString string, message Message) bool
- func MatchesCommandString(service Service, commandString string, private bool, message string) bool
- func MessageRecover()
- func ParseCommand(service Service, message Message) (string, []string)
- func ParseCommandString(service Service, message string) (string, []string)
- type Bot
- type CommandHelpFunc
- type CommandMessageFunc
- type CommandPlugin
- func (p *CommandPlugin) AddCommand(commandString string, message CommandMessageFunc, help CommandHelpFunc)
- func (p *CommandPlugin) Help(bot *Bot, service Service, message Message, detailed bool) []string
- func (p *CommandPlugin) Load(bot *Bot, service Service, data []byte) error
- func (p *CommandPlugin) Message(bot *Bot, service Service, message Message)
- func (p *CommandPlugin) Name() string
- func (p *CommandPlugin) Save() ([]byte, error)
- func (p *CommandPlugin) Stats(bot *Bot, service Service, message Message) []string
- type Discord
- func (d *Discord) BanUser(channel, userID string, duration int) error
- func (d *Discord) Channel(channelID string) (channel *discordgo.Channel, err error)
- func (d *Discord) ChannelCount() int
- func (d *Discord) CommandPrefix() string
- func (d *Discord) DeleteMessage(channel, messageID string) error
- func (d *Discord) Guild(guildID string) (guild *discordgo.Guild, err error)
- func (d *Discord) Guilds() []*discordgo.Guild
- func (d *Discord) IsBotOwner(message Message) bool
- func (d *Discord) IsChannelOwner(message Message) bool
- func (d *Discord) IsMe(message Message) bool
- func (d *Discord) IsModerator(message Message) bool
- func (d *Discord) IsPrivate(message Message) bool
- func (d *Discord) Join(join string) error
- func (d *Discord) MessageHistory(channel string) []Message
- func (d *Discord) Name() string
- func (d *Discord) Nickname(message Message) string
- func (d *Discord) NicknameForID(userID, userName, channelID string) string
- func (d *Discord) Open() (<-chan Message, error)
- func (d *Discord) PrivateMessage(userID, message string) error
- func (d *Discord) SendAction(channel, message string) error
- func (d *Discord) SendFile(channel, name string, r io.Reader) error
- func (d *Discord) SendMessage(channel, message string) error
- func (d *Discord) SupportsMessageHistory() bool
- func (d *Discord) SupportsMultiline() bool
- func (d *Discord) SupportsPrivateMessages() bool
- func (d *Discord) Typing(channel string) error
- func (d *Discord) UnbanUser(channel, userID string) error
- func (d *Discord) UserChannelPermissions(userID, channelID string) (apermissions int, err error)
- func (d *Discord) UserColor(userID, channelID string) int
- func (d *Discord) UserID() string
- func (d *Discord) UserName() string
- type DiscordMessage
- func (m *DiscordMessage) Channel() string
- func (m *DiscordMessage) Message() string
- func (m *DiscordMessage) MessageID() string
- func (m *DiscordMessage) RawMessage() string
- func (m *DiscordMessage) Type() MessageType
- func (m *DiscordMessage) UserAvatar() string
- func (m *DiscordMessage) UserID() string
- func (m *DiscordMessage) UserName() string
- type HelpFunc
- type IRC
- func (i *IRC) BanUser(channel, userID string, duration int) error
- func (i *IRC) ChannelCount() int
- func (i *IRC) CommandPrefix() string
- func (i *IRC) DeleteMessage(channel, messageID string) error
- func (i *IRC) IsBotOwner(message Message) bool
- func (i *IRC) IsChannelOwner(message Message) bool
- func (i *IRC) IsMe(message Message) bool
- func (i *IRC) IsModerator(message Message) bool
- func (i *IRC) IsPrivate(message Message) bool
- func (i *IRC) Join(join string) error
- func (i *IRC) MessageHistory(channel string) []Message
- func (i *IRC) Name() string
- func (i *IRC) Open() (<-chan Message, error)
- func (i *IRC) PrivateMessage(userID, message string) error
- func (i *IRC) SendAction(channel, message string) error
- func (i *IRC) SendFile(channel, name string, r io.Reader) error
- func (i *IRC) SendMessage(channel, message string) error
- func (i *IRC) SupportsMessageHistory() bool
- func (i *IRC) SupportsMultiline() bool
- func (i *IRC) SupportsPrivateMessages() bool
- func (i *IRC) Typing(channel string) error
- func (i *IRC) UnbanUser(channel, userID string) error
- func (i *IRC) UserID() string
- func (i *IRC) UserName() string
- type IRCMessage
- func (m *IRCMessage) Channel() string
- func (m *IRCMessage) Message() string
- func (m *IRCMessage) MessageID() string
- func (m *IRCMessage) RawMessage() string
- func (m *IRCMessage) Type() MessageType
- func (m *IRCMessage) UserAvatar() string
- func (m *IRCMessage) UserID() string
- func (m *IRCMessage) UserName() string
- type LiveChatMessage
- func (m *LiveChatMessage) Channel() string
- func (m *LiveChatMessage) Message() string
- func (m *LiveChatMessage) MessageID() string
- func (m *LiveChatMessage) RawMessage() string
- func (m *LiveChatMessage) Type() MessageType
- func (m *LiveChatMessage) UserAvatar() string
- func (m *LiveChatMessage) UserID() string
- func (m *LiveChatMessage) UserName() string
- type LoadFunc
- type Message
- type MessageFunc
- type MessageType
- type MockMessage
- func (m *MockMessage) Channel() string
- func (m *MockMessage) Message() string
- func (m *MockMessage) MessageID() string
- func (m *MockMessage) RawMessage() string
- func (m *MockMessage) SetAvatar(avatar string) *MockMessage
- func (m *MockMessage) SetChannel(channel string) *MockMessage
- func (m *MockMessage) SetMessage(message string) *MockMessage
- func (m *MockMessage) SetMessageID(messageID string) *MockMessage
- func (m *MockMessage) SetRawMessage(message string) *MockMessage
- func (m *MockMessage) SetUserID(userid string) *MockMessage
- func (m *MockMessage) SetUserName(username string) *MockMessage
- func (m *MockMessage) Type() MessageType
- func (m *MockMessage) UserAvatar() string
- func (m *MockMessage) UserID() string
- func (m *MockMessage) UserName() string
- type MockService
- func (s *MockService) BanUser(channel, userID string, duration int) error
- func (s *MockService) ChannelCount() int
- func (s *MockService) CommandPrefix() string
- func (s *MockService) DeleteMessage(channel, messageID string) error
- func (s *MockService) IsBotOwner(message Message) bool
- func (s *MockService) IsChannelOwner(message Message) bool
- func (s *MockService) IsMe(message Message) bool
- func (s *MockService) IsModerator(message Message) bool
- func (s *MockService) IsPrivate(message Message) bool
- func (s *MockService) Join(join string) error
- func (s *MockService) MessageHistory(chanel string) []Message
- func (s *MockService) Name() string
- func (s *MockService) NewMessage(message Message)
- func (s *MockService) Open() (<-chan Message, error)
- func (s *MockService) PrivateMessage(userID, messageID string) error
- func (s *MockService) SendAction(channel, message string) error
- func (s *MockService) SendFile(channel, name string, r io.Reader) error
- func (s *MockService) SendMessage(channel, message string) error
- func (m *MockService) SetName(name string) *MockService
- func (m *MockService) SetUserID(userid string) *MockService
- func (m *MockService) SetUserName(username string) *MockService
- func (s *MockService) SupportsMessageHistory() bool
- func (s *MockService) SupportsMultiline() bool
- func (s *MockService) SupportsPrivateMessages() bool
- func (s *MockService) Typing(channel string) error
- func (s *MockService) UnbanUser(channel, userID string) error
- func (s *MockService) UserID() string
- func (s *MockService) UserName() string
- type Plugin
- type SaveFunc
- type Service
- type SimplePlugin
- func (p *SimplePlugin) Help(bot *Bot, service Service, message Message, detailed bool) []string
- func (p *SimplePlugin) Load(bot *Bot, service Service, data []byte) error
- func (p *SimplePlugin) Message(bot *Bot, service Service, message Message)
- func (p *SimplePlugin) Name() string
- func (p *SimplePlugin) Save() ([]byte, error)
- func (p *SimplePlugin) Stats(bot *Bot, service Service, message Message) []string
- type Slack
- func (s *Slack) BanUser(channel, userID string, duration int) error
- func (s *Slack) ChannelCount() int
- func (s *Slack) CommandPrefix() string
- func (s *Slack) DeleteMessage(channel, messageID string) error
- func (s *Slack) IsBotOwner(message Message) bool
- func (s *Slack) IsChannelOwner(message Message) bool
- func (s *Slack) IsMe(message Message) bool
- func (s *Slack) IsModerator(message Message) bool
- func (s *Slack) IsPrivate(message Message) bool
- func (s *Slack) Join(join string) error
- func (s *Slack) MessageHistory(channel string) []Message
- func (s *Slack) Name() string
- func (s *Slack) Open() (<-chan Message, error)
- func (s *Slack) PrivateMessage(userID, message string) error
- func (s *Slack) SendAction(channel, message string) error
- func (s *Slack) SendFile(channel, name string, r io.Reader) error
- func (s *Slack) SendMessage(channel, message string) error
- func (s *Slack) SupportsMessageHistory() bool
- func (s *Slack) SupportsMultiline() bool
- func (s *Slack) SupportsPrivateMessages() bool
- func (s *Slack) Typing(channel string) error
- func (s *Slack) UnbanUser(channel, userID string) error
- func (s *Slack) UserID() string
- func (s *Slack) UserName() string
- type SlackMessage
- func (m *SlackMessage) Channel() string
- func (m *SlackMessage) Message() string
- func (m *SlackMessage) MessageID() string
- func (m *SlackMessage) RawMessage() string
- func (m *SlackMessage) Type() MessageType
- func (m *SlackMessage) UserAvatar() string
- func (m *SlackMessage) UserID() string
- func (m *SlackMessage) UserName() string
- type StatsFunc
- type YTLiveChannel
- type YouTube
- func (yt *YouTube) BanUser(channel, userID string, duration int) error
- func (yt *YouTube) ChannelCount() int
- func (yt *YouTube) ChannelIDForVideoID(videoID string) (channelID string, ok bool)
- func (yt *YouTube) ChannelNameForVideoID(videoID string) string
- func (yt *YouTube) CommandPrefix() string
- func (yt *YouTube) DeleteMessage(channel, messageID string) error
- func (yt *YouTube) GetLiveVideos(channelID string) ([]*youtube.Video, error)
- func (yt *YouTube) GetMe() (*youtube.Channel, error)
- func (yt *YouTube) GetTopLivestreamIDs(count int) ([]string, error)
- func (yt *YouTube) GetTopLivestreams(count int) ([]*youtube.Video, error)
- func (yt *YouTube) GetVideosByIDList(ids []string) ([]*youtube.Video, error)
- func (yt *YouTube) Init() error
- func (yt *YouTube) IsBotOwner(message Message) bool
- func (yt *YouTube) IsChannelOwner(message Message) bool
- func (yt *YouTube) IsMe(message Message) bool
- func (yt *YouTube) IsModerator(message Message) bool
- func (yt *YouTube) IsPrivate(message Message) bool
- func (yt *YouTube) Join(videoID string) error
- func (yt *YouTube) JoinSilent(videoID string) (chan Message, error)
- func (yt *YouTube) JoinVideo(video *youtube.Video) error
- func (yt *YouTube) JoinVideoAnnounce(video *youtube.Video)
- func (yt *YouTube) Leave(videoID string) error
- func (yt *YouTube) LeaveAll(channelID string) error
- func (yt *YouTube) MessageHistory(channel string) []Message
- func (yt *YouTube) Name() string
- func (yt *YouTube) Open() (<-chan Message, error)
- func (yt *YouTube) PrivateMessage(userID, message string) error
- func (yt *YouTube) SendAction(channel, message string) error
- func (yt *YouTube) SendFile(channel, name string, r io.Reader) error
- func (yt *YouTube) SendMessage(channel, message string) error
- func (yt *YouTube) SupportsMessageHistory() bool
- func (yt *YouTube) SupportsMultiline() bool
- func (yt *YouTube) SupportsPrivateMessages() bool
- func (yt *YouTube) Typing(channel string) error
- func (yt *YouTube) UnbanUser(channel, userID string) error
- func (yt *YouTube) UserID() string
- func (yt *YouTube) UserName() string
Constants ¶
const ( // MessageTypeCreate is the message type for message creation. MessageTypeCreate MessageType = "create" // MessageTypeUpdate is the message type for message updates. MessageTypeUpdate = "update" // MessageTypeDelete is the message type for message deletion. MessageTypeDelete = "delete" )
const ( LiveChatMessageSnippetTypeText string = "textMessageEvent" LiveChatMessageSnippetTypeFanFunding string = "fanFundingEvent" )
Enums for LiveMessageSnippet types.
const ( LiveChatBanSnippetTypeTemporary string = "temporary" LiveChatBanSnippetTypePermanent = "permanent" )
Enums for LiveChatBanSnippet types.
const DiscordServiceName string = "Discord"
DiscordServiceName is the service name for the Discord service.
const IRCServiceName string = "IRC"
IRCServiceName is the service name for the IRC service.
const (
LiveChatEndedEvent string = "chatEndedEvent"
)
const SlackServiceName string = "Slack"
SlackServiceName is the service name for the Slack service.
const VersionString string = "0.11"
VersionString is the current version of the bot
const YouTubeServiceName string = "YouTube"
YouTubeServiceName is the service name for the YouTube service.
Variables ¶
var ErrAlreadyJoined = errors.New("Already joined.")
ErrAlreadyJoined is an error dispatched on Join if the bot is already joined to the request.
Functions ¶
func CommandHelp ¶
CommandHelp is a helper message that creates help text for a command. eg. CommandHelp(service, "foo", "<bar>", "Foo bar baz") will return:
!foo <bar> - Foo bar baz
The string is automatatically styled in Discord.
func MatchesCommand ¶
MatchesCommand returns true if a message matches a command.
func MatchesCommandString ¶
MatchesCommandString returns true if a message matches a command. Commands will be matched ignoring case with a prefix if they are not private messages.
func MessageRecover ¶
func MessageRecover()
MessageRecover is the default panic handler for bruxism.
func ParseCommand ¶
ParseCommand parses a message.
Types ¶
type Bot ¶
type Bot struct { Services map[string]*serviceEntry ImgurID string ImgurAlbum string MashableKey string }
Bot enables registering of Services and Plugins.
func (*Bot) Open ¶
func (b *Bot) Open()
Open will open all the current services and begins listening.
func (*Bot) RegisterPlugin ¶
RegisterPlugin registers a plugin on a service.
func (*Bot) RegisterService ¶
RegisterService registers a service with the bot.
type CommandHelpFunc ¶
CommandHelpFunc is the function signature for command help methods.
func NewCommandHelp ¶
func NewCommandHelp(args, help string) CommandHelpFunc
NewCommandHelp creates a new Command Help function.
type CommandMessageFunc ¶
type CommandMessageFunc func(bot *Bot, service Service, message Message, args string, parts []string)
CommandMessageFunc is the function signature for bot message commands.
type CommandPlugin ¶
type CommandPlugin struct {
// contains filtered or unexported fields
}
CommandPlugin is a plugin that can have commands registered and will handle messages matching that command by calling functions.
func NewCommandPlugin ¶
func NewCommandPlugin() *CommandPlugin
NewCommandPlugin will create a new command plugin.
func (*CommandPlugin) AddCommand ¶
func (p *CommandPlugin) AddCommand(commandString string, message CommandMessageFunc, help CommandHelpFunc)
AddCommand adds a command.
func (*CommandPlugin) Help ¶
Help returns a list of help strings that are printed when the user requests them.
func (*CommandPlugin) Load ¶
func (p *CommandPlugin) Load(bot *Bot, service Service, data []byte) error
Load will load plugin state from a byte array.
func (*CommandPlugin) Message ¶
func (p *CommandPlugin) Message(bot *Bot, service Service, message Message)
Message handler. Iterates over the registered commands and executes them if the message matches.
func (*CommandPlugin) Name ¶
func (p *CommandPlugin) Name() string
Name returns the name of the plugin.
func (*CommandPlugin) Save ¶
func (p *CommandPlugin) Save() ([]byte, error)
Save will save plugin state to a byte array.
type Discord ¶
type Discord struct { Shards int // The first session, used to send messages (and maintain backwards compatibility). Session *discordgo.Session Sessions []*discordgo.Session OwnerUserID string ApplicationClientID string // contains filtered or unexported fields }
Discord is a Service provider for Discord.
func NewDiscord ¶
func NewDiscord(args ...interface{}) *Discord
NewDiscord creates a new discord service.
func (*Discord) ChannelCount ¶
ChannelCount returns the number of channels the bot is in.
func (*Discord) CommandPrefix ¶
CommandPrefix returns the command prefix for the service.
func (*Discord) DeleteMessage ¶
DeleteMessage deletes a message.
func (*Discord) IsBotOwner ¶
IsBotOwner returns whether or not a message sender was the owner of the bot.
func (*Discord) IsChannelOwner ¶
IsChannelOwner returns whether or not the sender of a message is a moderator.
func (*Discord) IsModerator ¶
IsModerator returns whether or not the sender of a message is a moderator.
func (*Discord) Join ¶
Join accept an invite or return an error. If AlreadyJoinedError is return, @me has already accepted that invite.
func (*Discord) MessageHistory ¶
MessageHistory returns the message history for a channel.
func (*Discord) NicknameForID ¶
func (*Discord) Open ¶
Open opens the service and returns a channel which all messages will be sent on.
func (*Discord) PrivateMessage ¶
PrivateMessage will send a private message to a user.
func (*Discord) SendAction ¶
SendAction sends an action.
func (*Discord) SendMessage ¶
SendMessage sends a message.
func (*Discord) SupportsMessageHistory ¶
SupportsMessageHistory returns if the service supports message history.
func (*Discord) SupportsMultiline ¶
SupportsMultiline returns whether the service supports multiline messages.
func (*Discord) SupportsPrivateMessages ¶
SupportsPrivateMessages returns whether the service supports private messages.
func (*Discord) UserChannelPermissions ¶
type DiscordMessage ¶
type DiscordMessage struct { Discord *Discord DiscordgoMessage *discordgo.Message MessageType MessageType Nick *string Content *string }
DiscordMessage is a Message wrapper around discordgo.Message.
func (*DiscordMessage) Channel ¶
func (m *DiscordMessage) Channel() string
Channel returns the channel id for this message.
func (*DiscordMessage) Message ¶
func (m *DiscordMessage) Message() string
Message returns the message content for this message.
func (*DiscordMessage) MessageID ¶
func (m *DiscordMessage) MessageID() string
MessageID returns the message ID for this message.
func (*DiscordMessage) RawMessage ¶
func (m *DiscordMessage) RawMessage() string
RawMessage returns the raw message content for this message.
func (*DiscordMessage) Type ¶
func (m *DiscordMessage) Type() MessageType
Type returns the type of message.
func (*DiscordMessage) UserAvatar ¶
func (m *DiscordMessage) UserAvatar() string
UserAvatar returns the avatar url for this message.
func (*DiscordMessage) UserID ¶
func (m *DiscordMessage) UserID() string
UserID returns the user id for this message.
func (*DiscordMessage) UserName ¶
func (m *DiscordMessage) UserName() string
UserName returns the user name for this message.
type IRC ¶
IRC is a Service provider for IRC.
func (*IRC) ChannelCount ¶
ChannelCount returns the number of channels the bot is in.
func (*IRC) CommandPrefix ¶
CommandPrefix returns the command prefix for the service.
func (*IRC) DeleteMessage ¶
DeleteMessage deletes a message.
func (*IRC) IsBotOwner ¶
IsBotOwner returns whether or not a message sender was the owner of the bot.
func (*IRC) IsChannelOwner ¶
IsChannelOwner returns whether or not the sender of a message is the owner.
func (*IRC) IsModerator ¶
IsModerator returns whether or not the sender of a message is a moderator.
func (*IRC) MessageHistory ¶
MessageHistory returns the message history for a channel.
func (*IRC) PrivateMessage ¶
PrivateMessage will send a private message to a user.
func (*IRC) SendAction ¶
SendAction sends an action.
func (*IRC) SendMessage ¶
SendMessage sends a message.
func (*IRC) SupportsMessageHistory ¶
SupportsMessageHistory returns if the service supports message history.
func (*IRC) SupportsMultiline ¶
SupportsMultiline returns whether the service supports multiline messages.
func (*IRC) SupportsPrivateMessages ¶
SupportsPrivateMessages returns whether the service supports private messages.
type IRCMessage ¶
IRCMessage is a Message wrapper around client.Line.
func (*IRCMessage) Channel ¶
func (m *IRCMessage) Channel() string
Channel returns the channel id for this message.
func (*IRCMessage) Message ¶
func (m *IRCMessage) Message() string
Message returns the message content for this message.
func (*IRCMessage) MessageID ¶
func (m *IRCMessage) MessageID() string
MessageID returns the message ID for this message.
func (*IRCMessage) RawMessage ¶
func (m *IRCMessage) RawMessage() string
RawMessage returns the raw message content for this message.
func (*IRCMessage) UserAvatar ¶
func (m *IRCMessage) UserAvatar() string
UserAvatar returns the avatar url for this message.
func (*IRCMessage) UserID ¶
func (m *IRCMessage) UserID() string
UserID returns the user id for this message.
func (*IRCMessage) UserName ¶
func (m *IRCMessage) UserName() string
UserName returns the user name for this message.
type LiveChatMessage ¶
type LiveChatMessage youtube.LiveChatMessage
LiveChatMessage is a Message wrapper around youtube.LiveChatMessage.
func (*LiveChatMessage) Channel ¶
func (m *LiveChatMessage) Channel() string
Channel returns the channel id for this message.
func (*LiveChatMessage) Message ¶
func (m *LiveChatMessage) Message() string
Message returns the message content for this message.
func (*LiveChatMessage) MessageID ¶
func (m *LiveChatMessage) MessageID() string
MessageID returns the message ID for this message.
func (*LiveChatMessage) RawMessage ¶
func (m *LiveChatMessage) RawMessage() string
RawMessage returns the message content for this message.
func (*LiveChatMessage) Type ¶
func (m *LiveChatMessage) Type() MessageType
Type returns the type of message.
func (*LiveChatMessage) UserAvatar ¶
func (m *LiveChatMessage) UserAvatar() string
UserAvatar returns the avatar url for this message.
func (*LiveChatMessage) UserID ¶
func (m *LiveChatMessage) UserID() string
UserID returns the user id for this message.
func (*LiveChatMessage) UserName ¶
func (m *LiveChatMessage) UserName() string
UserName returns the user name for this message.
type Message ¶
type Message interface { Channel() string UserName() string UserID() string UserAvatar() string Message() string RawMessage() string MessageID() string Type() MessageType }
Message is a message interface, wraps a single message from a service.
type MessageFunc ¶
MessageFunc is the function signature for a message handler.
type MessageType ¶
type MessageType string
MessageType is a type used to determine the CRUD state of a message.
type MockMessage ¶
type MockMessage struct {
// contains filtered or unexported fields
}
func NewMockMessage ¶
func NewMockMessage() *MockMessage
func (*MockMessage) Channel ¶
func (m *MockMessage) Channel() string
Satisfy Message interface below
func (*MockMessage) Message ¶
func (m *MockMessage) Message() string
func (*MockMessage) MessageID ¶
func (m *MockMessage) MessageID() string
func (*MockMessage) RawMessage ¶
func (m *MockMessage) RawMessage() string
func (*MockMessage) SetAvatar ¶
func (m *MockMessage) SetAvatar(avatar string) *MockMessage
func (*MockMessage) SetChannel ¶
func (m *MockMessage) SetChannel(channel string) *MockMessage
Functional options to set various properties
func (*MockMessage) SetMessage ¶
func (m *MockMessage) SetMessage(message string) *MockMessage
func (*MockMessage) SetMessageID ¶
func (m *MockMessage) SetMessageID(messageID string) *MockMessage
func (*MockMessage) SetRawMessage ¶
func (m *MockMessage) SetRawMessage(message string) *MockMessage
func (*MockMessage) SetUserID ¶
func (m *MockMessage) SetUserID(userid string) *MockMessage
func (*MockMessage) SetUserName ¶
func (m *MockMessage) SetUserName(username string) *MockMessage
func (*MockMessage) Type ¶
func (m *MockMessage) Type() MessageType
func (*MockMessage) UserAvatar ¶
func (m *MockMessage) UserAvatar() string
func (*MockMessage) UserID ¶
func (m *MockMessage) UserID() string
func (*MockMessage) UserName ¶
func (m *MockMessage) UserName() string
type MockService ¶
type MockService struct {
// contains filtered or unexported fields
}
Service is a service interface, wraps a single service such as YouTube or Discord.
func NewMockService ¶
func NewMockService() *MockService
func (*MockService) BanUser ¶
func (s *MockService) BanUser(channel, userID string, duration int) error
func (*MockService) ChannelCount ¶
func (s *MockService) ChannelCount() int
func (*MockService) CommandPrefix ¶
func (s *MockService) CommandPrefix() string
func (*MockService) DeleteMessage ¶
func (s *MockService) DeleteMessage(channel, messageID string) error
func (*MockService) IsBotOwner ¶
func (s *MockService) IsBotOwner(message Message) bool
func (*MockService) IsChannelOwner ¶
func (s *MockService) IsChannelOwner(message Message) bool
func (*MockService) IsMe ¶
func (s *MockService) IsMe(message Message) bool
func (*MockService) IsModerator ¶
func (s *MockService) IsModerator(message Message) bool
func (*MockService) IsPrivate ¶
func (s *MockService) IsPrivate(message Message) bool
func (*MockService) Join ¶
func (s *MockService) Join(join string) error
func (*MockService) MessageHistory ¶
func (s *MockService) MessageHistory(chanel string) []Message
func (*MockService) Name ¶
func (s *MockService) Name() string
func (*MockService) NewMessage ¶
func (s *MockService) NewMessage(message Message)
func (*MockService) Open ¶
func (s *MockService) Open() (<-chan Message, error)
func (*MockService) PrivateMessage ¶
func (s *MockService) PrivateMessage(userID, messageID string) error
func (*MockService) SendAction ¶
func (s *MockService) SendAction(channel, message string) error
func (*MockService) SendFile ¶
func (s *MockService) SendFile(channel, name string, r io.Reader) error
func (*MockService) SendMessage ¶
func (s *MockService) SendMessage(channel, message string) error
func (*MockService) SetName ¶
func (m *MockService) SetName(name string) *MockService
func (*MockService) SetUserID ¶
func (m *MockService) SetUserID(userid string) *MockService
func (*MockService) SetUserName ¶
func (m *MockService) SetUserName(username string) *MockService
func (*MockService) SupportsMessageHistory ¶
func (s *MockService) SupportsMessageHistory() bool
func (*MockService) SupportsMultiline ¶
func (s *MockService) SupportsMultiline() bool
func (*MockService) SupportsPrivateMessages ¶
func (s *MockService) SupportsPrivateMessages() bool
func (*MockService) Typing ¶
func (s *MockService) Typing(channel string) error
func (*MockService) UnbanUser ¶
func (s *MockService) UnbanUser(channel, userID string) error
func (*MockService) UserID ¶
func (s *MockService) UserID() string
func (*MockService) UserName ¶
func (s *MockService) UserName() string
type Plugin ¶
type Plugin interface { Name() string Load(*Bot, Service, []byte) error Save() ([]byte, error) Help(*Bot, Service, Message, bool) []string Message(*Bot, Service, Message) Stats(*Bot, Service, Message) []string }
Plugin is a plugin interface, supports loading and saving to a byte array and has help and message handlers.
type Service ¶
type Service interface { Name() string UserName() string UserID() string Open() (<-chan Message, error) IsMe(message Message) bool SendMessage(channel, message string) error SendAction(channel, message string) error DeleteMessage(channel, messageID string) error SendFile(channel, name string, r io.Reader) error BanUser(channel, userID string, duration int) error UnbanUser(channel, userID string) error Join(join string) error Typing(channel string) error PrivateMessage(userID, messageID string) error IsBotOwner(message Message) bool IsPrivate(message Message) bool IsChannelOwner(message Message) bool IsModerator(message Message) bool SupportsPrivateMessages() bool SupportsMultiline() bool CommandPrefix() string ChannelCount() int SupportsMessageHistory() bool MessageHistory(chanel string) []Message }
Service is a service interface, wraps a single service such as YouTube or Discord.
type SimplePlugin ¶
type SimplePlugin struct { LoadFunc LoadFunc `json:"-"` SaveFunc SaveFunc `json:"-"` MessageFunc MessageFunc `json:"-"` HelpFunc HelpFunc `json:"-"` StatsFunc StatsFunc `json:"-"` // contains filtered or unexported fields }
SimplePlugin is a simple wrapper around a Plugin that can implement handlers by function reference.
func NewSimplePlugin ¶
func NewSimplePlugin(name string) *SimplePlugin
NewSimplePlugin creates a new simple plugin.
func (*SimplePlugin) Help ¶
Help returns a list of help strings that are printed when the user requests them.
func (*SimplePlugin) Load ¶
func (p *SimplePlugin) Load(bot *Bot, service Service, data []byte) error
Load will load plugin state from a byte array.
func (*SimplePlugin) Message ¶
func (p *SimplePlugin) Message(bot *Bot, service Service, message Message)
Message handler.
func (*SimplePlugin) Name ¶
func (p *SimplePlugin) Name() string
Name returns the name of the plugin.
func (*SimplePlugin) Save ¶
func (p *SimplePlugin) Save() ([]byte, error)
Save will save plugin state to a byte array.
type Slack ¶
type Slack struct { Client *slack.Client RTM *slack.RTM Me *slack.AuthTestResponse OwnerUserID string // contains filtered or unexported fields }
Slack is a Service provider for Slack.
func (*Slack) ChannelCount ¶
ChannelCount returns the number of channels the bot is in.
func (*Slack) CommandPrefix ¶
CommandPrefix returns the command prefix for the service.
func (*Slack) DeleteMessage ¶
DeleteMessage deletes a message.
func (*Slack) IsBotOwner ¶
IsBotOwner returns whether or not a message sender was the owner of the bot.
func (*Slack) IsChannelOwner ¶
IsChannelOwner returns whether or not the sender of a message is the owner.
func (*Slack) IsModerator ¶
IsModerator returns whether or not the sender of a message is a moderator.
func (*Slack) MessageHistory ¶
MessageHistory returns the message history for a channel.
func (*Slack) Open ¶
Open opens the service and returns a channel which all messages will be sent on.
func (*Slack) PrivateMessage ¶
PrivateMessage will send a private message to a user.
func (*Slack) SendAction ¶
SendAction sends an action.
func (*Slack) SendMessage ¶
SendMessage sends a message.
func (*Slack) SupportsMessageHistory ¶
SupportsMessageHistory returns if the service supports message history.
func (*Slack) SupportsMultiline ¶
SupportsMultiline returns whether the service supports multiline messages.
func (*Slack) SupportsPrivateMessages ¶
SupportsPrivateMessages returns whether the service supports private messages.
type SlackMessage ¶
type SlackMessage struct { SlackMessage *slack.Msg MessageType MessageType }
SlackMessage is a Message wrapper around slack.MessageEvent.
func (*SlackMessage) Channel ¶
func (m *SlackMessage) Channel() string
Channel returns the channel id for this message.
func (*SlackMessage) Message ¶
func (m *SlackMessage) Message() string
Message returns the message content for this message.
func (*SlackMessage) MessageID ¶
func (m *SlackMessage) MessageID() string
MessageID returns the message ID for this message.
func (*SlackMessage) RawMessage ¶
func (m *SlackMessage) RawMessage() string
RawMessage returns the raw message content for this message.
func (*SlackMessage) Type ¶
func (m *SlackMessage) Type() MessageType
Type returns the type of message.
func (*SlackMessage) UserAvatar ¶
func (m *SlackMessage) UserAvatar() string
UserAvatar returns the avatar url for this message.
func (*SlackMessage) UserID ¶
func (m *SlackMessage) UserID() string
UserID returns the user id for this message.
func (*SlackMessage) UserName ¶
func (m *SlackMessage) UserName() string
UserName returns the user name for this message.
type YTLiveChannel ¶
YTLiveChannel is a monitor that will send new live videos to a provided channel.
func NewYTLiveChannel ¶
func NewYTLiveChannel(service *youtube.Service) *YTLiveChannel
func (*YTLiveChannel) ChannelName ¶
func (y *YTLiveChannel) ChannelName(channel string) string
func (*YTLiveChannel) Monitor ¶
func (y *YTLiveChannel) Monitor(channel string, liveVideoChan chan *youtube.Video) error
Monitor monitors a channel for new live videos and sends them down liveVideoChan. If the channel is live when this is called, it will not send the video down the channel.
func (*YTLiveChannel) Unmonitor ¶
func (y *YTLiveChannel) Unmonitor(channel string, liveVideoChan chan *youtube.Video) error
UnmonitorAll unmonitors a channel for live videos.
type YouTube ¶
type YouTube struct { Client *http.Client Service *youtube.Service InsertChan chan interface{} DeleteChan chan interface{} // contains filtered or unexported fields }
YouTube is a Service provider for YouTube.
func NewYouTube ¶
NewYouTube creates a new YouTube service.
func (*YouTube) ChannelCount ¶
ChannelCount returns the number of channels the bot is in.
func (*YouTube) ChannelIDForVideoID ¶
ChannelIDForVideoID gets a channelID for a video id.
func (*YouTube) ChannelNameForVideoID ¶
ChannelName gets a channel name for a channel id.
func (*YouTube) CommandPrefix ¶
CommandPrefix returns the command prefix for the service.
func (*YouTube) DeleteMessage ¶
DeleteMessage deletes a message.
func (*YouTube) GetLiveVideos ¶
GetLiveVideos gets a list of live videos for a channel
func (*YouTube) GetTopLivestreamIDs ¶
GetTopLivestreamIDs gets the video ids for the current top livestreams.
func (*YouTube) GetTopLivestreams ¶
GetTopLivestreams gets a list of videos for the current top livestreams.
func (*YouTube) GetVideosByIDList ¶
GetVideosByIDList gets all the videos for a list of video IDs.
func (*YouTube) IsBotOwner ¶
IsBotOwner returns whether or not a message sender was the owner of the bot.
func (*YouTube) IsChannelOwner ¶
IsChannelOwner returns whether or not the sender of a message is the owner.
func (*YouTube) IsModerator ¶
IsModerator returns whether or not the sender of a message is a moderator.
func (*YouTube) JoinSilent ¶
JoinSilent will join a video channel and return a channel of messages. Messages will not be broadcast through the bot.
func (*YouTube) JoinVideo ¶
JoinVideo joins a Video and monitors it for messages on the default message channel.
func (*YouTube) JoinVideoAnnounce ¶
func (yt *YouTube) JoinVideoAnnounce(video *youtube.Video)
JoinVideoAnnounce will join a video like normal, but announce to chat when the bot joins.
func (*YouTube) MessageHistory ¶
MessageHistory returns the message history for a channel.
func (*YouTube) Open ¶
Open opens the service and returns a channel which all messages will be sent on.
func (*YouTube) PrivateMessage ¶
PrivateMessage will send a private message to a user.
func (*YouTube) SendAction ¶
SendAction sends an action.
func (*YouTube) SendMessage ¶
SendMessage sends a message.
func (*YouTube) SupportsMessageHistory ¶
SupportsMessageHistory returns if the service supports message history.
func (*YouTube) SupportsMultiline ¶
SupportsMultiline returns whether the service supports multiline messages.
func (*YouTube) SupportsPrivateMessages ¶
SupportsPrivateMessages returns whether the service supports private messages.