ext

package
v1.0.0-my-beta35 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// raw tg client which will be used make send requests.
	Raw *tg.Client
	// self user who authorized the session.
	Self *tg.User
	// Sender is a message sending helper.
	Sender *message.Sender
	// Entities consists of mapped users, chats and channels from the update.
	Entities *tg.Entities
	// original context of the client.
	context.Context

	PeerStorage *storage.PeerStorage
	// contains filtered or unexported fields
}

Context consists of context.Context, tg.Client, Self etc.

func NewContext

func NewContext(ctx context.Context, client *tg.Client, peerStorage *storage.PeerStorage, self *tg.User, sender *message.Sender, entities *tg.Entities, setReply bool) *Context

NewContext creates a new Context object with provided parameters.

func (*Context) AddChatMembers

func (ctx *Context) AddChatMembers(chatId int64, userIds []int64, forwardLimit int) (bool, error)

AddChatMembers is used to add members to a chat

func (*Context) AnswerCallback

func (ctx *Context) AnswerCallback(request *tg.MessagesSetBotCallbackAnswerRequest) (bool, error)

AnswerCallback invokes method messages.setBotCallbackAnswer#d58f130a returning error if any. Set the callback answer to a user button press

func (*Context) ArchiveChats

func (ctx *Context) ArchiveChats(chatIds []int64) (bool, error)

ArchiveChats invokes method folders.editPeerFolders#6847d0ab returning error if any. Edit peers in peer folder¹

Links:

  1. https://core.telegram.org/api/folders#peer-folders

func (*Context) BanChatMember

func (ctx *Context) BanChatMember(chatId, userId int64, untilDate int) (tg.UpdatesClass, error)

BanChatMember is used to ban a user from a chat.

func (*Context) CreateChannel

func (ctx *Context) CreateChannel(title, about string, broadcast bool) (*tg.Channel, error)

CreateChannel invokes method channels.createChannel#3d5fb10f returning error if any. Create a supergroup/channel¹.

Links:

  1. https://core.telegram.org/api/channel

func (*Context) CreateChat

func (ctx *Context) CreateChat(title string, userIds []int64) (*tg.Chat, error)

CreateChat invokes method messages.createChat#9cb126e returning error if any. Creates a new chat.

func (*Context) DeleteMessages

func (ctx *Context) DeleteMessages(chatId int64, messageIDs []int) error

DeleteMessages shall be used to delete messages in a chat with chatId and messageIDs. Returns error if failed to delete.

func (*Context) DemoteChatMember

func (ctx *Context) DemoteChatMember(chatId, userId int64, opts *EditAdminOpts) (bool, error)

DemoteChatMember is used to demote a user in a chat.

func (*Context) EditMessage

func (ctx *Context) EditMessage(chatId int64, request *tg.MessagesEditMessageRequest) (*types.Message, error)

EditMessage invokes method messages.editMessage#48f71778 returning error if any. Edit message

func (*Context) ExportSessionString

func (ctx *Context) ExportSessionString() (string, error)

ExportSessionString returns session of authorized account in the form of string. Note: This session string can be used to log back in with the help of gotgproto. Check sessionMaker.SessionType for more information about it.

func (*Context) ForwardMediaGroup

func (ctx *Context) ForwardMediaGroup() error

func (*Context) ForwardMessage deprecated

func (ctx *Context) ForwardMessage(fromChatId, toChatId int64, request *tg.MessagesForwardMessagesRequest) (tg.UpdatesClass, error)

ForwardMessage shall be used to forward messages in a chat with chatId and messageIDs. Returns updatesclass or an error if failed to delete.

Deprecated: use ForwardMessages instead.

func (*Context) ForwardMessages

func (ctx *Context) ForwardMessages(fromChatId, toChatId int64, request *tg.MessagesForwardMessagesRequest) (tg.UpdatesClass, error)

ForwardMessages shall be used to forward messages in a chat with chatId and messageIDs. Returns updatesclass or an error if failed to delete.

func (*Context) GetChat

func (ctx *Context) GetChat(chatId int64) (tg.ChatFullClass, error)

GetChat returns tg.ChatFullClass of the provided chat id.

func (*Context) GetInlineBotResults

func (ctx *Context) GetInlineBotResults(chatId int64, botUsername string, request *tg.MessagesGetInlineBotResultsRequest) (*tg.MessagesBotResults, error)

func (*Context) GetMessages

func (ctx *Context) GetMessages(chatId int64, messageIds []tg.InputMessageClass) ([]tg.MessageClass, error)

GetMessages is used to fetch messages from a PM (Private Chat).

func (*Context) GetUser

func (ctx *Context) GetUser(userId int64) (*tg.UserFull, error)

GetUser returns tg.UserFull of the provided user id.

func (*Context) GetUserProfilePhotos

func (ctx *Context) GetUserProfilePhotos(userId int64, opts *tg.PhotosGetUserPhotosRequest) ([]tg.PhotoClass, error)

GetUserProfilePhotos invokes method photos.getUserPhotos#91cd32a8 returning error if any. Returns the list of user photos.

func (*Context) PromoteChatMember

func (ctx *Context) PromoteChatMember(chatId, userId int64, opts *EditAdminOpts) (bool, error)

