(new): rich message support
(fix): runtime reliability (tests): regression coverage (doc): v1.1 release notes
This commit is contained in:
+12
-1
@@ -93,6 +93,7 @@ type Command[T AppData] struct {
|
||||
args extypes.Slice[CommandArg] // List of expected arguments
|
||||
middlewares extypes.Slice[Middleware[T]] // Optional middleware chain
|
||||
skipAutoCmd bool // If true, this command won't be auto-added to help menus
|
||||
isEphemeral bool
|
||||
}
|
||||
|
||||
// NewCommand creates a new Command with the given identifier, executor, and arguments.
|
||||
@@ -108,7 +109,9 @@ type Command[T AppData] struct {
|
||||
// that fit Telegram's callback_data limit, though the configured payload
|
||||
// encoding may impose its own restrictions.
|
||||
func NewCommand[T any](command string, exec CommandExecutor[T], args ...CommandArg) *Command[T] {
|
||||
return &Command[T]{command, "", exec, args, make(extypes.Slice[Middleware[T]], 0), false}
|
||||
return &Command[T]{
|
||||
command, "", exec, args, make(extypes.Slice[Middleware[T]], 0), false, false,
|
||||
}
|
||||
}
|
||||
|
||||
// Use adds a middleware to the command's execution chain.
|
||||
@@ -130,6 +133,14 @@ func (c *Command[T]) SkipCommandAutoGen() *Command[T] {
|
||||
return c
|
||||
}
|
||||
|
||||
// SetEphemeral controls whether Telegram treats the command as ephemeral.
|
||||
//
|
||||
// Since: Bot API 10.2
|
||||
func (c *Command[T]) SetEphemeral(b bool) *Command[T] {
|
||||
c.isEphemeral = b
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Command[T]) validateArgs(args []string) error {
|
||||
for i := range c.args.Len() {
|
||||
if i >= len(args) && c.args.Get(i).required {
|
||||
|
||||
Reference in New Issue
Block a user