I think things are pretty good
This commit is contained in:
@@ -24,6 +24,8 @@ type BotModel struct {
|
||||
|
||||
messageWatchers map[string]func(msg BotMessage) bool
|
||||
rtmWatchers map[string]func(event *slack.RTMEvent) bool
|
||||
|
||||
Running bool
|
||||
}
|
||||
|
||||
func NewBotModel(debug bool) (*BotModel, error) {
|
||||
@@ -60,7 +62,9 @@ func (m *BotModel) DebugRTMWatcher(event *slack.RTMEvent) bool {
|
||||
}
|
||||
|
||||
func (m *BotModel) SendMessage(msg BotMessage) {
|
||||
fmt.Println("Sending:", msg)
|
||||
if m.debug {
|
||||
fmt.Println("Sending:", msg)
|
||||
}
|
||||
m.messages <- msg
|
||||
}
|
||||
|
||||
@@ -72,11 +76,8 @@ func (m *BotModel) AddRTMWatcher(name string, watcher func(event *slack.RTMEvent
|
||||
}
|
||||
|
||||
func (m *BotModel) ProcessMessageChannel() {
|
||||
fmt.Println(">> ProcessMessageChannel")
|
||||
msg := <-m.messages
|
||||
fmt.Println(">>>> Received Message", msg)
|
||||
for k, v := range m.messageWatchers {
|
||||
fmt.Printf(">>>> Message Watcher [%s]\n", k)
|
||||
for _, v := range m.messageWatchers {
|
||||
// Pass the message to the watcher
|
||||
if v != nil && v(msg) {
|
||||
// if a watcher returns true, the message was consumed
|
||||
@@ -85,11 +86,8 @@ func (m *BotModel) ProcessMessageChannel() {
|
||||
}
|
||||
}
|
||||
func (m *BotModel) ProcessRTMChannel() {
|
||||
fmt.Println(">> ProcessRTMChannel")
|
||||
msg := <-m.otherRTMEvents
|
||||
fmt.Println(">>>> Received Message", msg)
|
||||
for k, v := range m.rtmWatchers {
|
||||
fmt.Printf(">>>> RTM Watcher [%s]\n", k)
|
||||
for _, v := range m.rtmWatchers {
|
||||
// Pass the event to the watcher
|
||||
if v(msg) {
|
||||
// if a watcher returns true, the message was consumed
|
||||
|
Reference in New Issue
Block a user