v0.12.1
Added Ephemeral
flag to Ctx
. When this is set to true, all subsequent responses and follow-up messages sent with this context will carry the Ephemeral
Message Flag. This will make the command response only visible to the user who invokes the command.
Also added an interface ResponsePolicyCommand
which defines a method retuning a response policy for the given command.
This
ResponsePolicy
object is also subject to be extended in further versions.
// ResponsePolicyCommand defines a command which
// provides a ResponsePolicy.
type ResponsePolicyCommand interface {
ResponsePolicy() ResponsePolicy
}
You can now set the EphemeralCommand
implementation as anonymous field in your command structure to make all responses of this command ephemeral.
type MyCommand struct {
EphemeralCommand
}
This is what the EphemeralCommand
implementaiton looks like.
// EphemeralCommand can be added to your command
// to make all command responses ephemeral.
// This means, that all responses to the command
// from the bot will only be received by the sender
// of the command.
type EphemeralCommand struct{}
var _ ResponsePolicyCommand = (*EphemeralCommand)(nil)
func (EphemeralCommand) ResponsePolicy() ResponsePolicy {
return ResponsePolicy{
Ephemeral: true,
}
}
Acknowledgements
Thanks a lot to @zordem who brought it to my attention that this message flag exists.