diff --git a/stable/chat/v1/messages.proto b/stable/chat/v1/messages.proto index 59ead8a..6118760 100644 --- a/stable/chat/v1/messages.proto +++ b/stable/chat/v1/messages.proto @@ -30,37 +30,11 @@ message Overrides { } } -// The payload sent to the bot when an action is triggered. -message ActionPayload { - // The payload data for a button action. - message Button { - // The data from the Button action. - bytes data = 1; - } - // The payload for a dropdown action. - message Dropdown { - // The user choice from the dropdown. - bytes choice = 1; - } - // The payload for a text input action. - message Input { - // The user input. - string input = 1; - // The bot-provided data. - bytes data = 2; - } - // The payload data. - oneof payload { - // Payload for a button. - Button button = 1; - // Payload for a dropdown. - Dropdown dropdown = 2; - // Payload for a text input. - Input input = 3; - } -} - -// Actions are interactive elements that can exist within an embed. +// Actions are interactive elements that can exist within a message. +// They can be only sent by bots; servers should ignore actions created by users. +// +// Servers MUST verify that the action data sent by an user is valid for that action +// before sending it to the bot. message Action { // The action type. This is primarily used to change the look of the action to // the user (example: Destructive actions will have a red background). @@ -78,14 +52,11 @@ message Action { // The text to show on the button. string text = 1; - // Action data, which should be used in the call to perform the action. - bytes data = 2; - // An external URL that the button links to. // // This makes it so that tapping this button will open said URL instead // of triggering the action. - optional string url = 3; + optional string url = 2; } // A dropdown menu that users can click on to trigger an action. @@ -111,21 +82,24 @@ message Action { string label = 1; // Whether this text input should be a multiline one or not. bool multiline = 2; - // Contextual data allowing the bot to discern what the user input is for. - bytes data = 3; + // The default text that should be pre-filled in the text field. + optional string default = 3; } // Type of the action. Type action_type = 1; + // Contextual info allowing the bot to discern what the action is for. + // The info of an action cannot be the same with the info of another action in the same message. + bytes info = 2; // The kind of the action. oneof kind { // Button action. - Button button = 2; + Button button = 3; // Dropdown action. - Dropdown dropdown = 3; + Dropdown dropdown = 4; // Input action. - Input input = 4; + Input input = 5; } } @@ -440,6 +414,8 @@ message Message { Content content = 7; // The reactions of the message. repeated Reaction reactions = 8; + // Bot actions to show on this message. + repeated Action actions = 9; } // Object representing a message with it's ID. @@ -537,8 +513,11 @@ message TriggerActionRequest { uint64 channel_id = 2; // Message ID of the message you want to trigger an action in. uint64 message_id = 3; - // Payload of action data. - ActionPayload payload = 4; + // Data that alllows the bot to discern which action the user is trying to trigger. + // A server MUST verify that this info refers to a valid action for the target message. + bytes info = 4; + // Payload of action data. Ignored if this is a button action. + optional bytes payload = 5; } // Used in the `TriggerAction` endpoint. message TriggerActionResponse {} @@ -604,6 +583,8 @@ message SendMessageRequest { optional Overrides overrides = 6; // The message this new message is a reply to. optional uint64 in_reply_to = 7; + // Actions to send on this message. Ignored if the message is not sent by a bot. + repeated Action actions = 8; // The metadata of this new message. optional harmonytypes.v1.Metadata metadata = 5; } diff --git a/stable/chat/v1/stream.proto b/stable/chat/v1/stream.proto index 66bc899..bb1223f 100644 --- a/stable/chat/v1/stream.proto +++ b/stable/chat/v1/stream.proto @@ -230,8 +230,10 @@ message StreamEvent { uint64 message_id = 3; // User ID of the user that triggered the action uint64 user_id = 4; + // The custom info set by the bot + optional bytes info = 5; // The action data payload - ActionPayload payload = 5; + optional bytes payload = 6; } // Event sent when a role's position in the role list is changed.