command

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2023 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name        string
	Aliases     []string
	Description string

	Category string
	Cache    bool

	HideFromHelp bool
	GroupOnly    bool
	PrivateOnly  bool

	OnlyAdminGroup bool
	OnlyIfBotAdmin bool

	Middleware MiddlewareFunc
	RunFunc    RunFunc
}

func (*Command) Validate

func (c *Command) Validate()

type MiddlewareFunc

type MiddlewareFunc func(c *RunFuncContext) bool

type QuestionState

type QuestionState struct {
	WithEmojiReact bool
	EmojiReact     string
	Separator      string
	RunFuncCtx     *RunFuncContext
	ActiveQuestion string
	Questions      []*Questions
	ResultChan     chan bool
}

func NewUserQuestion

func NewUserQuestion(ctx *RunFuncContext) *QuestionState

NewUserQuestion New user question engine

func (*QuestionState) CaptureMediaQuestion

func (state *QuestionState) CaptureMediaQuestion(question string, answer **waProto.Message) *QuestionState

CaptureMediaQuestion Set a question to capture media object

func (*QuestionState) CaptureQuestion

func (state *QuestionState) CaptureQuestion(question string, answer **waProto.Message) *QuestionState

CaptureQuestion Set a question to capture message object with json string format

func (*QuestionState) Exec

func (state *QuestionState) Exec()

Exec Run question engine without argument parser

func (*QuestionState) ExecWithParser

func (state *QuestionState) ExecWithParser()

ExecWithParser Run question engine with argument parser

func (*QuestionState) NoAskCaptureMediaQuestion

func (state *QuestionState) NoAskCaptureMediaQuestion(answer **waProto.Message) *QuestionState

NoAskCaptureMediaQuestion Set no asking question to capture media object

func (*QuestionState) NoAskCaptureQuestion

func (state *QuestionState) NoAskCaptureQuestion(answer **waProto.Message) *QuestionState

NoAskCaptureQuestion Set no asking question to capture message object with json string format

func (*QuestionState) SetNoAskQuestions

func (state *QuestionState) SetNoAskQuestions(answer any) *QuestionState

SetNoAskQuestions Set no asking question based on question and string answer pointer

func (*QuestionState) SetNoAskReplyQuestion

func (state *QuestionState) SetNoAskReplyQuestion(answer any) *QuestionState

SetNoAskReplyQuestion Set no asking question based on message has a reply string answer pointer

func (*QuestionState) SetParserSeparator

func (state *QuestionState) SetParserSeparator(separator string) *QuestionState

SetParserSeparator Set parser separator for question, eg: /hello world | info [" | " is the separator]

func (*QuestionState) SetQuestion

func (state *QuestionState) SetQuestion(question string, answer any) *QuestionState

SetQuestion Set a question based on question and string answer pointer

func (*QuestionState) SetReplyQuestion

func (state *QuestionState) SetReplyQuestion(question string, answer any) *QuestionState

SetReplyQuestion Set a question based on message has a reply string answer pointer

func (*QuestionState) WithEmoji

func (state *QuestionState) WithEmoji(emoji string) *QuestionState

WithEmoji react custom emoji when user answered a question

func (*QuestionState) WithLikeEmoji

func (state *QuestionState) WithLikeEmoji() *QuestionState

WithLikeEmoji react 👍 when user answered a question

func (*QuestionState) WithOkEmoji

func (state *QuestionState) WithOkEmoji() *QuestionState

WithOkEmoji react 👌 when user answered a question

func (*QuestionState) WithTimeEmoji

func (state *QuestionState) WithTimeEmoji() *QuestionState

WithTimeEmoji react ⏳ when user answered a question

type Questions

type Questions struct {
	Index        int
	Question     string
	HasReplied   bool
	Capture      bool
	CaptureMedia bool
	Reply        bool
	Answer       any
}

func (*Questions) GetAnswer

func (q *Questions) GetAnswer() string

func (*Questions) SetAnswer

func (q *Questions) SetAnswer(answer any)

type RunFunc

type RunFunc func(c *RunFuncContext) *waProto.Message

type RunFuncContext

type RunFuncContext struct {
	FromMe    bool
	ParsedMsg string
	Number    string
	Prefix    string
	Arguments []string

	CurrentCommand *Command
	WaLog          waLog.Logger
	ClientJID      *waTypes.JID
	MessageEvent   *events.Message
	Options        *options.Options
	Message        *waProto.Message
	Client         *whatsmeow.Client
	QuestionChan   chan *QuestionState
	MessageInfo    *waTypes.MessageInfo
	Locals         *skipmap.StringMap[string]
	Ctx            *skipmap.StringMap[types.RoxyContext]
}

func (*RunFuncContext) ByteToMessage

func (runFunc *RunFuncContext) ByteToMessage(value []byte, withReply bool, caption string) *waProto.Message

