Skip to content

Commit

Permalink
support CHANNEL_TOPIC_CHANGED event
Browse files Browse the repository at this point in the history
  • Loading branch information
wtks committed May 9, 2019
1 parent 11505dc commit f02a430
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions event_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ type ChannelCreatedPayload struct {
Channel ChannelPayload `json:"channel"`
}

// ChannelTopicChangedPayload CHANNEL_TOPIC_CHANGEDイベントペイロード
type ChannelTopicChangedPayload struct {
BasePayload
// Channel 変更されたチャンネル
Channel ChannelPayload `json:"channel"`
// Topic 変更後のトピック
Topic string `json:"topic"`
// Updater トピック更新者
Updater UserPayload `json:"updater"`
}

// UserCreatedPayload USER_CREATEDイベントペイロード
type UserCreatedPayload struct {
BasePayload
Expand Down
2 changes: 2 additions & 0 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
DirectMessageCreated = "DIRECT_MESSAGE_CREATED"
// ChannelCreated CHANNEL_CREATEDイベント
ChannelCreated = "CHANNEL_CREATED"
// ChannelTopicChanged CHANNEL_TOPIC_CHANGEDイベント
ChannelTopicChanged = "CHANNEL_TOPIC_CHANGED"
// UserCreated USER_CREATEDイベント
UserCreated = "USER_CREATED"
)
5 changes: 5 additions & 0 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func (hs EventHandlers) SetChannelCreatedHandler(h func(payload *ChannelCreatedP
hs.SetHandler(ChannelCreated, func(event string, payload interface{}) { h(payload.(*ChannelCreatedPayload)) })
}

// SetChannelTopicChangedHandler イベントハンドラをセットします
func (hs EventHandlers) SetChannelTopicChangedHandler(h func(payload *ChannelTopicChangedPayload)) {
hs.SetHandler(ChannelTopicChanged, func(event string, payload interface{}) { h(payload.(*ChannelTopicChangedPayload)) })
}

// SetUserCreatedHandler イベントハンドラをセットします
func (hs EventHandlers) SetUserCreatedHandler(h func(payload *UserCreatedPayload)) {
hs.SetHandler(UserCreated, func(event string, payload interface{}) { h(payload.(*UserCreatedPayload)) })
Expand Down
2 changes: 2 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (bs *BotServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
payload = &DirectMessageCreatedPayload{}
case ChannelCreated:
payload = &ChannelCreatedPayload{}
case ChannelTopicChanged:
payload = &ChannelTopicChangedPayload{}
case UserCreated:
payload = &UserCreatedPayload{}
default:
Expand Down

0 comments on commit f02a430

Please sign in to comment.