context

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReleaseCtx

func ReleaseCtx(c *Ctx)

Types

type Ctx

type Ctx struct {
	// contains filtered or unexported fields
}

func AcquireCtx

func AcquireCtx() *Ctx

func NewCtx

func NewCtx(locals *xsync.MapOf[string, string]) *Ctx

func (*Ctx) AddMemberToGroup

func (context *Ctx) AddMemberToGroup(jids []waTypes.JID) error

AddMemberToGroup add members from group

func (*Ctx) Arguments

func (context *Ctx) Arguments() []string

func (*Ctx) ByteToMessage

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

ByteToMessage convert byte to whatsmeow message object

func (*Ctx) ChatJID

func (context *Ctx) ChatJID() waTypes.JID

func (*Ctx) Client

func (context *Ctx) Client() *whatsmeow.Client

func (*Ctx) ClientJID

func (context *Ctx) ClientJID() waTypes.JID

func (*Ctx) DelLocals

func (context *Ctx) DelLocals(key string)

func (*Ctx) DemoteMemberInGroup

func (context *Ctx) DemoteMemberInGroup(jids []waTypes.JID) error

DemoteMemberInGroup kick a member from group

func (*Ctx) Download

func (context *Ctx) Download(quoted bool) ([]byte, error)

Download message with get quoted message

func (*Ctx) DownloadMessage

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

DownloadMessage download with given message

func (*Ctx) DownloadMessageToFile

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

DownloadMessageToFile download with given message to file

func (*Ctx) DownloadToFile

func (context *Ctx) DownloadToFile(quoted bool, fileName string) (*os.File, error)

DownloadToFile download message to file with quoted message

func (*Ctx) EditMessageText

func (context *Ctx) EditMessageText(to string) error

EditMessageText edit current text message to given text

func (*Ctx) FindGroupByJid

func (context *Ctx) FindGroupByJid(groupJid waTypes.JID) (group *waTypes.GroupInfo, err error)

FindGroupByJid find group by jid from cache

func (*Ctx) FindMessageByID

func (context *Ctx) FindMessageByID(jid waTypes.JID, id string) *events.Message

FindMessageByID find message by specific id from local store

func (*Ctx) FromMe

func (context *Ctx) FromMe() bool

func (*Ctx) GenerateReplyMessage

func (context *Ctx) GenerateReplyMessage(obj any) *waProto.Message

GenerateReplyMessage generate reply message to whatsmeow message object

func (*Ctx) GetAllChats

func (context *Ctx) GetAllChats() []*events.Message

GetAllChats get all chats from local store

func (*Ctx) GetAllGroups

func (context *Ctx) GetAllGroups() (group []*waTypes.GroupInfo, err error)

GetAllGroups get all groups from cache

func (*Ctx) GetChatInJID

func (context *Ctx) GetChatInJID(jid waTypes.JID) []*events.Message

GetChatInJID get chats in jid from local store

func (*Ctx) GetDownloadable

func (context *Ctx) GetDownloadable(quoted bool) *waProto.Message

GetDownloadable get downloadable type

func (*Ctx) GetDownloadableMessage

func (context *Ctx) GetDownloadableMessage(message *waProto.Message, quoted bool) *waProto.Message

GetDownloadableMessage get downloadable with given message

func (*Ctx) GetGroupInfo

func (context *Ctx) GetGroupInfo(jid any) (*waTypes.GroupInfo, error)

GetGroupInfo get group info from cache

func (context *Ctx) GetGroupInfoFromInviteLink(link string) (*waTypes.GroupInfo, error)

GetGroupInfoFromInviteLink get group info from invite link

func (context *Ctx) GetGroupInviteLink(jid any) (string, error)

GetGroupInviteLink get current group invite link

func (*Ctx) GetGroupProfilePicture

func (context *Ctx) GetGroupProfilePicture(jid any) (string, error)

GetGroupProfilePicture get group profile picture

func (*Ctx) GetJoinedGroups

func (context *Ctx) GetJoinedGroups() ([]*waTypes.GroupInfo, error)

GetJoinedGroups get client joined group from cache

func (*Ctx) GetLocals

func (context *Ctx) GetLocals(key string) (string, bool)

func (*Ctx) GetStatusMessages

func (context *Ctx) GetStatusMessages() []*events.Message

GetStatusMessages get client statuses from local store

func (*Ctx) GetUserInfo

func (context *Ctx) GetUserInfo(jid any) (result waTypes.UserInfo, err error)

GetUserInfo get contact user info from cache

func (*Ctx) IsClientGroupAdmin

func (context *Ctx) IsClientGroupAdmin() (bool, error)

IsClientGroupAdmin check if client is a group admin

func (*Ctx) IsGroupAdmin

func (context *Ctx) IsGroupAdmin(jid any) (bool, error)

IsGroupAdmin check is target jid are group admin

func (context *Ctx) JoinGroupInviteLink(link string) error

JoinGroupInviteLink join a group invite link