func (*RunFuncContext) DelLocals

func (runFunc *RunFuncContext) DelLocals(key string)

func (*RunFuncContext) Download

func (runFunc *RunFuncContext) Download(quoted bool) ([]byte, error)

Download message with get quoted message

func (*RunFuncContext) DownloadMessage

func (runFunc *RunFuncContext) DownloadMessage(message *waProto.Message, quoted bool) ([]byte, error)

DownloadMessage download with given message

func (*RunFuncContext) DownloadMessageToFile

func (runFunc *RunFuncContext) DownloadMessageToFile(message *waProto.Message, quoted bool, fileName string) (*os.File, error)

DownloadMessageToFile download with given message to file

func (*RunFuncContext) DownloadToFile

func (runFunc *RunFuncContext) DownloadToFile(quoted bool, fileName string) (*os.File, error)

DownloadToFile download message to file with quoted message

func (*RunFuncContext) EditMessageText

func (runFunc *RunFuncContext) EditMessageText(to string) error

func (*RunFuncContext) FindGroupByJid

func (runFunc *RunFuncContext) FindGroupByJid(groupJid waTypes.JID) (group *waTypes.GroupInfo, err error)

func (*RunFuncContext) FindMessageByID

func (runFunc *RunFuncContext) FindMessageByID(jid waTypes.JID, id string) *events.Message

func (*RunFuncContext) GenerateReplyMessage

func (runFunc *RunFuncContext) GenerateReplyMessage(obj any) *waProto.Message

func (*RunFuncContext) GetAllChats

func (runFunc *RunFuncContext) GetAllChats() []*events.Message

func (*RunFuncContext) GetAllGroups

func (runFunc *RunFuncContext) GetAllGroups() (group []*waTypes.GroupInfo, err error)

func (*RunFuncContext) GetChatInJID

func (runFunc *RunFuncContext) GetChatInJID(jid waTypes.JID) []*events.Message

func (*RunFuncContext) GetClient

func (runFunc *RunFuncContext) GetClient() *whatsmeow.Client

func (*RunFuncContext) GetClientJID

func (runFunc *RunFuncContext) GetClientJID() *waTypes.JID

func (*RunFuncContext) GetCommand

func (runFunc *RunFuncContext) GetCommand() *Command

func (*RunFuncContext) GetDownloadable

func (runFunc *RunFuncContext) GetDownloadable(quoted bool) *waProto.Message

GetDownloadable get downloadable type

func (*RunFuncContext) GetDownloadableMessage

func (runFunc *RunFuncContext) GetDownloadableMessage(message *waProto.Message, quoted bool) *waProto.Message

GetDownloadableMessage get downloadable with given message

func (*RunFuncContext) GetGroupInfo

func (runFunc *RunFuncContext) GetGroupInfo(jid any) (*waTypes.GroupInfo, error)
func (runFunc *RunFuncContext) GetGroupInfoFromInviteLink(link string) (*waTypes.GroupInfo, error)
func (runFunc *RunFuncContext) GetGroupInviteLink(jid any, reset bool) (string, error)

func (*RunFuncContext) GetJoinedGroups

func (runFunc *RunFuncContext) GetJoinedGroups() ([]*waTypes.GroupInfo, error)

func (*RunFuncContext) GetLocals

func (runFunc *RunFuncContext) GetLocals(key string) (string, bool)

func (*RunFuncContext) GetMessage

func (runFunc *RunFuncContext) GetMessage() *waProto.Message

func (*RunFuncContext) GetMessageEvent

func (runFunc *RunFuncContext) GetMessageEvent() *events.Message

func (*RunFuncContext) GetMessageInfo

func (runFunc *RunFuncContext) GetMessageInfo() *waTypes.MessageInfo

func (*RunFuncContext) GetOptions

func (runFunc *RunFuncContext) GetOptions() *options.Options

func (*RunFuncContext) GetProfilePicture

func (runFunc *RunFuncContext) GetProfilePicture(jid any) (string, error)

func (*RunFuncContext) GetStatusMessages

func (runFunc *RunFuncContext) GetStatusMessages() []*events.Message

func (*RunFuncContext) GetUser

func (runFunc *RunFuncContext) GetUser(jid any) (result waTypes.UserInfo, err error)

func (*RunFuncContext) IsClientGroupAdmin

func (runFunc *RunFuncContext) IsClientGroupAdmin() (bool, error)

func (*RunFuncContext) IsGroupAdmin

func (runFunc *RunFuncContext) IsGroupAdmin(jid any) (bool, error)
func (runFunc *RunFuncContext) JoinInviteLink(link string) error

func (*RunFuncContext) RangeLocals

func (runFunc *RunFuncContext) RangeLocals(fun func(key string, value string) bool)

func (*RunFuncContext) RevokeMessage

