-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(interface/chat_bot): improve chat bot interface (#160)
- Loading branch information
Showing
2 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: placeos-driver | ||
version: 6.6.1 | ||
version: 6.6.2 | ||
crystal: ">= 1.0.0" | ||
|
||
dependencies: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,56 @@ | ||
require "json" | ||
|
||
abstract class PlaceOS::Driver | ||
module Interface::ChatBot | ||
# drivers are expected to emit door state events on | ||
# channel security/event/door | ||
class Message | ||
# NOTE:: expects messages to broadcast to a channel, such as: chat/<bot_name>/<org_id>/message | ||
|
||
struct Id | ||
include JSON::Serializable | ||
|
||
def initialize(@message_id, @room_id = nil, @user_id = nil, @org_id = nil) | ||
end | ||
|
||
# something used to identify the message | ||
property message_id : String | ||
|
||
# The room ID of the message. | ||
@[JSON::Field(key: "roomId")] | ||
property room_id : String | ||
property room_id : String? | ||
|
||
# The user who sent the message | ||
property user_id : String? | ||
|
||
# The org sending the message. | ||
property org_id : String? | ||
end | ||
|
||
struct Message | ||
include JSON::Serializable | ||
|
||
def initialize(@id, @text) | ||
end | ||
|
||
property id : Id | ||
|
||
# The message, in plain text. | ||
@[JSON::Field(key: "text")] | ||
property text : String | ||
end | ||
|
||
struct Attachment | ||
include JSON::Serializable | ||
|
||
def initialize(@name, @payload) | ||
end | ||
|
||
property name : String | ||
|
||
# Base64 encoded binary contents | ||
property payload : String | ||
end | ||
|
||
# allows a bot responder to indicate it is replying to a message | ||
abstract def notify_typing(id : Id) | ||
|
||
# interface used to reply to a message | ||
abstract def reply(id : Id, response : String, url : String? = nil, attachment : Attachment? = nil) | ||
end | ||
end |