CommandMeta
Filters and aliases for a command. Declared via the optional ModuleWithMeta interface:
go
func (m *Weather) CommandMetas() map[string]goroku.CommandMeta {
return map[string]goroku.CommandMeta{
"weather": {
Aliases: []string{"w"},
OnlyOwner: true,
},
}
}The dispatcher applies these before your handler runs. A command whose filters do not match simply does not fire.
The same struct configures watchers through WatcherMetas(), matched positionally to the slice returned by Watchers().
Naming
| Field | Type | Effect |
|---|---|---|
Alias | string | A single alternative name |
Aliases | []string | Several alternative names |
Aliases share one namespace with command names across all modules. A collision fails registration rather than shadowing silently.
Who
| Field | Effect |
|---|---|
OnlyOwner | Only the account owner. Identity only — ignores sudo, masks and temporary grants |
FromID | []int64 of allowed sender IDs |
Where
| Field | Effect |
|---|---|
OnlyPM | Only private chats |
NoPM | Never in private chats |
OnlyGroups | Only groups |
OnlyChannels | Only channels |
OnlyChats | Only non-private chats |
ChatID | []int64 of allowed chat IDs |
Attachments
| Field | Effect |
|---|---|
OnlyMedia | Require any attachment |
OnlyPhotos | Require a photo |
OnlyVideos | Require a video |
OnlyAudios | Require audio |
OnlyDocs | Require a document |
OnlyStickers | Require a sticker |
NoMedia | Reject any attachment |
NoStickers | Reject stickers |
NoAudio | Reject audio |
NoDoc | Reject documents |
Message shape
| Field | Effect |
|---|---|
OnlyReply | Require a replied-to message |
NoReply | Reject replies |
NoForwarded | Reject forwarded messages |
Mention | Require a mention |
NoMention | Reject mentions |
OnlyCommands | Only messages that are commands |
NoCommands | Reject commands |
OnlyInline | Only via inline |
NoInline | Reject inline |
Editable | Only messages this account can edit |
Content
| Field | Type | Effect |
|---|---|---|
Regex | string | Text must match. Compiled at registration; an invalid pattern fails registration |
StartsWith | string | Text must start with this |
EndsWith | string | Text must end with this |
Contains | string | Text must contain this |
Other
| Field | Type | Effect |
|---|---|---|
Ratelimit | bool | Apply per-user and per-chat rate limits |
Filter | func(*Message) bool | Arbitrary predicate; runs last |
go
"weather": {
Filter: func(msg *goroku.Message) bool {
return len(msg.Text) < 200
},
},Combining
All set fields must pass — they are ANDed.
go
"purge": {
Aliases: []string{"p"},
OnlyGroups: true,
OnlyReply: true,
NoForwarded: true,
Ratelimit: true,
},.purge now fires only in a group, only as a reply, never on a forwarded message, and is rate-limited.