func (runFunc *RunFuncContext) RevokeMessage(jid waTypes.JID, messageId waTypes.MessageID)

func (*RunFuncContext) SendEmoji

func (runFunc *RunFuncContext) SendEmoji(emoji string)

func (*RunFuncContext) SendMessage

func (runFunc *RunFuncContext) SendMessage(obj any)

func (*RunFuncContext) SendReadPresence

func (runFunc *RunFuncContext) SendReadPresence()

func (*RunFuncContext) SendReplyMessage

func (runFunc *RunFuncContext) SendReplyMessage(obj any)

func (*RunFuncContext) SendTypingPresence

func (runFunc *RunFuncContext) SendTypingPresence(duration time.Duration)

func (*RunFuncContext) SetGroupAnnounce

func (runFunc *RunFuncContext) SetGroupAnnounce(announce bool) error

func (*RunFuncContext) SetGroupLocked

func (runFunc *RunFuncContext) SetGroupLocked(locked bool) error

func (*RunFuncContext) SetGroupName

func (runFunc *RunFuncContext) SetGroupName(name string) error

func (*RunFuncContext) SetGroupPhoto

func (runFunc *RunFuncContext) SetGroupPhoto(data []byte) error

func (*RunFuncContext) SetLocals

func (runFunc *RunFuncContext) SetLocals(key string, value string)

func (*RunFuncContext) SetLocalsWithTTL

func (runFunc *RunFuncContext) SetLocalsWithTTL(key string, value string, ttl time.Duration)

func (*RunFuncContext) SetUserStatus

func (runFunc *RunFuncContext) SetUserStatus(status string) error

func (*RunFuncContext) UpdateClientProfilePicture

func (runFunc *RunFuncContext) UpdateClientProfilePicture(data []byte) error

func (*RunFuncContext) UpdateProfilePicture

func (runFunc *RunFuncContext) UpdateProfilePicture(jid any, data []byte) error

func (*RunFuncContext) UploadAudioFromUrl

func (runFunc *RunFuncContext) UploadAudioFromUrl(url string) (*waProto.AudioMessage, error)

func (*RunFuncContext) UploadAudioMessageFromBytes

func (runFunc *RunFuncContext) UploadAudioMessageFromBytes(bytes []byte) (*waProto.AudioMessage, error)

func (*RunFuncContext) UploadAudioMessageFromPath

func (runFunc *RunFuncContext) UploadAudioMessageFromPath(path string) (*waProto.AudioMessage, error)

func (*RunFuncContext) UploadDocumentFromUrl

func (runFunc *RunFuncContext) UploadDocumentFromUrl(url, title, filename string) (*waProto.DocumentMessage, error)

func (*RunFuncContext) UploadDocumentMessageFromBytes

func (runFunc *RunFuncContext) UploadDocumentMessageFromBytes(bytes []byte, title, filename string) (*waProto.DocumentMessage, error)

func (*RunFuncContext) UploadDocumentMessageFromPath

func (runFunc *RunFuncContext) UploadDocumentMessageFromPath(path, title string) (*waProto.DocumentMessage, error)

func (*RunFuncContext) UploadImageFromUrl

func (runFunc *RunFuncContext) UploadImageFromUrl(url, caption string) (*waProto.ImageMessage, error)

func (*RunFuncContext) UploadImageMessageFromBytes

func (runFunc *RunFuncContext) UploadImageMessageFromBytes(bytes []byte, caption string) (*waProto.ImageMessage, error)

func (*RunFuncContext) UploadImageMessageFromPath

func (runFunc *RunFuncContext) UploadImageMessageFromPath(path, caption string) (*waProto.ImageMessage, error)

func (*RunFuncContext) UploadStickerFromUrl

func (runFunc *RunFuncContext) UploadStickerFromUrl(url string) (*waProto.StickerMessage, error)

func (*RunFuncContext) UploadStickerMessageFromBytes

func (runFunc *RunFuncContext) UploadStickerMessageFromBytes(bytes []byte) (*waProto.StickerMessage, error)

func (*RunFuncContext) UploadStickerMessageFromPath

func (runFunc *RunFuncContext) UploadStickerMessageFromPath(path string) (*waProto.StickerMessage, error)

func (*RunFuncContext) UploadVideoFromUrl

func (runFunc *RunFuncContext) UploadVideoFromUrl(url, caption string) (*waProto.VideoMessage, error)

func (*RunFuncContext) UploadVideoMessageFromBytes

func (runFunc *RunFuncContext) UploadVideoMessageFromBytes(bytes []byte, caption string) (*waProto.VideoMessage, error)

func (*RunFuncContext) UploadVideoMessageFromPath

func (runFunc *RunFuncContext) UploadVideoMessageFromPath(path, caption string) (*waProto.VideoMessage, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL