Skip to content

Commit

Permalink
Calls AI
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 committed Apr 26, 2024
1 parent eb3c3f0 commit 76b29f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const (
WSCallLoweredHandEvent EventType = "WSCallLoweredHand"
WSCallScreenOnEvent EventType = "WSCallScreenOn"
WSCallScreenOffEvent EventType = "WSCallScreenOff"
WSSummonAIEvent EventType = "WSSummonAI"
WSAIPostUpdateEvent EventType = "WSAIPostUpdate"
)

func (e EventType) IsValid() bool {
Expand All @@ -58,7 +60,9 @@ func (e EventType) IsValid() bool {
WSCallRaisedHandEvent, WSCallLoweredHandEvent,
WSCallScreenOnEvent, WSCallScreenOffEvent,
WSCallJobStateEvent,
WSJobStopEvent:
WSJobStopEvent,
WSSummonAIEvent,
WSAIPostUpdateEvent:
return true
default:
return false
Expand Down
11 changes: 11 additions & 0 deletions client/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const (
wsEventUserScreenOn = wsEvPrefix + "user_screen_on"
wsEventUserScreenOff = wsEvPrefix + "user_screen_off"
wsEventUserReacted = wsEvPrefix + "user_reacted"
wsEventSummonAI = wsEvPrefix + "summon_ai"
wsEventAIPostUpdate = "custom_mattermost-ai_postupdate"
)

var (
Expand Down Expand Up @@ -295,6 +297,15 @@ func (c *Client) handleWSMsg(msg ws.Message) error {
evType = WSCallScreenOffEvent
}
c.emit(evType, sessionID)
case wsEventSummonAI:
channelID, _ := ev.GetData()["channel_id"].(string)
if channelID != c.cfg.ChannelID {
return nil
}
authToken, _ := ev.GetData()["auth_token"].(string)
c.emit(WSSummonAIEvent, authToken)
case wsEventAIPostUpdate:
c.emit(WSAIPostUpdateEvent, ev.GetData())
default:
}
case ws.BinaryMessage:
Expand Down

0 comments on commit 76b29f7

Please sign in to comment.