Skip to content

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

FieldTypeEffect
AliasstringA single alternative name
Aliases[]stringSeveral alternative names

Aliases share one namespace with command names across all modules. A collision fails registration rather than shadowing silently.

Who

FieldEffect
OnlyOwnerOnly the account owner. Identity only — ignores sudo, masks and temporary grants
FromID[]int64 of allowed sender IDs

Where

FieldEffect
OnlyPMOnly private chats
NoPMNever in private chats
OnlyGroupsOnly groups
OnlyChannelsOnly channels
OnlyChatsOnly non-private chats
ChatID[]int64 of allowed chat IDs

Attachments

FieldEffect
OnlyMediaRequire any attachment
OnlyPhotosRequire a photo
OnlyVideosRequire a video
OnlyAudiosRequire audio
OnlyDocsRequire a document
OnlyStickersRequire a sticker
NoMediaReject any attachment
NoStickersReject stickers
NoAudioReject audio
NoDocReject documents

Message shape

FieldEffect
OnlyReplyRequire a replied-to message
NoReplyReject replies
NoForwardedReject forwarded messages
MentionRequire a mention
NoMentionReject mentions
OnlyCommandsOnly messages that are commands
NoCommandsReject commands
OnlyInlineOnly via inline
NoInlineReject inline
EditableOnly messages this account can edit

Content

FieldTypeEffect
RegexstringText must match. Compiled at registration; an invalid pattern fails registration
StartsWithstringText must start with this
EndsWithstringText must end with this
ContainsstringText must contain this

Other

FieldTypeEffect
RatelimitboolApply per-user and per-chat rate limits
Filterfunc(*Message) boolArbitrary 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.

Released under the GNU AGPL v3 License.