aboutsummaryrefslogtreecommitdiff
path: root/connector/external
diff options
context:
space:
mode:
Diffstat (limited to 'connector/external')
-rw-r--r--connector/external/external.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/connector/external/external.go b/connector/external/external.go
index 9aae0f1..92339b9 100644
--- a/connector/external/external.go
+++ b/connector/external/external.go
@@ -51,10 +51,12 @@ const (
LEAVE = "leave"
SEARCH = "search"
SEND = "send"
+ USER_COMMAND = "user_command"
CLOSE = "close"
// external -> ezbr
SAVE_CONFIG = "save_config"
+ SYSTEM_MESSAGE = "system_message"
JOINED = "joined"
LEFT = "left"
USER_INFO_UPDATED = "user_info_updated"
@@ -249,7 +251,7 @@ func (m *extMessageWithData) UnmarshalJSON(jj []byte) error {
}
m.Data = sr.Data
return nil
- case JOINED, LEFT, CACHE_PUT, CACHE_GET, REP_OK, REP_ERROR:
+ case SYSTEM_MESSAGE, JOINED, LEFT, CACHE_PUT, CACHE_GET, REP_OK, REP_ERROR:
return nil
default:
return fmt.Errorf("Invalid message type for message from external program: '%s'", c.MsgType)
@@ -377,6 +379,8 @@ func (ext *External) handleCmd(msg *extMessageWithData) {
switch msg.MsgType {
case SAVE_CONFIG:
ext.handler.SaveConfig(msg.Data.(Configuration))
+ case SYSTEM_MESSAGE:
+ ext.handler.SystemMessage(msg.Value)
case JOINED:
ext.handler.Joined(msg.Room)
case LEFT:
@@ -475,3 +479,10 @@ func (ext *External) Send(event *Event) (string, error) {
}
return rep.EventId, nil
}
+
+func (ext *External) UserCommand(cm string) {
+ ext.cmd(extMessage{
+ MsgType: USER_COMMAND,
+ Value: cm,
+ }, nil)
+}