func (*Ctx) LeaveFromGroup

func (context *Ctx) LeaveFromGroup(jid waTypes.JID) error

LeaveFromGroup leave group from given jid

func (*Ctx) LeaveFromThisGroup

func (context *Ctx) LeaveFromThisGroup() error

LeaveFromThisGroup leave from this group chat

func (*Ctx) Logger

func (context *Ctx) Logger() waLog.Logger

func (*Ctx) Message

func (context *Ctx) Message() *waProto.Message

func (*Ctx) MessageEvent

func (context *Ctx) MessageEvent() *events.Message

func (*Ctx) MessageInfo

func (context *Ctx) MessageInfo() waTypes.MessageInfo

func (*Ctx) Methods

func (context *Ctx) Methods() types.ClientMethods

func (*Ctx) NewPollingState

func (context *Ctx) NewPollingState() *PollingState

func (*Ctx) NewUserQuestion

func (context *Ctx) NewUserQuestion() *QuestionState

NewUserQuestion New user question engine

func (*Ctx) Number

func (context *Ctx) Number() string

func (*Ctx) Options

func (context *Ctx) Options() *options.Options

func (*Ctx) ParsedMsg

func (context *Ctx) ParsedMsg() string

func (*Ctx) Prefix

func (context *Ctx) Prefix() string

func (*Ctx) PromoteMemberInGroup

func (context *Ctx) PromoteMemberInGroup(jids []waTypes.JID) error

PromoteMemberInGroup kick a member from group

func (*Ctx) RangeLocals

func (context *Ctx) RangeLocals(fun func(key string, value string) bool)

func (*Ctx) RemoveMemberFromGroup

func (context *Ctx) RemoveMemberFromGroup(jids []waTypes.JID) error

RemoveMemberFromGroup kick members from group

func (*Ctx) RevokeGroupInvite

func (context *Ctx) RevokeGroupInvite() (string, error)

RevokeGroupInvite revoke current group invite link

func (*Ctx) RevokeMessage

func (context *Ctx) RevokeMessage(jid waTypes.JID, messageId waTypes.MessageID)

RevokeMessage revoke message from given jid and client message id

func (*Ctx) SendEmoji

func (context *Ctx) SendEmoji(emoji string)

SendEmoji send emoji to current text message

func (*Ctx) SendMessage

func (context *Ctx) SendMessage(obj any)

func (*Ctx) SendReadPresence

func (context *Ctx) SendReadPresence()

SendReadPresence send read status in current chat

func (*Ctx) SendReplyMessage

func (context *Ctx) SendReplyMessage(obj any)

SendReplyMessage send reply message in current chat

func (*Ctx) SendTypingPresence

func (context *Ctx) SendTypingPresence(duration time.Duration)

SendTypingPresence send typing action in current chat

func (*Ctx) SenderJID

func (context *Ctx) SenderJID() waTypes.JID

func (*Ctx) SetClient

func (context *Ctx) SetClient(client *whatsmeow.Client)

func (*Ctx) SetClientJID

func (context *Ctx) SetClientJID(jid waTypes.JID)

func (*Ctx) SetClientMethods

func (context *Ctx) SetClientMethods(clientMethods types.ClientMethods)

func (*Ctx) SetGroupAnnounce

func (context *Ctx) SetGroupAnnounce(announce bool) error

SetGroupAnnounce set group announce info

func (*Ctx) SetGroupLocked

func (context *Ctx) SetGroupLocked(locked bool) error

SetGroupLocked set current group to locked

func (*Ctx) SetGroupName

func (context *Ctx) SetGroupName(name string) error

SetGroupName set current group name

func (*Ctx) SetGroupPhoto

func (context *Ctx) SetGroupPhoto(data []byte) error

SetGroupPhoto set current group photo

func (*Ctx) SetLocals

func (context *Ctx) SetLocals(key string, value string)

func (*Ctx) SetLocalsWithTTL

func (context *Ctx) SetLocalsWithTTL(key string, value string, ttl time.Duration)

func (*Ctx) SetLogger

func (context *Ctx) SetLogger(logger waLog.Logger)

func (*Ctx) SetMessageEvent

func (context *Ctx) SetMessageEvent(evt *events.Message)

func (*Ctx) SetOptions

func (context *Ctx) SetOptions(options *options.Options)

func (*Ctx) SetParsedMsg

func (context *Ctx) SetParsedMsg(parsedMsg string)

func (*Ctx) SetPollingChan

func (context *Ctx) SetPollingChan(pooling chan *PollingState)

func (*Ctx) SetPrefix

func (context *Ctx) SetPrefix(prefix string)

func (*Ctx) SetQuestionChan

func (context *Ctx) SetQuestionChan(question chan *QuestionState)

func (*Ctx) SetUserStatus

func (context *Ctx) SetUserStatus(status string) error

SetUserStatus set client status

func (*Ctx) UpdateClientProfilePicture

func (context *Ctx) UpdateClientProfilePicture(data []byte) error

