Documentation ¶
Index ¶
- type CLIResponseWriter
- type CommandRequest
- type MessageHandler
- type MessageRouter
- func (mr *MessageRouter) BuildResponseWriter(msg *slack.Msg) ResponseWriter
- func (mr *MessageRouter) GetUsername(msg *slack.Msg) (string, error)
- func (mr *MessageRouter) Handle(cmdString string, fn MessageHandler) error
- func (mr *MessageRouter) ProcessMessage(msg *slack.Msg) error
- func (mr *MessageRouter) Run()
- type ResponseWriter
- type SlackResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLIResponseWriter ¶
type CLIResponseWriter struct { }
CLIResponseWriter handles writing to the command line
func (*CLIResponseWriter) Write ¶
func (w *CLIResponseWriter) Write(text string) error
Write writes to CLI
func (*CLIResponseWriter) WriteChannel ¶
func (w *CLIResponseWriter) WriteChannel(channel string, text string) error
Write writes to CLI, prints channel it would go to if via Slack
func (*CLIResponseWriter) WriteError ¶
func (w *CLIResponseWriter) WriteError(errText string) error
WriteError writes error to CLI
type MessageHandler ¶
type MessageHandler func(*CommandRequest, ResponseWriter) error
MessageHandler responds to a slack or cli message request.
type MessageRouter ¶
type MessageRouter struct { API *slack.Client RTM *slack.RTM IsDev bool // contains filtered or unexported fields }
MessageRouter does stuff with messages.
func New ¶
func New(token, gittag, channel string, spamchannel string) *MessageRouter
New Returns a new Puddle Messagerouter
func (*MessageRouter) BuildResponseWriter ¶
func (mr *MessageRouter) BuildResponseWriter(msg *slack.Msg) ResponseWriter
BuildResponseWriter checks the MessageRouter and returns the appropriate response writer
func (*MessageRouter) GetUsername ¶
func (mr *MessageRouter) GetUsername(msg *slack.Msg) (string, error)
GetUsername retrieves human readable username information from SLACK API using Slack username ID
func (*MessageRouter) Handle ¶
func (mr *MessageRouter) Handle(cmdString string, fn MessageHandler) error
Handle registers the handler for the given command, or register a standard message parsing function Must match a command prefix, `!` for admin commands, `%` for general commands & `#` for MUD commands For functions that will parse all messages (sans command prefix), the cmdString must equal "*"
func (*MessageRouter) ProcessMessage ¶
func (mr *MessageRouter) ProcessMessage(msg *slack.Msg) error
ProcessMessage performs basic routing on Slack messages in the channel #puddle Eventually, this will feed into two routers One for admin commands & one for mud commands
func (*MessageRouter) Run ¶
func (mr *MessageRouter) Run()
type ResponseWriter ¶
type SlackResponseWriter ¶
type SlackResponseWriter struct {
// contains filtered or unexported fields
}
func NewSlackResponseWriter ¶
func NewSlackResponseWriter(msg *slack.Msg, rtm *slack.RTM) *SlackResponseWriter
func (*SlackResponseWriter) Msg ¶
func (w *SlackResponseWriter) Msg(msg *slack.Msg)
Msg sets the SlackResponseWriter Message
func (*SlackResponseWriter) Rtm ¶
func (w *SlackResponseWriter) Rtm(rtm *slack.RTM)
Msg sets the SlackResponseWriter RTM
func (*SlackResponseWriter) Write ¶
func (w *SlackResponseWriter) Write(text string) error
Write writes to Slack
func (*SlackResponseWriter) WriteChannel ¶
func (w *SlackResponseWriter) WriteChannel(channel string, text string) error
WriteChannel sends message to particular channel
func (*SlackResponseWriter) WriteError ¶
func (w *SlackResponseWriter) WriteError(errText string) error
WriteError writes an error to Slack