Documentation ¶
Overview ¶
Package message contains some useful utilities for creating Telegram messages.
Code generated by mktyping, DO NOT EDIT.
Index ¶
- Constants
- type AnswerableMessageUpdate
- type AudioDocumentBuilder
- func (u *AudioDocumentBuilder) Duration(duration time.Duration) *AudioDocumentBuilder
- func (u *AudioDocumentBuilder) DurationSeconds(duration int) *AudioDocumentBuilder
- func (u *AudioDocumentBuilder) Performer(performer string) *AudioDocumentBuilder
- func (u *AudioDocumentBuilder) Title(title string) *AudioDocumentBuilder
- func (u *AudioDocumentBuilder) Voice() *AudioDocumentBuilder
- func (u *AudioDocumentBuilder) Waveform(waveform []byte) *AudioDocumentBuilder
- type Builder
- func (b *Builder) Album(ctx context.Context, media MultiMediaOption, album ...MultiMediaOption) (tg.UpdatesClass, error)
- func (b *Builder) Audio(ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) Background() *Builder
- func (b *Builder) Basketball(ctx context.Context) (tg.UpdatesClass, error)
- func (b *Builder) Bowling(ctx context.Context) (tg.UpdatesClass, error)
- func (b *Builder) Casino(ctx context.Context) (tg.UpdatesClass, error)
- func (b *Builder) Clear() *Builder
- func (b *Builder) ClearDraft(ctx context.Context) error
- func (b *Builder) Darts(ctx context.Context) (tg.UpdatesClass, error)
- func (b *Builder) Dice(ctx context.Context) (tg.UpdatesClass, error)
- func (b *Builder) Document(ctx context.Context, file FileLocation, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) DocumentByHash(ctx context.Context, hash []byte, size int64, mime string, ...) (tg.UpdatesClass, error)
- func (b *Builder) DocumentExternal(ctx context.Context, url string, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) Edit(id int) *EditMessageBuilder
- func (b *Builder) File(ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) Football(ctx context.Context) (tg.UpdatesClass, error)
- func (b *Builder) ForwardIDs(from tg.InputPeerClass, id int, ids ...int) *ForwardBuilder
- func (b *Builder) ForwardMessages(from tg.InputPeerClass, msg tg.MessageClass, m ...tg.MessageClass) *ForwardBuilder
- func (b *Builder) GIF(ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) InlineResult(ctx context.Context, id string, queryID int64, hideVia bool) (tg.UpdatesClass, error)
- func (b *Builder) Markup(m tg.ReplyMarkupClass) *Builder
- func (b *Builder) Media(ctx context.Context, media MediaOption) (tg.UpdatesClass, error)
- func (b *Builder) NoForwards() *Builder
- func (b *Builder) NoWebpage() *Builder
- func (b *Builder) Photo(ctx context.Context, photo FileLocation, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) PhotoExternal(ctx context.Context, url string, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) Reply(id int) *Builder
- func (b *Builder) ReplyMsg(msg tg.MessageClass) *Builder
- func (b *Builder) RoundVideo(ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) Row(buttons ...tg.KeyboardButtonClass) *Builder
- func (b *Builder) SaveDraft(ctx context.Context, msg string) error
- func (b *Builder) SaveStyledDraft(ctx context.Context, texts ...StyledTextOption) error
- func (b *Builder) Schedule(date time.Time) *Builder
- func (b *Builder) ScheduleTS(date int) *Builder
- func (b *Builder) SendAs(p tg.InputPeerClass) *Builder
- func (b *Builder) Silent() *Builder
- func (b *Builder) StyledText(ctx context.Context, texts ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) Text(ctx context.Context, msg string) (tg.UpdatesClass, error)
- func (b *Builder) Textf(ctx context.Context, format string, args ...interface{}) (tg.UpdatesClass, error)
- func (b *Builder) Upload(upd UploadOption) *UploadBuilder
- func (b *Builder) UploadMedia(ctx context.Context, media MediaOption) (tg.MessageMediaClass, error)
- func (b *Builder) UploadedPhoto(ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) UploadedSticker(ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) Video(ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *Builder) Voice(ctx context.Context, file tg.InputFileClass) (tg.UpdatesClass, error)
- type DeleteBuilder
- type DocumentBuilder
- type DocumentExternalBuilder
- type EditMessageBuilder
- func (b *EditMessageBuilder) Media(ctx context.Context, media MediaOption) (tg.UpdatesClass, error)
- func (b *EditMessageBuilder) StyledText(ctx context.Context, texts ...StyledTextOption) (tg.UpdatesClass, error)
- func (b *EditMessageBuilder) Text(ctx context.Context, msg string) (tg.UpdatesClass, error)
- func (b *EditMessageBuilder) Textf(ctx context.Context, format string, args ...interface{}) (tg.UpdatesClass, error)
- type FileLocation
- type FilePromise
- type ForwardBuilder
- type InlineUpdate
- type MediaOption
- func Basketball() MediaOption
- func Bowling() MediaOption
- func Casino() MediaOption
- func Contact(contact tg.InputMediaContact, caption ...StyledTextOption) MediaOption
- func Darts() MediaOption
- func Dice() MediaOption
- func Football() MediaOption
- func Game(id tg.InputGameClass, caption ...StyledTextOption) MediaOption
- func GeoPoint(lat, long float64, accuracy int, caption ...StyledTextOption) MediaOption
- func Media(media tg.InputMediaClass, caption ...StyledTextOption) MediaOption
- func MediaDice(emoticon string) MediaOption
- type MultiMediaOption
- type PeerUpdate
- type PhotoBuilder
- type PhotoExternalBuilder
- type PollAnswerOption
- type PollBuilder
- func (p *PollBuilder) Close() *PollBuilder
- func (p *PollBuilder) CloseDate(d time.Time) *PollBuilder
- func (p *PollBuilder) CloseDateTS(ts int) *PollBuilder
- func (p *PollBuilder) ClosePeriod(d time.Duration) *PollBuilder
- func (p *PollBuilder) ClosePeriodSeconds(s int) *PollBuilder
- func (p *PollBuilder) Explanation(msg string) *PollBuilder
- func (p *PollBuilder) MultipleChoice(multipleChoice bool) *PollBuilder
- func (p *PollBuilder) PollID() int64
- func (p *PollBuilder) PublicVoters(publicVoters bool) *PollBuilder
- func (p *PollBuilder) StyledExplanation(texts ...StyledTextOption) *PollBuilder
- type ReportBuilder
- func (b *ReportBuilder) ChildAbuse(ctx context.Context) (bool, error)
- func (b *ReportBuilder) Copyright(ctx context.Context) (bool, error)
- func (b *ReportBuilder) Fake(ctx context.Context) (bool, error)
- func (b *ReportBuilder) GeoIrrelevant(ctx context.Context) (bool, error)
- func (b *ReportBuilder) Message(msg string) *ReportBuilder
- func (b *ReportBuilder) Other(ctx context.Context) (bool, error)
- func (b *ReportBuilder) Pornography(ctx context.Context) (bool, error)
- func (b *ReportBuilder) Spam(ctx context.Context) (bool, error)
- func (b *ReportBuilder) Violence(ctx context.Context) (bool, error)
- type RequestBuilder
- func (b *RequestBuilder) AsInputChannel(ctx context.Context) (*tg.InputChannel, error)
- func (b *RequestBuilder) AsInputChannelClass(ctx context.Context) (tg.InputChannelClass, error)
- func (b *RequestBuilder) AsInputPeer(ctx context.Context) (tg.InputPeerClass, error)
- func (b *RequestBuilder) AsInputUser(ctx context.Context) (*tg.InputUser, error)
- func (b *RequestBuilder) AsInputUserClass(ctx context.Context) (tg.InputUserClass, error)
- func (b *RequestBuilder) CloneBuilder() *Builder
- func (b *RequestBuilder) Join(ctx context.Context) (tg.UpdatesClass, error)
- func (b *RequestBuilder) Leave(ctx context.Context) (tg.UpdatesClass, error)
- func (b *RequestBuilder) PeerSettings(ctx context.Context) (*tg.PeerSettings, error)
- func (b *RequestBuilder) PollVote(ctx context.Context, msgID int, answer []byte, answers ...[]byte) (tg.UpdatesClass, error)
- func (b *RequestBuilder) Reaction(ctx context.Context, msgID int, reaction ...tg.ReactionClass) (tg.UpdatesClass, error)
- func (b *RequestBuilder) Report(id int, ids ...int) *ReportBuilder
- func (b *RequestBuilder) ReportSpam(ctx context.Context) (bool, error)
- func (b *RequestBuilder) Revoke() *RevokeBuilder
- func (b *RequestBuilder) Scheduled() *ScheduledManager
- func (b *RequestBuilder) ScreenshotNotify(ctx context.Context, msgID int) (tg.UpdatesClass, error)
- func (b *RequestBuilder) TypingAction() *TypingActionBuilder
- type RevokeBuilder
- type ScheduledManager
- func (m *ScheduledManager) Delete(ctx context.Context, id int, ids ...int) (tg.UpdatesClass, error)
- func (m *ScheduledManager) Get(ctx context.Context, id int, ids ...int) (tg.ModifiedMessagesMessages, error)
- func (m *ScheduledManager) History(ctx context.Context) (tg.ModifiedMessagesMessages, error)
- func (m *ScheduledManager) HistoryWithHash(ctx context.Context, hash int64) (tg.ModifiedMessagesMessages, error)
- func (m *ScheduledManager) Send(ctx context.Context, id int, ids ...int) (tg.UpdatesClass, error)
- type SearchDocumentBuilder
- type Sender
- func (s *Sender) Answer(uctx tg.Entities, upd AnswerableMessageUpdate, ...) *RequestBuilder
- func (s *Sender) ClearAllDrafts(ctx context.Context) error
- func (s *Sender) Delete() *DeleteBuilder
- func (s *Sender) Inline(upd InlineUpdate) *inline.ResultBuilder
- func (s *Sender) JoinHash(ctx context.Context, hash string) (tg.UpdatesClass, error)
- func (s *Sender) JoinLink(ctx context.Context, link string) (tg.UpdatesClass, error)
- func (s *Sender) Peer(uctx tg.Entities, upd PeerUpdate, decorators ...peer.PromiseDecorator) *RequestBuilder
- func (s *Sender) PeerPromise(p peer.Promise, decorators ...peer.PromiseDecorator) *RequestBuilder
- func (s *Sender) Reply(uctx tg.Entities, upd AnswerableMessageUpdate, ...) *Builder
- func (s *Sender) Resolve(from string, decorators ...peer.PromiseDecorator) *RequestBuilder
- func (s *Sender) ResolveDeeplink(link string, decorators ...peer.PromiseDecorator) *RequestBuilder
- func (s *Sender) ResolveDomain(domain string, decorators ...peer.PromiseDecorator) *RequestBuilder
- func (s *Sender) ResolvePhone(phone string, decorators ...peer.PromiseDecorator) *RequestBuilder
- func (s *Sender) Self() *RequestBuilder
- func (s *Sender) To(p tg.InputPeerClass) *RequestBuilder
- func (s *Sender) WithRand(r io.Reader) *Sender
- func (s *Sender) WithResolver(resolver peer.Resolver) *Sender
- func (s *Sender) WithUploader(u Uploader) *Sender
- type StyledTextOption
- type TypingActionBuilder
- func (b *TypingActionBuilder) Cancel(ctx context.Context) error
- func (b *TypingActionBuilder) ChooseContact(ctx context.Context) error
- func (b *TypingActionBuilder) ChooseSticker(ctx context.Context) error
- func (b *TypingActionBuilder) Custom(ctx context.Context, action tg.SendMessageActionClass) error
- func (b *TypingActionBuilder) EmojiInteraction(ctx context.Context, emoticon string, msgID int, interaction tg.DataJSON) error
- func (b *TypingActionBuilder) EmojiInteractionSeen(ctx context.Context, emoticon string) error
- func (b *TypingActionBuilder) GamePlay(ctx context.Context) error
- func (b *TypingActionBuilder) GeoLocation(ctx context.Context) error
- func (b *TypingActionBuilder) HistoryImport(ctx context.Context, progress int) error
- func (b *TypingActionBuilder) RecordAudio(ctx context.Context) error
- func (b *TypingActionBuilder) RecordRound(ctx context.Context) error
- func (b *TypingActionBuilder) RecordVideo(ctx context.Context) error
- func (b *TypingActionBuilder) SpeakingInGroupCall(ctx context.Context) error
- func (b *TypingActionBuilder) ThreadID(id int) *TypingActionBuilder
- func (b *TypingActionBuilder) ThreadMsg(msg tg.MessageClass) *TypingActionBuilder
- func (b *TypingActionBuilder) Typing(ctx context.Context) error
- func (b *TypingActionBuilder) UploadAudio(ctx context.Context, progress int) error
- func (b *TypingActionBuilder) UploadDocument(ctx context.Context, progress int) error
- func (b *TypingActionBuilder) UploadPhoto(ctx context.Context, progress int) error
- func (b *TypingActionBuilder) UploadRound(ctx context.Context, progress int) error
- func (b *TypingActionBuilder) UploadVideo(ctx context.Context, progress int) error
- type UploadBuilder
- func (u *UploadBuilder) AsInputFile(ctx context.Context) (tg.InputFileClass, error)
- func (u *UploadBuilder) Audio(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (u *UploadBuilder) File(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (u *UploadBuilder) GIF(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (u *UploadBuilder) Photo(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (u *UploadBuilder) RoundVideo(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (u *UploadBuilder) Sticker(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (u *UploadBuilder) Video(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
- func (u *UploadBuilder) Voice(ctx context.Context) (tg.UpdatesClass, error)
- type UploadOption
- func FromBytes(name string, data []byte) UploadOption
- func FromFS(filesystem fs.FS, path string) UploadOption
- func FromFile(f uploader.File) UploadOption
- func FromPath(path string) UploadOption
- func FromReader(name string, r io.Reader) UploadOption
- func FromSource(src source.Source, rawURL string) UploadOption
- func FromURL(rawURL string) UploadOption
- func Upload(promise FilePromise) UploadOption
- type UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) Attributes(attrs ...tg.DocumentAttributeClass) *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) Audio() *AudioDocumentBuilder
- func (u *UploadedDocumentBuilder) Filename(name string) *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) ForceFile(v bool) *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) GIF() *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) HasStickers() *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) MIME(mime string) *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) NosoundVideo(v bool) *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) RoundVideo() *VideoDocumentBuilder
- func (u *UploadedDocumentBuilder) Stickers(stickers ...FileLocation) *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) TTL(ttl time.Duration) *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) TTLSeconds(ttl int) *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) Thumb(file tg.InputFileClass) *UploadedDocumentBuilder
- func (u *UploadedDocumentBuilder) UploadedSticker() *UploadedStickerBuilder
- func (u *UploadedDocumentBuilder) Video() *VideoDocumentBuilder
- func (u *UploadedDocumentBuilder) Voice() *AudioDocumentBuilder
- type UploadedPhotoBuilder
- type UploadedStickerBuilder
- func (u *UploadedStickerBuilder) Alt(alt string) *UploadedStickerBuilder
- func (u *UploadedStickerBuilder) Mask(mask bool) *UploadedStickerBuilder
- func (u *UploadedStickerBuilder) MaskCoords(maskCoords tg.MaskCoords) *UploadedStickerBuilder
- func (u *UploadedStickerBuilder) StickerSet(stickerSet tg.InputStickerSetClass) *UploadedStickerBuilder
- type Uploader
- type VideoDocumentBuilder
- func (u *VideoDocumentBuilder) Duration(duration time.Duration) *VideoDocumentBuilder
- func (u *VideoDocumentBuilder) DurationSeconds(duration int) *VideoDocumentBuilder
- func (u *VideoDocumentBuilder) Resolution(w, h int) *VideoDocumentBuilder
- func (u *VideoDocumentBuilder) Round() *VideoDocumentBuilder
- func (u *VideoDocumentBuilder) SupportsStreaming() *VideoDocumentBuilder
Examples ¶
Constants ¶
const ( // DiceEmoticon is an emoticon to send dice sticker. DiceEmoticon = "🎲" // DartsEmoticon is an emoticon to send darts sticker. DartsEmoticon = "🎯" // BasketballEmoticon is an emoticon to send basketball sticker. BasketballEmoticon = "🏀" // FootballEmoticon is an emoticon to send football sticker. FootballEmoticon = "⚽" // CasinoEmoticon is an emoticon to send casino sticker. CasinoEmoticon = "🎰" // BowlingEmoticon is an emoticon to send bowling sticker. BowlingEmoticon = "🎳" )
const ( // DefaultVoiceMIME is a default voice MIME to use. DefaultVoiceMIME = "audio/ogg" // DefaultAudioMIME is a default audio MIME to use. DefaultAudioMIME = "audio/mp3" // DefaultVideoMIME is a default video MIME to use. DefaultVideoMIME = "video/mp4" // DefaultGifMIME is a default gif MIME to use. DefaultGifMIME = "image/gif" // DefaultStickerMIME is a default sticker MIME to use. DefaultStickerMIME = "image/webp" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnswerableMessageUpdate ¶
type AnswerableMessageUpdate interface {
GetMessage() tg.MessageClass
}
AnswerableMessageUpdate represents update which can be used to answer.
type AudioDocumentBuilder ¶
type AudioDocumentBuilder struct {
// contains filtered or unexported fields
}
AudioDocumentBuilder is an Audio media option.
func Audio ¶
func Audio(file tg.InputFileClass, caption ...StyledTextOption) *AudioDocumentBuilder
Audio adds audio attachment.
Example ¶
package main import ( "context" "fmt" "os" "os/signal" "github.com/go-faster/errors" "bitbucket.org/hokego/hokego-td/telegram" "bitbucket.org/hokego/hokego-td/telegram/message" "bitbucket.org/hokego/hokego-td/telegram/uploader" "bitbucket.org/hokego/hokego-td/tg" ) func sendAudio(ctx context.Context) error { client, err := telegram.ClientFromEnvironment(telegram.Options{}) if err != nil { return err } return client.Run(ctx, func(ctx context.Context) error { raw := tg.NewClient(client) // Upload file. f, err := uploader.NewUploader(raw).FromPath(ctx, "vsyo idyot po planu.mp3") if err != nil { return errors.Wrap(err, "upload") } sender := message.NewSender(raw) r := sender.Resolve("@durovschat") // Sends audio to the @durovschat. if _, err := r.Audio(ctx, f); err != nil { return err } // Sends audio with title to the @durovschat. if _, err := r.Media(ctx, message.Audio(f). Performer("Yegor Letov"). Title("Everything is going according to plan")); err != nil { return err } // Sends voice message to the @durovschat. if _, err := r.Voice(ctx, f); err != nil { return err } return nil }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := sendAudio(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
func (*AudioDocumentBuilder) Duration ¶
func (u *AudioDocumentBuilder) Duration(duration time.Duration) *AudioDocumentBuilder
Duration sets duration of audio file.
func (*AudioDocumentBuilder) DurationSeconds ¶
func (u *AudioDocumentBuilder) DurationSeconds(duration int) *AudioDocumentBuilder
DurationSeconds sets duration in seconds.
func (*AudioDocumentBuilder) Performer ¶
func (u *AudioDocumentBuilder) Performer(performer string) *AudioDocumentBuilder
Performer sets performer.
func (*AudioDocumentBuilder) Title ¶
func (u *AudioDocumentBuilder) Title(title string) *AudioDocumentBuilder
Title sets name of song.
func (*AudioDocumentBuilder) Voice ¶
func (u *AudioDocumentBuilder) Voice() *AudioDocumentBuilder
Voice sets flag to mark this audio as voice message.
func (*AudioDocumentBuilder) Waveform ¶
func (u *AudioDocumentBuilder) Waveform(waveform []byte) *AudioDocumentBuilder
Waveform sets waveform representation of the voice message.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is a message builder.
func (*Builder) Album ¶
func (b *Builder) Album(ctx context.Context, media MultiMediaOption, album ...MultiMediaOption) (tg.UpdatesClass, error)
Album sends message with multiple media attachments.
func (*Builder) Audio ¶
func (b *Builder) Audio( ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption, ) (tg.UpdatesClass, error)
Audio sends audio file.
func (*Builder) Background ¶
Background sets flag to send this message as background message.
func (*Builder) Basketball ¶
Basketball sends a basketball animated sticker.
func (*Builder) ClearDraft ¶
ClearDraft clears draft. Also, you can use Clear() builder option with any other message send method.
func (*Builder) Document ¶
func (b *Builder) Document( ctx context.Context, file FileLocation, caption ...StyledTextOption, ) (tg.UpdatesClass, error)
Document sends document.
func (*Builder) DocumentByHash ¶
func (b *Builder) DocumentByHash( ctx context.Context, hash []byte, size int64, mime string, caption ...StyledTextOption, ) (tg.UpdatesClass, error)
DocumentByHash finds document by hash and sends as attachment.
func (*Builder) DocumentExternal ¶
func (b *Builder) DocumentExternal(ctx context.Context, url string, caption ...StyledTextOption) (tg.UpdatesClass, error)
DocumentExternal sends document attachment that will be downloaded by the Telegram servers.
func (*Builder) File ¶
func (b *Builder) File(ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption) (tg.UpdatesClass, error)
File sends uploaded file as document and forces it to be used as plain file, not media.
func (*Builder) ForwardIDs ¶
func (b *Builder) ForwardIDs(from tg.InputPeerClass, id int, ids ...int) *ForwardBuilder
ForwardIDs creates builder to forward messages by ID.
func (*Builder) ForwardMessages ¶
func (b *Builder) ForwardMessages(from tg.InputPeerClass, msg tg.MessageClass, m ...tg.MessageClass) *ForwardBuilder
ForwardMessages creates builder to forward messages.
func (*Builder) GIF ¶
func (b *Builder) GIF( ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption, ) (tg.UpdatesClass, error)
GIF sends gif.
func (*Builder) InlineResult ¶
func (b *Builder) InlineResult(ctx context.Context, id string, queryID int64, hideVia bool) (tg.UpdatesClass, error)
InlineResult is a user method to send bot inline query result message.
func (*Builder) Markup ¶
func (b *Builder) Markup(m tg.ReplyMarkupClass) *Builder
Markup sets reply markup for sending bot buttons.
NB: markup will not be used, if you send multiple media attachments.
func (*Builder) Media ¶
func (b *Builder) Media(ctx context.Context, media MediaOption) (tg.UpdatesClass, error)
Media sends message with media attachment.
func (*Builder) NoForwards ¶
NoForwards whether that sent message cannot be forwarded.
func (*Builder) Photo ¶
func (b *Builder) Photo( ctx context.Context, photo FileLocation, caption ...StyledTextOption, ) (tg.UpdatesClass, error)
Photo sends photo.
func (*Builder) PhotoExternal ¶
func (b *Builder) PhotoExternal( ctx context.Context, url string, caption ...StyledTextOption, ) (tg.UpdatesClass, error)
PhotoExternal sends photo attachment which will be downloaded by the Telegram servers.
func (*Builder) ReplyMsg ¶
func (b *Builder) ReplyMsg(msg tg.MessageClass) *Builder
ReplyMsg sets message to reply.
func (*Builder) RoundVideo ¶
func (b *Builder) RoundVideo( ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption, ) (tg.UpdatesClass, error)
RoundVideo sends round video.
func (*Builder) Row ¶
func (b *Builder) Row(buttons ...tg.KeyboardButtonClass) *Builder
Row sets single row keyboard markup for sending bot buttons.
NB: markup will not be used, if you send multiple media attachments.
func (*Builder) SaveDraft ¶
SaveDraft saves given message as draft.
See https://core.telegram.org/api/drafts#saving-drafts.
Example ¶
package main import ( "context" "fmt" "os" "os/signal" "github.com/go-faster/errors" "bitbucket.org/hokego/hokego-td/telegram" "bitbucket.org/hokego/hokego-td/telegram/message" "bitbucket.org/hokego/hokego-td/telegram/message/styling" "bitbucket.org/hokego/hokego-td/tg" ) func saveDraft(ctx context.Context) error { client, err := telegram.ClientFromEnvironment(telegram.Options{}) if err != nil { return err } return client.Run(ctx, func(ctx context.Context) error { sender := message.NewSender(tg.NewClient(client)) r := sender.Resolve("@durov") // Save draft message. if err := r.SaveDraft(ctx, "Hi!"); err != nil { return errors.Wrap(err, "draft") } // Save styled draft message. if err := r.SaveStyledDraft(ctx, styling.Bold("Hi!")); err != nil { return errors.Wrap(err, "draft") } // Clear draft for resolved @durov peer. if err := r.ClearDraft(ctx); err != nil { return errors.Wrap(err, "draft") } return nil }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := saveDraft(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
func (*Builder) SaveStyledDraft ¶
func (b *Builder) SaveStyledDraft(ctx context.Context, texts ...StyledTextOption) error
SaveStyledDraft saves given styled message as draft.
func (*Builder) ScheduleTS ¶
ScheduleTS sets scheduled message timestamp for scheduled messages.
func (*Builder) SendAs ¶
func (b *Builder) SendAs(p tg.InputPeerClass) *Builder
SendAs sets peer to send as.
func (*Builder) Silent ¶
Silent sets flag to send this message silently (no notifications for the receivers).
func (*Builder) StyledText ¶
func (b *Builder) StyledText(ctx context.Context, texts ...StyledTextOption) (tg.UpdatesClass, error)
StyledText sends styled text message.
Example ¶
package main import ( "context" "fmt" "os" "os/signal" "bitbucket.org/hokego/hokego-td/telegram" "bitbucket.org/hokego/hokego-td/telegram/message" "bitbucket.org/hokego/hokego-td/telegram/message/styling" "bitbucket.org/hokego/hokego-td/tg" ) func sendStyledText(ctx context.Context) error { client, err := telegram.ClientFromEnvironment(telegram.Options{}) if err != nil { return err } // This example creates a big message with different style lines // and sends to your Saved Messages folder. return client.Run(ctx, func(ctx context.Context) error { formats := []message.StyledTextOption{ styling.Plain("plaintext"), styling.Plain("\n\n"), styling.Mention("@durov"), styling.Plain("\n\n"), styling.Hashtag("#hashtag"), styling.Plain("\n\n"), styling.BotCommand("/command"), styling.Plain("\n\n"), styling.URL("https://google.org"), styling.Plain("\n\n"), styling.Email("example@example.org"), styling.Plain("\n\n"), styling.Bold("bold"), styling.Plain("\n\n"), styling.Italic("italic"), styling.Plain("\n\n"), styling.Underline("underline"), styling.Plain("\n\n"), styling.Strike("strike"), styling.Plain("\n\n"), styling.Code("fmt.Println(`Hello, World!`)"), styling.Plain("\n\n"), styling.Pre("fmt.Println(`Hello, World!`)", "Go"), styling.Plain("\n\n"), styling.TextURL("clickme", "https://google.com"), styling.Plain("\n\n"), styling.Phone("+71234567891"), styling.Plain("\n\n"), styling.Cashtag("$CASHTAG"), styling.Plain("\n\n"), styling.Blockquote("blockquote"), styling.Plain("\n\n"), styling.BankCard("5550111111111111"), styling.Plain("\n\n"), } _, err := message.NewSender(tg.NewClient(client)). Self().StyledText(ctx, formats...) return err }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := sendStyledText(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
func (*Builder) Text ¶
Text sends text message.
Example ¶
package main import ( "context" "fmt" "os" "os/signal" "bitbucket.org/hokego/hokego-td/telegram" "bitbucket.org/hokego/hokego-td/telegram/message" "bitbucket.org/hokego/hokego-td/telegram/message/styling" ) func sendText(ctx context.Context) error { client, err := telegram.ClientFromEnvironment(telegram.Options{}) if err != nil { return err } return client.Run(ctx, func(ctx context.Context) error { s := message.NewSender(client.API()) // Sends message to your Saved Message folder. if _, err := s.Self().Text(ctx, "Hi!"); err != nil { return err } // Resolves @my_channel and gets tg.InputPeerClass. p, err := s.Resolve("my_channel").AsInputPeer(ctx) if err != nil { return err } // Replies to message ID = 1 in @gotd_en as @my_channel with spoiler message "spoiler". if _, err := s.Resolve("gotd_en"). SendAs(p).Reply(1). StyledText(ctx, styling.Spoiler("spoiler")); err != nil { return err } // Sends message to channel return err }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := sendText(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
func (*Builder) Textf ¶
func (b *Builder) Textf(ctx context.Context, format string, args ...interface{}) (tg.UpdatesClass, error)
Textf formats and sends text message.
func (*Builder) Upload ¶
func (b *Builder) Upload(upd UploadOption) *UploadBuilder
Upload creates new UploadBuilder to upload and send attachments. Given option will be called only once, even if you call upload functions.
func (*Builder) UploadMedia ¶
func (b *Builder) UploadMedia(ctx context.Context, media MediaOption) (tg.MessageMediaClass, error)
UploadMedia uses messages.uploadMedia to upload a file and associate it to a chat (without actually sending it to the chat).
func (*Builder) UploadedPhoto ¶
func (b *Builder) UploadedPhoto( ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption, ) (tg.UpdatesClass, error)
UploadedPhoto sends uploaded file as photo.
func (*Builder) UploadedSticker ¶
func (b *Builder) UploadedSticker( ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption, ) (tg.UpdatesClass, error)
UploadedSticker sends uploaded file as sticker.
func (*Builder) Video ¶
func (b *Builder) Video( ctx context.Context, file tg.InputFileClass, caption ...StyledTextOption, ) (tg.UpdatesClass, error)
Video sends video.
func (*Builder) Voice ¶
func (b *Builder) Voice(ctx context.Context, file tg.InputFileClass) (tg.UpdatesClass, error)
Voice sends voice message.
type DeleteBuilder ¶
type DeleteBuilder struct {
// contains filtered or unexported fields
}
DeleteBuilder is an intermediate builder to delete messages. Unlike RevokeBuilder will keep messages for other users.
func (*DeleteBuilder) Messages ¶
func (b *DeleteBuilder) Messages(ctx context.Context, ids ...int) (*tg.MessagesAffectedMessages, error)
Messages deletes messages by given IDs, but keeps it for other users.
NB: Telegram counts message IDs globally for private chats (but not for channels). This method does not check that all given message IDs from one chat.
type DocumentBuilder ¶
type DocumentBuilder struct {
// contains filtered or unexported fields
}
DocumentBuilder is a Document media option.
func Document ¶
func Document(doc FileLocation, caption ...StyledTextOption) *DocumentBuilder
Document adds document attachment.
func (*DocumentBuilder) Query ¶
func (u *DocumentBuilder) Query(query string) *DocumentBuilder
Query sets query field of InputMediaDocument.
func (*DocumentBuilder) TTL ¶
func (u *DocumentBuilder) TTL(ttl time.Duration) *DocumentBuilder
TTL sets time to live of self-destructing document.
func (*DocumentBuilder) TTLSeconds ¶
func (u *DocumentBuilder) TTLSeconds(ttl int) *DocumentBuilder
TTLSeconds sets time to live in seconds of self-destructing document.
type DocumentExternalBuilder ¶
type DocumentExternalBuilder struct {
// contains filtered or unexported fields
}
DocumentExternalBuilder is a DocumentExternal media option.
func DocumentExternal ¶
func DocumentExternal(url string, caption ...StyledTextOption) *DocumentExternalBuilder
DocumentExternal adds document attachment that will be downloaded by the Telegram servers.
func (*DocumentExternalBuilder) TTL ¶
func (u *DocumentExternalBuilder) TTL(ttl time.Duration) *DocumentExternalBuilder
TTL sets time to live of self-destructing document.
func (*DocumentExternalBuilder) TTLSeconds ¶
func (u *DocumentExternalBuilder) TTLSeconds(ttl int) *DocumentExternalBuilder
TTLSeconds sets time to live in seconds of self-destructing document.
type EditMessageBuilder ¶
type EditMessageBuilder struct {
// contains filtered or unexported fields
}
EditMessageBuilder creates edit message builder.
func (*EditMessageBuilder) Media ¶
func (b *EditMessageBuilder) Media(ctx context.Context, media MediaOption) (tg.UpdatesClass, error)
Media edits message using given media and text.
func (*EditMessageBuilder) StyledText ¶
func (b *EditMessageBuilder) StyledText(ctx context.Context, texts ...StyledTextOption) (tg.UpdatesClass, error)
StyledText edits message using given message.
func (*EditMessageBuilder) Text ¶
func (b *EditMessageBuilder) Text(ctx context.Context, msg string) (tg.UpdatesClass, error)
Text edits message.
func (*EditMessageBuilder) Textf ¶
func (b *EditMessageBuilder) Textf(ctx context.Context, format string, args ...interface{}) (tg.UpdatesClass, error)
Textf formats and edits message .
type FileLocation ¶
type FileLocation interface { GetID() (value int64) GetAccessHash() (value int64) GetFileReference() (value []byte) }
FileLocation is an abstraction of Telegram file location.
type FilePromise ¶
FilePromise is a upload file promise.
type ForwardBuilder ¶
type ForwardBuilder struct {
// contains filtered or unexported fields
}
ForwardBuilder is a forward request builder.
func (*ForwardBuilder) Send ¶
func (b *ForwardBuilder) Send(ctx context.Context) (tg.UpdatesClass, error)
Send sends forwarded messages.
func (*ForwardBuilder) WithMyScore ¶
func (b *ForwardBuilder) WithMyScore() *ForwardBuilder
WithMyScore sets flag to include your score in the forwarded game.
type InlineUpdate ¶
type InlineUpdate interface {
GetQueryID() int64
}
InlineUpdate is an abstraction for
type MediaOption ¶
type MediaOption interface {
// contains filtered or unexported methods
}
MediaOption is an option for sending media attachments.
func Contact ¶
func Contact(contact tg.InputMediaContact, caption ...StyledTextOption) MediaOption
Contact adds contact attachment.
func Game ¶
func Game(id tg.InputGameClass, caption ...StyledTextOption) MediaOption
Game adds a game attachment.
func GeoPoint ¶
func GeoPoint(lat, long float64, accuracy int, caption ...StyledTextOption) MediaOption
GeoPoint adds geo point attachment. NB: parameter accuracy may be zero and will not be used.
func Media ¶
func Media(media tg.InputMediaClass, caption ...StyledTextOption) MediaOption
Media adds given media attachment to message.
func MediaDice ¶
func MediaDice(emoticon string) MediaOption
MediaDice adds a dice-based animated sticker.
Example ¶
package main import ( "context" "fmt" "os" "os/signal" "bitbucket.org/hokego/hokego-td/telegram" "bitbucket.org/hokego/hokego-td/telegram/message" "bitbucket.org/hokego/hokego-td/tg" ) func sendDice(ctx context.Context) error { client, err := telegram.ClientFromEnvironment(telegram.Options{}) if err != nil { return err } return client.Run(ctx, func(ctx context.Context) error { sender := message.NewSender(tg.NewClient(client)) // Sends dice "🎲" to the @durovschat. if _, err := sender.Resolve("@durovschat").Dice(ctx); err != nil { return err } // Sends darts "🎯" to the @durovschat. if _, err := sender.Resolve("https://t.me/durovschat").Darts(ctx); err != nil { return err } return nil }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := sendDice(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
type MultiMediaOption ¶
type MultiMediaOption interface { MediaOption // contains filtered or unexported methods }
MultiMediaOption is an option for sending albums.
func ForceMulti ¶
func ForceMulti(opt MediaOption) MultiMediaOption
ForceMulti converts MediaOption to MultiMediaOption. It can produce unexpected RPC errors. Use carefully.
type PeerUpdate ¶
PeerUpdate represents update which can be used to answer.
type PhotoBuilder ¶
type PhotoBuilder struct {
// contains filtered or unexported fields
}
PhotoBuilder is a Photo media option.
func Photo ¶
func Photo(photo FileLocation, caption ...StyledTextOption) *PhotoBuilder
Photo adds photo attachment.
func (*PhotoBuilder) TTL ¶
func (u *PhotoBuilder) TTL(ttl time.Duration) *PhotoBuilder
TTL sets time to live of self-destructing photo.
func (*PhotoBuilder) TTLSeconds ¶
func (u *PhotoBuilder) TTLSeconds(ttl int) *PhotoBuilder
TTLSeconds sets time to live in seconds of self-destructing photo.
type PhotoExternalBuilder ¶
type PhotoExternalBuilder struct {
// contains filtered or unexported fields
}
PhotoExternalBuilder is a PhotoExternal media option.
func PhotoExternal ¶
func PhotoExternal(url string, caption ...StyledTextOption) *PhotoExternalBuilder
PhotoExternal adds photo attachment which will be downloaded by the Telegram servers.
func (*PhotoExternalBuilder) TTL ¶
func (u *PhotoExternalBuilder) TTL(ttl time.Duration) *PhotoExternalBuilder
TTL sets time to live of self-destructing document.
func (*PhotoExternalBuilder) TTLSeconds ¶
func (u *PhotoExternalBuilder) TTLSeconds(ttl int) *PhotoExternalBuilder
TTLSeconds sets time to live in seconds of self-destructing document.
type PollAnswerOption ¶
type PollAnswerOption func(p *pollAnswerBuilder)
PollAnswerOption is an option to create poll answer.
func CorrectPollAnswer ¶
func CorrectPollAnswer(text string) PollAnswerOption
CorrectPollAnswer creates new correct poll answer option.
func PollAnswer ¶
func PollAnswer(text string) PollAnswerOption
PollAnswer creates new plain poll answer option.
func RawPollAnswer ¶
func RawPollAnswer(poll tg.PollAnswer) PollAnswerOption
RawPollAnswer creates new raw poll answer option.
type PollBuilder ¶
type PollBuilder struct {
// contains filtered or unexported fields
}
PollBuilder is a Poll media option.
func Poll ¶
func Poll(question string, a, b PollAnswerOption, answers ...PollAnswerOption) *PollBuilder
Poll adds poll attachment.
func (*PollBuilder) Close ¶
func (p *PollBuilder) Close() *PollBuilder
Close sets flag that the poll is closed and doesn't accept any more answers.
func (*PollBuilder) CloseDate ¶
func (p *PollBuilder) CloseDate(d time.Time) *PollBuilder
CloseDate sets point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future.
func (*PollBuilder) CloseDateTS ¶
func (p *PollBuilder) CloseDateTS(ts int) *PollBuilder
CloseDateTS sets point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future.
func (*PollBuilder) ClosePeriod ¶
func (p *PollBuilder) ClosePeriod(d time.Duration) *PollBuilder
ClosePeriod sets amount of time in seconds the poll will be active after creation, 5-600 seconds.
func (*PollBuilder) ClosePeriodSeconds ¶
func (p *PollBuilder) ClosePeriodSeconds(s int) *PollBuilder
ClosePeriodSeconds sets amount of time in seconds the poll will be active after creation, 5-600.
func (*PollBuilder) Explanation ¶
func (p *PollBuilder) Explanation(msg string) *PollBuilder
Explanation sets explanation message.
func (*PollBuilder) MultipleChoice ¶
func (p *PollBuilder) MultipleChoice(multipleChoice bool) *PollBuilder
MultipleChoice sets flag that multiple options can be chosen as answer.
func (*PollBuilder) PollID ¶
func (p *PollBuilder) PollID() int64
PollID return poll ID. If poll was not sent, will be zero. It useful to close polls.
func (*PollBuilder) PublicVoters ¶
func (p *PollBuilder) PublicVoters(publicVoters bool) *PollBuilder
PublicVoters sets flag that votes are publicly visible to all users (non-anonymous poll).
func (*PollBuilder) StyledExplanation ¶
func (p *PollBuilder) StyledExplanation(texts ...StyledTextOption) *PollBuilder
StyledExplanation sets styled explanation message.
type ReportBuilder ¶
type ReportBuilder struct {
// contains filtered or unexported fields
}
ReportBuilder is a reporting messages helper.
func (*ReportBuilder) ChildAbuse ¶
func (b *ReportBuilder) ChildAbuse(ctx context.Context) (bool, error)
ChildAbuse sends report for child abuse.
func (*ReportBuilder) Copyright ¶
func (b *ReportBuilder) Copyright(ctx context.Context) (bool, error)
Copyright sends report for copyrighted content.
func (*ReportBuilder) Fake ¶
func (b *ReportBuilder) Fake(ctx context.Context) (bool, error)
Fake sends report for fake.
func (*ReportBuilder) GeoIrrelevant ¶
func (b *ReportBuilder) GeoIrrelevant(ctx context.Context) (bool, error)
GeoIrrelevant sends report for irrelevant geogroup.
func (*ReportBuilder) Message ¶
func (b *ReportBuilder) Message(msg string) *ReportBuilder
Message sets additional comment for report.
func (*ReportBuilder) Other ¶
func (b *ReportBuilder) Other(ctx context.Context) (bool, error)
Other sends report for other.
func (*ReportBuilder) Pornography ¶
func (b *ReportBuilder) Pornography(ctx context.Context) (bool, error)
Pornography sends report for pornography.
type RequestBuilder ¶
type RequestBuilder struct {
Builder
}
RequestBuilder is an intermediate builder to make different RPC calls using Sender.
func (*RequestBuilder) AsInputChannel ¶
func (b *RequestBuilder) AsInputChannel(ctx context.Context) (*tg.InputChannel, error)
AsInputChannel returns resolve result as InputChannel.
func (*RequestBuilder) AsInputChannelClass ¶
func (b *RequestBuilder) AsInputChannelClass(ctx context.Context) (tg.InputChannelClass, error)
AsInputChannelClass returns resolve result as tg.NotEmptyInputChannel.
func (*RequestBuilder) AsInputPeer ¶
func (b *RequestBuilder) AsInputPeer(ctx context.Context) (tg.InputPeerClass, error)
AsInputPeer returns resolve result as InputPeerClass.
func (*RequestBuilder) AsInputUser ¶
AsInputUser returns resolve result as InputUser.
func (*RequestBuilder) AsInputUserClass ¶
func (b *RequestBuilder) AsInputUserClass(ctx context.Context) (tg.InputUserClass, error)
AsInputUserClass returns resolve result as InputUserClass.
func (*RequestBuilder) CloneBuilder ¶
func (b *RequestBuilder) CloneBuilder() *Builder
CloneBuilder returns copy of message Builder inside RequestBuilder.
func (*RequestBuilder) Join ¶
func (b *RequestBuilder) Join(ctx context.Context) (tg.UpdatesClass, error)
Join joins resolved channel. NB: if resolved peer is not a channel, error will be returned.
func (*RequestBuilder) Leave ¶
func (b *RequestBuilder) Leave(ctx context.Context) (tg.UpdatesClass, error)
Leave leaves resolved peer.
NB: if resolved peer is not a channel or chat, or chat is deactivated, empty *tg.Updates will be returned.
func (*RequestBuilder) PeerSettings ¶
func (b *RequestBuilder) PeerSettings(ctx context.Context) (*tg.PeerSettings, error)
PeerSettings returns peer settings.
func (*RequestBuilder) PollVote ¶
func (b *RequestBuilder) PollVote( ctx context.Context, msgID int, answer []byte, answers ...[]byte, ) (tg.UpdatesClass, error)
PollVote votes in a poll.
func (*RequestBuilder) Reaction ¶
func (b *RequestBuilder) Reaction(ctx context.Context, msgID int, reaction ...tg.ReactionClass) (tg.UpdatesClass, error)
Reaction sends reaction for given message.
func (*RequestBuilder) Report ¶
func (b *RequestBuilder) Report(id int, ids ...int) *ReportBuilder
Report reports messages in a chat for violation of Telegram's Terms of Service.
func (*RequestBuilder) ReportSpam ¶
func (b *RequestBuilder) ReportSpam(ctx context.Context) (bool, error)
ReportSpam reports peer for spam. NB: You should check that the peer settings of the chat allow us to do that.
func (*RequestBuilder) Revoke ¶
func (b *RequestBuilder) Revoke() *RevokeBuilder
Revoke creates new RevokeBuilder.
func (*RequestBuilder) Scheduled ¶
func (b *RequestBuilder) Scheduled() *ScheduledManager
Scheduled creates new ScheduledManager using resolved peer.
func (*RequestBuilder) ScreenshotNotify ¶
func (b *RequestBuilder) ScreenshotNotify(ctx context.Context, msgID int) (tg.UpdatesClass, error)
ScreenshotNotify sends notification about screenshot. Parameter msgID is an ID of message that was screenshotted, can be 0.
func (*RequestBuilder) TypingAction ¶
func (b *RequestBuilder) TypingAction() *TypingActionBuilder
TypingAction creates TypingActionBuilder.
type RevokeBuilder ¶
type RevokeBuilder struct {
// contains filtered or unexported fields
}
RevokeBuilder is an intermediate builder to delete messages. Unlike DeleteBuilder will not keep messages for other users.
func (*RevokeBuilder) Messages ¶
func (b *RevokeBuilder) Messages(ctx context.Context, ids ...int) (*tg.MessagesAffectedMessages, error)
Messages deletes messages by given IDs.
NB: Telegram counts message IDs globally for private chats (but not for channels). This method does not check that all given message IDs from one chat.
type ScheduledManager ¶
type ScheduledManager struct {
// contains filtered or unexported fields
}
ScheduledManager is a scheduled messages manager.
func (*ScheduledManager) Delete ¶
func (m *ScheduledManager) Delete(ctx context.Context, id int, ids ...int) (tg.UpdatesClass, error)
Delete deletes scheduled messages.
func (*ScheduledManager) Get ¶
func (m *ScheduledManager) Get(ctx context.Context, id int, ids ...int) (tg.ModifiedMessagesMessages, error)
Get gets scheduled messages.
func (*ScheduledManager) History ¶
func (m *ScheduledManager) History(ctx context.Context) (tg.ModifiedMessagesMessages, error)
History gets scheduled messages history.
func (*ScheduledManager) HistoryWithHash ¶
func (m *ScheduledManager) HistoryWithHash(ctx context.Context, hash int64) (tg.ModifiedMessagesMessages, error)
HistoryWithHash gets scheduled messages history.
func (*ScheduledManager) Send ¶
func (m *ScheduledManager) Send(ctx context.Context, id int, ids ...int) (tg.UpdatesClass, error)
Send sends scheduled messages.
type SearchDocumentBuilder ¶
type SearchDocumentBuilder struct {
// contains filtered or unexported fields
}
SearchDocumentBuilder is a Document media option which uses messages.getDocumentByHash to find document.
See https://core.telegram.org/method/messages.getDocumentByHash.
See https://core.telegram.org/api/files#re-using-pre-uploaded-files.
func DocumentByHash ¶
func DocumentByHash( hash []byte, size int64, mime string, caption ...StyledTextOption, ) *SearchDocumentBuilder
DocumentByHash finds document by hash and adds as attachment.
See https://core.telegram.org/method/messages.getDocumentByHash.
See https://core.telegram.org/api/files#re-using-pre-uploaded-files.
func (*SearchDocumentBuilder) Query ¶
func (u *SearchDocumentBuilder) Query(query string) *SearchDocumentBuilder
Query sets query field of InputMediaDocument.
func (*SearchDocumentBuilder) TTL ¶
func (u *SearchDocumentBuilder) TTL(ttl time.Duration) *SearchDocumentBuilder
TTL sets time to live of self-destructing document.
func (*SearchDocumentBuilder) TTLSeconds ¶
func (u *SearchDocumentBuilder) TTLSeconds(ttl int) *SearchDocumentBuilder
TTLSeconds sets time to live in seconds of self-destructing document.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender is a message sending helper.
func (*Sender) Answer ¶
func (s *Sender) Answer( uctx tg.Entities, upd AnswerableMessageUpdate, decorators ...peer.PromiseDecorator, ) *RequestBuilder
Answer uses given message update to create message for same chat.
func (*Sender) ClearAllDrafts ¶
ClearAllDrafts clears all drafts in all peers.
func (*Sender) Inline ¶
func (s *Sender) Inline(upd InlineUpdate) *inline.ResultBuilder
Inline creates new inline.ResultBuilder using given update.
func (*Sender) JoinLink ¶
JoinLink joins to private chat using given link or hash. Input examples:
t.me/+AAAAAAAAAAAAAAAA https://t.me/+AAAAAAAAAAAAAAAA t.me/joinchat/AAAAAAAAAAAAAAAA https://t.me/joinchat/AAAAAAAAAAAAAAAA tg:join?invite=AAAAAAAAAAAAAAAA tg://join?invite=AAAAAAAAAAAAAAAA
Example ¶
package main import ( "context" "fmt" "os" "os/signal" "bitbucket.org/hokego/hokego-td/telegram" "bitbucket.org/hokego/hokego-td/telegram/message" "bitbucket.org/hokego/hokego-td/tg" ) func sendJoin(ctx context.Context) error { client, err := telegram.ClientFromEnvironment(telegram.Options{}) if err != nil { return err } return client.Run(ctx, func(ctx context.Context) error { sender := message.NewSender(tg.NewClient(client)) // Join to private chat by link. if _, err := sender.JoinLink(ctx, "https://t.me/+aBCdeFG123AAAAAA"); err != nil { return err } return nil }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := sendJoin(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
func (*Sender) Peer ¶
func (s *Sender) Peer(uctx tg.Entities, upd PeerUpdate, decorators ...peer.PromiseDecorator) *RequestBuilder
Peer uses given peer update to create message for same chat.
func (*Sender) PeerPromise ¶
func (s *Sender) PeerPromise(p peer.Promise, decorators ...peer.PromiseDecorator) *RequestBuilder
PeerPromise uses given peer promise to create new message builder.
func (*Sender) Reply ¶
func (s *Sender) Reply(uctx tg.Entities, upd AnswerableMessageUpdate, decorators ...peer.PromiseDecorator) *Builder
Reply uses given message update to create message for same chat and create a reply. Shorthand for
sender.Answer(uctx, upd).ReplyMsg(upd.GetMessage())
func (*Sender) Resolve ¶
func (s *Sender) Resolve(from string, decorators ...peer.PromiseDecorator) *RequestBuilder
Resolve uses given text to create new message builder. It resolves peer of message using Sender's PeerResolver. Input examples:
@telegram telegram t.me/telegram https://t.me/telegram tg:resolve?domain=telegram tg://resolve?domain=telegram +13115552368 +1 (311) 555-0123 +1 311 555-6162
Example ¶
package main import ( "context" "fmt" "os" "os/signal" "bitbucket.org/hokego/hokego-td/telegram" "bitbucket.org/hokego/hokego-td/telegram/message" "bitbucket.org/hokego/hokego-td/telegram/message/peer" "bitbucket.org/hokego/hokego-td/tg" ) func resolve(ctx context.Context) error { client, err := telegram.ClientFromEnvironment(telegram.Options{}) if err != nil { return err } return client.Run(ctx, func(ctx context.Context) error { sender := message.NewSender(tg.NewClient(client)) // Resolve and return input peer for @misato. _, err := sender.Resolve("misato").AsInputPeer(ctx) if err != nil { return err } // Resolve and join channel @seele. // If @seele is a user, not channel, error would be returned. _, err = sender.Resolve("seele", peer.OnlyChannel).Join(ctx) if err != nil { return err } return nil }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := resolve(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
func (*Sender) ResolveDeeplink ¶
func (s *Sender) ResolveDeeplink(link string, decorators ...peer.PromiseDecorator) *RequestBuilder
ResolveDeeplink uses given deeplink to create new message builder. Deeplink is a URL like https://t.me/telegram. It resolves peer of message using Sender's PeerResolver. Input examples:
t.me/telegram https://t.me/telegram tg:resolve?domain=telegram tg://resolve?domain=telegram
func (*Sender) ResolveDomain ¶
func (s *Sender) ResolveDomain(domain string, decorators ...peer.PromiseDecorator) *RequestBuilder
ResolveDomain uses given domain to create new message builder. It resolves peer of message using Sender's PeerResolver. Can has prefix with @ or not. Input examples:
@telegram telegram
func (*Sender) ResolvePhone ¶
func (s *Sender) ResolvePhone(phone string, decorators ...peer.PromiseDecorator) *RequestBuilder
ResolvePhone uses given phone to create new peer promise. It resolves peer of message using given Resolver. Input example:
+13115552368 +1 (311) 555-0123 +1 311 555-6162
NB: ResolvePhone just deletes any non-digit symbols from phone argument. For now, Telegram sends contact number as string like "13115552368".
func (*Sender) Self ¶
func (s *Sender) Self() *RequestBuilder
Self creates a new message builder to send it to yourself. It means that message will be sent to your Saved Messages folder.
func (*Sender) To ¶
func (s *Sender) To(p tg.InputPeerClass) *RequestBuilder
To uses given peer to create new message builder.
func (*Sender) WithResolver ¶
WithResolver sets peer resolver to use.
func (*Sender) WithUploader ¶
WithUploader sets file uploader to use.
type StyledTextOption ¶
type StyledTextOption = styling.StyledTextOption
StyledTextOption is an option for styling text.
type TypingActionBuilder ¶
type TypingActionBuilder struct {
// contains filtered or unexported fields
}
TypingActionBuilder is a helper to create and send typing actions.
See https://core.telegram.org/method/messages.setTyping.
See https://core.telegram.org/type/SendMessageAction.
func (*TypingActionBuilder) Cancel ¶
func (b *TypingActionBuilder) Cancel(ctx context.Context) error
Cancel sends SendMessageCancelAction.
func (*TypingActionBuilder) ChooseContact ¶
func (b *TypingActionBuilder) ChooseContact(ctx context.Context) error
ChooseContact sends SendMessageChooseContactAction.
func (*TypingActionBuilder) ChooseSticker ¶
func (b *TypingActionBuilder) ChooseSticker(ctx context.Context) error
ChooseSticker sends SendMessageChooseStickerAction.
func (*TypingActionBuilder) Custom ¶
func (b *TypingActionBuilder) Custom(ctx context.Context, action tg.SendMessageActionClass) error
Custom sends given action.
func (*TypingActionBuilder) EmojiInteraction ¶
func (b *TypingActionBuilder) EmojiInteraction(ctx context.Context, emoticon string, msgID int, interaction tg.DataJSON) error
EmojiInteraction sends SendMessageEmojiInteraction.
func (*TypingActionBuilder) EmojiInteractionSeen ¶
func (b *TypingActionBuilder) EmojiInteractionSeen(ctx context.Context, emoticon string) error
EmojiInteractionSeen sends SendMessageEmojiInteractionSeen.
func (*TypingActionBuilder) GamePlay ¶
func (b *TypingActionBuilder) GamePlay(ctx context.Context) error
GamePlay sends SendMessageGamePlayAction.
func (*TypingActionBuilder) GeoLocation ¶
func (b *TypingActionBuilder) GeoLocation(ctx context.Context) error
GeoLocation sends SendMessageGeoLocationAction.
func (*TypingActionBuilder) HistoryImport ¶
func (b *TypingActionBuilder) HistoryImport(ctx context.Context, progress int) error
HistoryImport sends SendMessageHistoryImportAction.
func (*TypingActionBuilder) RecordAudio ¶
func (b *TypingActionBuilder) RecordAudio(ctx context.Context) error
RecordAudio sends SendMessageRecordAudioAction.
func (*TypingActionBuilder) RecordRound ¶
func (b *TypingActionBuilder) RecordRound(ctx context.Context) error
RecordRound sends SendMessageRecordRoundAction.
func (*TypingActionBuilder) RecordVideo ¶
func (b *TypingActionBuilder) RecordVideo(ctx context.Context) error
RecordVideo sends SendMessageRecordVideoAction.
func (*TypingActionBuilder) SpeakingInGroupCall ¶
func (b *TypingActionBuilder) SpeakingInGroupCall(ctx context.Context) error
SpeakingInGroupCall sends SpeakingInGroupCallAction.
func (*TypingActionBuilder) ThreadID ¶
func (b *TypingActionBuilder) ThreadID(id int) *TypingActionBuilder
ThreadID sets thread ID to send.
func (*TypingActionBuilder) ThreadMsg ¶
func (b *TypingActionBuilder) ThreadMsg(msg tg.MessageClass) *TypingActionBuilder
ThreadMsg sets message's ID as thread ID to send.
func (*TypingActionBuilder) Typing ¶
func (b *TypingActionBuilder) Typing(ctx context.Context) error
Typing sends SendMessageTypingAction.
func (*TypingActionBuilder) UploadAudio ¶
func (b *TypingActionBuilder) UploadAudio(ctx context.Context, progress int) error
UploadAudio sends SendMessageUploadAudioAction.
func (*TypingActionBuilder) UploadDocument ¶
func (b *TypingActionBuilder) UploadDocument(ctx context.Context, progress int) error
UploadDocument sends SendMessageUploadDocumentAction.
func (*TypingActionBuilder) UploadPhoto ¶
func (b *TypingActionBuilder) UploadPhoto(ctx context.Context, progress int) error
UploadPhoto sends SendMessageUploadPhotoAction.
func (*TypingActionBuilder) UploadRound ¶
func (b *TypingActionBuilder) UploadRound(ctx context.Context, progress int) error
UploadRound sends SendMessageUploadRoundAction.
func (*TypingActionBuilder) UploadVideo ¶
func (b *TypingActionBuilder) UploadVideo(ctx context.Context, progress int) error
UploadVideo sends SendMessageUploadVideoAction.
type UploadBuilder ¶
type UploadBuilder struct {
// contains filtered or unexported fields
}
UploadBuilder is an attachment uploading helper.
func (*UploadBuilder) AsInputFile ¶
func (u *UploadBuilder) AsInputFile(ctx context.Context) (tg.InputFileClass, error)
AsInputFile uploads and returns uploaded file entity.
func (*UploadBuilder) Audio ¶
func (u *UploadBuilder) Audio(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
Audio uploads and sends audio file.
func (*UploadBuilder) File ¶
func (u *UploadBuilder) File(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
File uploads and sends plain file.
func (*UploadBuilder) GIF ¶
func (u *UploadBuilder) GIF(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
GIF uploads and sends gif file.
func (*UploadBuilder) Photo ¶
func (u *UploadBuilder) Photo(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
Photo uploads and sends photo.
func (*UploadBuilder) RoundVideo ¶
func (u *UploadBuilder) RoundVideo(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
RoundVideo uploads and sends round video.
func (*UploadBuilder) Sticker ¶
func (u *UploadBuilder) Sticker(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
Sticker uploads and sends sticker.
func (*UploadBuilder) Video ¶
func (u *UploadBuilder) Video(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)
Video uploads and sends video.
func (*UploadBuilder) Voice ¶
func (u *UploadBuilder) Voice(ctx context.Context) (tg.UpdatesClass, error)
Voice uploads and sends voice message.
type UploadOption ¶
type UploadOption interface {
// contains filtered or unexported methods
}
UploadOption is a UploadBuilder creation option.
func FromBytes ¶
func FromBytes(name string, data []byte) UploadOption
FromBytes uploads file from given byte slice.
func FromFS ¶
func FromFS(filesystem fs.FS, path string) UploadOption
FromFS uploads file from given path using given fs.FS.
func FromFile ¶
func FromFile(f uploader.File) UploadOption
FromFile uploads given File. NB: FromFile does not close given file.
func FromReader ¶
func FromReader(name string, r io.Reader) UploadOption
FromReader uploads file from given io.Reader. NB: totally stream should not exceed the limit for small files (10 MB as docs says, may be a bit bigger).
func FromSource ¶
func FromSource(src source.Source, rawURL string) UploadOption
FromSource uploads file from given URL using given Source.
func Upload ¶
func Upload(promise FilePromise) UploadOption
Upload creates new upload options using given promise.
Example ¶
package main import ( "context" "fmt" "os" "os/signal" "github.com/go-faster/errors" "bitbucket.org/hokego/hokego-td/telegram" "bitbucket.org/hokego/hokego-td/telegram/message" "bitbucket.org/hokego/hokego-td/tg" ) func filePromiseResult(ctx context.Context) error { client, err := telegram.ClientFromEnvironment(telegram.Options{}) if err != nil { return err } return client.Run(ctx, func(ctx context.Context) error { sender := message.NewSender(tg.NewClient(client)) r := sender.Resolve("@durov") var result tg.InputFileClass _, err := r.Upload(message.Upload(func(ctx context.Context, b message.Uploader) (tg.InputFileClass, error) { r, err := b.FromPath(ctx, "file.jpg") if err != nil { return nil, err } result = r return r, nil })).Photo(ctx) if err != nil { return errors.Wrap(err, "upload photo") } _, err = r.Media(ctx, message.UploadedDocument(result)) if err != nil { return errors.Wrap(err, "upload document") } return nil }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := filePromiseResult(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
type UploadedDocumentBuilder ¶
type UploadedDocumentBuilder struct {
// contains filtered or unexported fields
}
UploadedDocumentBuilder is a UploadedDocument media option.
func File ¶
func File(file tg.InputFileClass, caption ...StyledTextOption) *UploadedDocumentBuilder
File adds document attachment and forces it to be used as plain file, not media.
func GIF ¶
func GIF(file tg.InputFileClass, caption ...StyledTextOption) *UploadedDocumentBuilder
GIF adds gif attachment.
Example ¶
package main import ( "context" "fmt" "os" "os/signal" "bitbucket.org/hokego/hokego-td/telegram" "bitbucket.org/hokego/hokego-td/telegram/message" "bitbucket.org/hokego/hokego-td/tg" ) func sendGif(ctx context.Context) error { client, err := telegram.ClientFromEnvironment(telegram.Options{}) if err != nil { return err } return client.Run(ctx, func(ctx context.Context) error { sender := message.NewSender(tg.NewClient(client)) // Uploads and sends gif to the @durovschat. if _, err := sender.Resolve("https://t.me/durovschat"). Upload(message.FromPath("./rickroll.gif")). GIF(ctx); err != nil { return err } return nil }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := sendGif(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
func UploadedDocument ¶
func UploadedDocument(file tg.InputFileClass, caption ...StyledTextOption) *UploadedDocumentBuilder
UploadedDocument adds document attachment.
func (*UploadedDocumentBuilder) Attributes ¶
func (u *UploadedDocumentBuilder) Attributes(attrs ...tg.DocumentAttributeClass) *UploadedDocumentBuilder
Attributes adds given attributes to the document. Attribute specify the type of the document (video, audio, voice, sticker, etc.).
func (*UploadedDocumentBuilder) Audio ¶
func (u *UploadedDocumentBuilder) Audio() *AudioDocumentBuilder
Audio creates new AudioDocumentBuilder to create audio attachment.
func (*UploadedDocumentBuilder) Filename ¶
func (u *UploadedDocumentBuilder) Filename(name string) *UploadedDocumentBuilder
Filename sets name of uploaded file.
func (*UploadedDocumentBuilder) ForceFile ¶
func (u *UploadedDocumentBuilder) ForceFile(v bool) *UploadedDocumentBuilder
ForceFile sets flag to force the media file to be uploaded as document.
func (*UploadedDocumentBuilder) GIF ¶
func (u *UploadedDocumentBuilder) GIF() *UploadedDocumentBuilder
GIF add attributes to create GIF attachment.
func (*UploadedDocumentBuilder) HasStickers ¶
func (u *UploadedDocumentBuilder) HasStickers() *UploadedDocumentBuilder
HasStickers sets flag that document attachment has stickers.
func (*UploadedDocumentBuilder) MIME ¶
func (u *UploadedDocumentBuilder) MIME(mime string) *UploadedDocumentBuilder
MIME sets MIME type of document.
func (*UploadedDocumentBuilder) NosoundVideo ¶
func (u *UploadedDocumentBuilder) NosoundVideo(v bool) *UploadedDocumentBuilder
NosoundVideo sets flag that the specified document is a video file with no audio tracks (a GIF animation (even as MPEG4), for example).
func (*UploadedDocumentBuilder) RoundVideo ¶
func (u *UploadedDocumentBuilder) RoundVideo() *VideoDocumentBuilder
RoundVideo creates new VideoDocumentBuilder to create round video attachment.
func (*UploadedDocumentBuilder) Stickers ¶
func (u *UploadedDocumentBuilder) Stickers(stickers ...FileLocation) *UploadedDocumentBuilder
Stickers adds attached mask stickers.
func (*UploadedDocumentBuilder) TTL ¶
func (u *UploadedDocumentBuilder) TTL(ttl time.Duration) *UploadedDocumentBuilder
TTL sets time to live of self-destructing document.
func (*UploadedDocumentBuilder) TTLSeconds ¶
func (u *UploadedDocumentBuilder) TTLSeconds(ttl int) *UploadedDocumentBuilder
TTLSeconds sets time to live in seconds of self-destructing document.
func (*UploadedDocumentBuilder) Thumb ¶
func (u *UploadedDocumentBuilder) Thumb(file tg.InputFileClass) *UploadedDocumentBuilder
Thumb sets thumbnail of the document, uploaded as for the file.
func (*UploadedDocumentBuilder) UploadedSticker ¶
func (u *UploadedDocumentBuilder) UploadedSticker() *UploadedStickerBuilder
UploadedSticker creates new UploadedStickerBuilder to create sticker attachment.
func (*UploadedDocumentBuilder) Video ¶
func (u *UploadedDocumentBuilder) Video() *VideoDocumentBuilder
Video creates new VideoDocumentBuilder to create video attachment.
func (*UploadedDocumentBuilder) Voice ¶
func (u *UploadedDocumentBuilder) Voice() *AudioDocumentBuilder
Voice creates new AudioDocumentBuilder to create voice attachment.
type UploadedPhotoBuilder ¶
type UploadedPhotoBuilder struct {
// contains filtered or unexported fields
}
UploadedPhotoBuilder is a UploadedPhoto media option.
func UploadedPhoto ¶
func UploadedPhoto(file tg.InputFileClass, caption ...StyledTextOption) *UploadedPhotoBuilder
UploadedPhoto adds photo attachment.
func (*UploadedPhotoBuilder) Stickers ¶
func (u *UploadedPhotoBuilder) Stickers(stickers ...FileLocation) *UploadedPhotoBuilder
Stickers adds attached mask stickers.
func (*UploadedPhotoBuilder) TTL ¶
func (u *UploadedPhotoBuilder) TTL(ttl time.Duration) *UploadedPhotoBuilder
TTL sets time to live of self-destructing photo.
func (*UploadedPhotoBuilder) TTLSeconds ¶
func (u *UploadedPhotoBuilder) TTLSeconds(ttl int) *UploadedPhotoBuilder
TTLSeconds sets time to live in seconds of self-destructing photo.
type UploadedStickerBuilder ¶
type UploadedStickerBuilder struct {
// contains filtered or unexported fields
}
UploadedStickerBuilder is a uploaded sticker media option.
func UploadedSticker ¶
func UploadedSticker(file tg.InputFileClass, caption ...StyledTextOption) *UploadedStickerBuilder
UploadedSticker adds uploaded sticker attachment.
func (*UploadedStickerBuilder) Alt ¶
func (u *UploadedStickerBuilder) Alt(alt string) *UploadedStickerBuilder
Alt sets alternative emoji representation of sticker.
func (*UploadedStickerBuilder) Mask ¶
func (u *UploadedStickerBuilder) Mask(mask bool) *UploadedStickerBuilder
Mask sets flag that is a mask sticker.
func (*UploadedStickerBuilder) MaskCoords ¶
func (u *UploadedStickerBuilder) MaskCoords(maskCoords tg.MaskCoords) *UploadedStickerBuilder
MaskCoords sets mask coordinates (if this is a mask sticker, attached to a photo).
func (*UploadedStickerBuilder) StickerSet ¶
func (u *UploadedStickerBuilder) StickerSet(stickerSet tg.InputStickerSetClass) *UploadedStickerBuilder
StickerSet sets associated sticker set.
type Uploader ¶
type Uploader interface { FromFile(ctx context.Context, f uploader.File) (tg.InputFileClass, error) FromPath(ctx context.Context, path string) (tg.InputFileClass, error) FromFS(ctx context.Context, filesystem fs.FS, path string) (tg.InputFileClass, error) FromReader(ctx context.Context, name string, f io.Reader) (tg.InputFileClass, error) FromBytes(ctx context.Context, name string, b []byte) (tg.InputFileClass, error) FromURL(ctx context.Context, rawURL string) (tg.InputFileClass, error) FromSource(ctx context.Context, src source.Source, rawURL string) (tg.InputFileClass, error) }
Uploader is an abstraction for Telegram file uploader.
type VideoDocumentBuilder ¶
type VideoDocumentBuilder struct {
// contains filtered or unexported fields
}
VideoDocumentBuilder is a Video media option.
func RoundVideo ¶
func RoundVideo(file tg.InputFileClass, caption ...StyledTextOption) *VideoDocumentBuilder
RoundVideo adds round video attachment.
func Video ¶
func Video(file tg.InputFileClass, caption ...StyledTextOption) *VideoDocumentBuilder
Video adds video attachment.
func (*VideoDocumentBuilder) Duration ¶
func (u *VideoDocumentBuilder) Duration(duration time.Duration) *VideoDocumentBuilder
Duration sets duration of video file.
func (*VideoDocumentBuilder) DurationSeconds ¶
func (u *VideoDocumentBuilder) DurationSeconds(duration int) *VideoDocumentBuilder
DurationSeconds sets duration in seconds.
func (*VideoDocumentBuilder) Resolution ¶
func (u *VideoDocumentBuilder) Resolution(w, h int) *VideoDocumentBuilder
Resolution sets resolution of this video.
func (*VideoDocumentBuilder) Round ¶
func (u *VideoDocumentBuilder) Round() *VideoDocumentBuilder
Round sets flag to mark this video as round.
func (*VideoDocumentBuilder) SupportsStreaming ¶
func (u *VideoDocumentBuilder) SupportsStreaming() *VideoDocumentBuilder
SupportsStreaming sets flag to mark this video as which supports streaming.
Source Files ¶
- audio.go
- builder.go
- check.go
- contact.go
- delete.go
- dice.go
- doc.go
- document.go
- draft.go
- edit.go
- file.go
- file_promise.go
- format.go
- forward.go
- game.go
- geo_point.go
- gif.go
- inline.go
- join.go
- media.go
- mime.go
- multi.go
- peer.go
- peer_unpack.go
- photo.go
- poll.go
- report.go
- request.go
- scheduled.go
- sender.go
- stickers.go
- style.go
- text.go
- types.go
- typing.gen.go
- typing.go
- upload.go
- video.go
Directories ¶
Path | Synopsis |
---|---|
Package entity contains message formatting and styling helpers.
|
Package entity contains message formatting and styling helpers. |
Package html contains HTML styling options.
|
Package html contains HTML styling options. |
Package inline contains inline query results builder.
|
Package inline contains inline query results builder. |
internal
|
|
mkrun
Package mkrun contains some helpers for generation scripts.
|
Package mkrun contains some helpers for generation scripts. |
mktyping
Binary mktyping generates TypingActionBuilder.
|
Binary mktyping generates TypingActionBuilder. |
Package markup contain bots inline markup builder.
|
Package markup contain bots inline markup builder. |
Package peer conatains some peer resolving and extracting helpers.
|
Package peer conatains some peer resolving and extracting helpers. |
Package styling contains styling options for Telegram messages.
|
Package styling contains styling options for Telegram messages. |
Package unpack contains some updates result unpacking helpers.
|
Package unpack contains some updates result unpacking helpers. |