UpdateClientProfilePicture update client profile picture

func (*Ctx) UpdateGroupProfilePicture

func (context *Ctx) UpdateGroupProfilePicture(jid any, data []byte) error

UpdateGroupProfilePicture update group profile picture

func (*Ctx) UploadAudioFromUrl

func (context *Ctx) UploadAudioFromUrl(url string) (*waProto.AudioMessage, error)

UploadAudioFromUrl upload audio from given url

func (*Ctx) UploadAudioMessageFromBytes

func (context *Ctx) UploadAudioMessageFromBytes(bytes []byte) (*waProto.AudioMessage, error)

UploadAudioMessageFromBytes upload audio from given bytes

func (*Ctx) UploadAudioMessageFromPath

func (context *Ctx) UploadAudioMessageFromPath(path string) (*waProto.AudioMessage, error)

UploadAudioMessageFromPath upload audio message from given path

func (*Ctx) UploadBytesMedia

func (context *Ctx) UploadBytesMedia(bytes []byte, vars map[string]string) (any, error)

UploadBytesMedia upload bytes media based from mimetype

func (*Ctx) UploadDocumentFromUrl

func (context *Ctx) UploadDocumentFromUrl(url, title, filename string) (*waProto.DocumentMessage, error)

UploadDocumentFromUrl upload document from given url

func (*Ctx) UploadDocumentMessageFromBytes

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

UploadDocumentMessageFromBytes upload document from given bytes

func (*Ctx) UploadDocumentMessageFromPath

func (context *Ctx) UploadDocumentMessageFromPath(path, title string) (*waProto.DocumentMessage, error)

UploadDocumentMessageFromPath upload document from given path

func (*Ctx) UploadImageFromUrl

func (context *Ctx) UploadImageFromUrl(url, caption string) (*waProto.ImageMessage, error)

UploadImageFromUrl upload image from given url

func (*Ctx) UploadImageMessageFromBytes

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

UploadImageMessageFromBytes upload image from given bytes

func (*Ctx) UploadImageMessageFromPath

func (context *Ctx) UploadImageMessageFromPath(path, caption string) (*waProto.ImageMessage, error)

UploadImageMessageFromPath upload a image from given path

func (*Ctx) UploadMediaFromUrl

func (context *Ctx) UploadMediaFromUrl(url string, vars map[string]string) (any, error)

UploadMediaFromUrl upload media detected from mimetype

func (*Ctx) UploadStickerFromUrl

func (context *Ctx) UploadStickerFromUrl(url string) (*waProto.StickerMessage, error)

UploadStickerFromUrl upload sticker from given url

func (*Ctx) UploadStickerMessageFromBytes

func (context *Ctx) UploadStickerMessageFromBytes(bytes []byte) (*waProto.StickerMessage, error)

UploadStickerMessageFromBytes upload sticker from given bytes

func (*Ctx) UploadStickerMessageFromPath

func (context *Ctx) UploadStickerMessageFromPath(path string) (*waProto.StickerMessage, error)

UploadStickerMessageFromPath upload sticker from given path

func (*Ctx) UploadVideoFromUrl

func (context *Ctx) UploadVideoFromUrl(url, caption string) (*waProto.VideoMessage, error)

UploadVideoFromUrl upload video from given url

func (*Ctx) UploadVideoMessageFromBytes

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

UploadVideoMessageFromBytes upload video from given bytes

func (*Ctx) UploadVideoMessageFromPath

func (context *Ctx) UploadVideoMessageFromPath(path, caption string) (*waProto.VideoMessage, error)

UploadVideoMessageFromPath upload video from given path

type MiddlewareFunc

type MiddlewareFunc func(c *Ctx) bool

type PollingOptions

type PollingOptions struct {
	Options string
	Hashed  []byte
}

type PollingState

type PollingState struct {
	PollId         string
	PollName       string
	PollOptions    []PollingOptions
	PollSelectable int
	PollingTimeout *time.Duration
	Ctx            *Ctx
	PollWithRevoke bool
	PollingResult  []string
	ResultChan     chan bool
}

func NewPollingState

func NewPollingState(context *Ctx) *PollingState

func (*PollingState) Exec

func (p *PollingState) Exec() []string

func (*PollingState) SetOnlyOnePool

func (p *PollingState) SetOnlyOnePool() *PollingState

func (*PollingState) SetPollInformation

func (p *PollingState) SetPollInformation(name string, options []string) *PollingState

func (*PollingState) SetSelectableOption

func (p *PollingState) SetSelectableOption(count int) *PollingState

func (*PollingState) SetTimeBasedType

func (p *PollingState) SetTimeBasedType(timeOut time.Duration) *PollingState

func (*PollingState) WithRevoke

func (p *PollingState) WithRevoke() *PollingState

type QuestionState

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

func NewUserQuestion

func NewUserQuestion(context *Ctx) *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 *Ctx) *waProto.Message

Jump to

Keyboard shortcuts

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