PromoteChatMember is used to promote a user in a chat.

func (*Context) Reply

func (ctx *Context) Reply(upd *Update, text interface{}, opts *ReplyOpts) (*types.Message, error)

Reply uses given message update to create message for same chat and create a reply. Parameter 'text' interface should be one from string or an array of styling.StyledTextOption.

func (*Context) ResolveUsername

func (ctx *Context) ResolveUsername(username string) (types.EffectiveChat, error)

ResolveUsername invokes method contacts.resolveUsername#f93ccba3 returning error if any. Resolve a @username to get peer info

func (*Context) SendInlineBotResult

func (ctx *Context) SendInlineBotResult(chatId int64, request *tg.MessagesSendInlineBotResultRequest) (tg.UpdatesClass, error)

SendInlineBotResult invokes method messages.sendInlineBotResult#7aa11297 returning error if any. Send a result obtained using messages.getInlineBotResults¹.

func (*Context) SendMedia

func (ctx *Context) SendMedia(chatId int64, request *tg.MessagesSendMediaRequest) (*types.Message, error)

SendMedia invokes method messages.sendMedia#e25ff8e0 returning error if any. Send a media

func (*Context) SendMessage

func (ctx *Context) SendMessage(chatId int64, request *tg.MessagesSendMessageRequest) (*types.Message, error)

SendMessage invokes method messages.sendMessage#d9d75a4 returning error if any.

func (*Context) SendMultiMedia

func (ctx *Context) SendMultiMedia(chatId int64, request *tg.MessagesSendMultiMediaRequest) (*types.Message, error)

SendMultiMedia invokes method messages.sendMultiMedia#f803138f returning error if any. Send an album or grouped media¹

func (*Context) SendReaction

func (ctx *Context) SendReaction(chatId int64, request *tg.MessagesSendReactionRequest) (*types.Message, error)

SendReaction invokes method messages.sendReaction#25690ce4 returning error if any.

func (*Context) SetInlineBotResult

func (ctx *Context) SetInlineBotResult(request *tg.MessagesSetInlineBotResultsRequest) (bool, error)

SetInlineBotResult invokes method messages.setInlineBotResults#eb5ea206 returning error if any. Answer an inline query, for bots only

func (*Context) UnarchiveChats

func (ctx *Context) UnarchiveChats(chatIds []int64) (bool, error)

UnarchiveChats invokes method folders.editPeerFolders#6847d0ab returning error if any. Edit peers in peer folder¹

Links:

  1. https://core.telegram.org/api/folders#peer-folders

func (*Context) UnbanChatMember

func (ctx *Context) UnbanChatMember(chatId, userId int64) (bool, error)

UnbanChatMember is used to unban a user from a chat.

type EditAdminOpts

type EditAdminOpts struct {
	AdminRights tg.ChatAdminRights
	AdminTitle  string
}

type ReplyOpts

type ReplyOpts struct {
	// Whether the message should show link preview or not.
	NoWebpage bool
	// Reply markup of a message, i.e. inline keyboard buttons etc.
	Markup           tg.ReplyMarkupClass
	ReplyToMessageId int
}

ReplyOpts object contains optional parameters for Context.Reply.

type Update

type Update struct {
	// EffectiveMessage is the tg.Message of current update.
	EffectiveMessage *types.Message
	// CallbackQuery is the tg.UpdateBotCallbackQuery of current update.
	CallbackQuery *tg.UpdateBotCallbackQuery
	// InlineQuery is the tg.UpdateInlineBotCallbackQuery of current update.
	InlineQuery *tg.UpdateBotInlineQuery
	// ChatJoinRequest is the tg.UpdatePendingJoinRequests of current update.
	ChatJoinRequest *tg.UpdatePendingJoinRequests
	// ChatParticipant is the tg.UpdateChatParticipant of current update.
	ChatParticipant *tg.UpdateChatParticipant
	// ChannelParticipant is the tg.UpdateChannelParticipant of current update.
	ChannelParticipant *tg.UpdateChannelParticipant
	// UpdateClass is the current update in raw form.
	UpdateClass tg.UpdateClass
	// Entities of an update, i.e. mapped users, chats and channels.
	Entities *tg.Entities
}

Update contains all the data related to an update.

func GetNewUpdate

func GetNewUpdate(ctx context.Context, client *tg.Client, p *storage.PeerStorage, e *tg.Entities, update tg.UpdateClass) *Update

GetNewUpdate creates a new Update with provided parameters.

func (*Update) Args

func (u *Update) Args() []string

func (*Update) EffectiveChat

func (u *Update) EffectiveChat() types.EffectiveChat

EffectiveChat returns the responsible EffectiveChat for the current update.

func (*Update) EffectiveUser

func (u *Update) EffectiveUser() *tg.User

EffectiveUser returns the tg.User who is responsible for the update.

func (*Update) GetChannel

func (u *Update) GetChannel() *tg.Channel

GetChannel returns the responsible tg.Channel for the current update.

func (*Update) GetChat

func (u *Update) GetChat() *tg.Chat

GetChat returns the responsible tg.Chat for the current update.

func (*Update) GetUserChat

func (u *Update) GetUserChat() *tg.User

GetUserChat returns the responsible tg.User for the current update.

Jump to

Keyboard shortcuts

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