message

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 15 Imported by: 76

Documentation

Overview

Package message contains some useful utilities for creating Telegram messages.

Index

Examples

Constants

View Source
const (
	// DiceEmoticon is a emoticon to send dice sticker.
	DiceEmoticon = "🎲"
	// DartsEmoticon is a emoticon to send darts sticker.
	DartsEmoticon = "🎯"
	// BasketballEmoticon is a emoticon to send basketball sticker.
	BasketballEmoticon = "🏀"
)
View Source
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

func StartBotInputUser added in v0.26.0

func StartBotInputUser(bot tg.InputUserClass) func(s *startBotBuilder)

StartBotInputUser sets InputUserClass to start bot.

func StartBotParam added in v0.26.0

func StartBotParam(param string) func(s *startBotBuilder)

StartBotParam sets deeplink param to start bot.

Types

type AnswerableMessageUpdate added in v0.26.0

type AnswerableMessageUpdate interface {
	GetMessage() tg.MessageClass
	GetPts() int
}

AnswerableMessageUpdate represents update which can be used to answer.

type AudioDocumentBuilder added in v0.26.0

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

AudioDocumentBuilder is a Audio media option.

func Audio added in v0.26.0

func Audio(file tg.InputFileClass, caption ...StyledTextOption) *AudioDocumentBuilder

Audio adds audio attachment.

Example
package main

import (
	"context"
	"fmt"
	"os"
	"os/signal"

	"golang.org/x/xerrors"

	"github.com/gotd/td/telegram"
	"github.com/gotd/td/telegram/message"
	"github.com/gotd/td/telegram/uploader"
	"github.com/gotd/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 xerrors.Errorf("upload: %w", err)
		}

		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 Voice added in v0.26.0

Voice adds voice attachment.

func (*AudioDocumentBuilder) Duration added in v0.26.0

func (u *AudioDocumentBuilder) Duration(duration time.Duration) *AudioDocumentBuilder

Duration sets duration of audio file.

func (*AudioDocumentBuilder) DurationSeconds added in v0.26.0

func (u *AudioDocumentBuilder) DurationSeconds(duration int) *AudioDocumentBuilder

DurationSeconds sets duration in seconds.

func (*AudioDocumentBuilder) Performer added in v0.26.0

func (u *AudioDocumentBuilder) Performer(performer string) *AudioDocumentBuilder

Performer sets performer.

func (*AudioDocumentBuilder) Title added in v0.26.0

Title sets name of song.

func (*AudioDocumentBuilder) Voice added in v0.26.0

Voice sets flag to mark this audio as voice message.

func (*AudioDocumentBuilder) Waveform added in v0.26.0

func (u *AudioDocumentBuilder) Waveform(waveform []byte) *AudioDocumentBuilder

Waveform sets waveform representation of the voice message.

type Builder added in v0.26.0

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

Builder is a message builder.

func (*Builder) Album added in v0.26.0

func (b *Builder) Album(ctx context.Context, media MultiMediaOption, album ...MultiMediaOption) (tg.UpdatesClass, error)

Album sends message with multiple media attachments.

func (*Builder) Audio added in v0.26.0

func (b *Builder) Audio(
	ctx context.Context,
	file tg.InputFileClass, caption ...StyledTextOption,
) (tg.UpdatesClass, error)

Audio sends audio file.

func (*Builder) Background added in v0.26.0

func (b *Builder) Background() *Builder

Background sets flag to send this message as background message.

func (*Builder) Basketball added in v0.26.0

func (b *Builder) Basketball(ctx context.Context) (tg.UpdatesClass, error)

Basketball sends a basketball animated sticker.

func (*Builder) Clear added in v0.26.0

func (b *Builder) Clear() *Builder

Clear sets flag to clear the draft field.

func (*Builder) ClearDraft added in v0.26.0

func (b *Builder) ClearDraft(ctx context.Context) error

ClearDraft clears draft. Also, you can use Clear() builder option with any other message send method.

See https://core.telegram.org/api/drafts#clearing-drafts.

func (*Builder) Darts added in v0.26.0

func (b *Builder) Darts(ctx context.Context) (tg.UpdatesClass, error)

Darts sends a darts animated sticker.

func (*Builder) Dice added in v0.26.0

func (b *Builder) Dice(ctx context.Context) (tg.UpdatesClass, error)

Dice sends a dice animated sticker.

func (*Builder) Document added in v0.26.0

func (b *Builder) Document(
	ctx context.Context, file FileLocation, caption ...StyledTextOption,
) (tg.UpdatesClass, error)

Document sends document.

func (*Builder) DocumentByHash added in v0.26.0

func (b *Builder) DocumentByHash(
	ctx context.Context, hash []byte, size int, mime string,
	caption ...StyledTextOption,
) (tg.UpdatesClass, error)

DocumentByHash finds document by hash and sends as attachment.

func (*Builder) DocumentExternal added in v0.26.0

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) Edit added in v0.26.0

func (b *Builder) Edit(id int) *EditMessageBuilder

Edit edits message by ID.

func (*Builder) File added in v0.26.0

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 added in v0.26.0

func (b *Builder) ForwardIDs(from tg.InputPeerClass, id int, ids ...int) *ForwardBuilder

ForwardIDs creates builder to forward messages by ID.

func (*Builder) ForwardMessages added in v0.26.0

func (b *Builder) ForwardMessages(from tg.InputPeerClass, msg tg.MessageClass, m ...tg.MessageClass) *ForwardBuilder

ForwardMessages creates builder to forward messages.

func (*Builder) GIF added in v0.26.0

func (b *Builder) GIF(
	ctx context.Context,
	file tg.InputFileClass, caption ...StyledTextOption,
) (tg.UpdatesClass, error)

GIF sends gif.

func (*Builder) InlineResult added in v0.26.0

func (b *Builder) InlineResult(ctx context.Context, id string, queryID int64, hideVia bool) (tg.UpdatesClass, error)

InlineResult sends inline query result message.

func (*Builder) Markup added in v0.26.0

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 added in v0.26.0

func (b *Builder) Media(ctx context.Context, media MediaOption) (tg.UpdatesClass, error)

Media sends message with media attachment.

func (*Builder) NoWebpage added in v0.26.0

func (b *Builder) NoWebpage() *Builder

NoWebpage sets flag to disable generation of the webpage preview.

func (*Builder) Photo added in v0.26.0

func (b *Builder) Photo(
	ctx context.Context,
	photo FileLocation, caption ...StyledTextOption,
) (tg.UpdatesClass, error)

Photo sends photo.

func (*Builder) PhotoExternal added in v0.26.0

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) Reply added in v0.26.0

func (b *Builder) Reply(id int) *Builder

Reply sets message ID to reply.

func (*Builder) ReplyMsg added in v0.26.0

func (b *Builder) ReplyMsg(msg tg.MessageClass) *Builder

ReplyMsg sets message to reply.

func (*Builder) RoundVideo added in v0.26.0

func (b *Builder) RoundVideo(
	ctx context.Context,
	file tg.InputFileClass, caption ...StyledTextOption,
) (tg.UpdatesClass, error)

RoundVideo sends round video.

func (*Builder) Row added in v0.26.0

func (b *Builder) Row(button tg.KeyboardButtonClass, 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 added in v0.26.0

func (b *Builder) SaveDraft(ctx context.Context, msg string) error

SaveDraft saves given message as draft.

See https://core.telegram.org/api/drafts#saving-drafts.

Example
package main

import (
	"context"
	"fmt"
	"os"
	"os/signal"

	"golang.org/x/xerrors"

	"github.com/gotd/td/telegram"
	"github.com/gotd/td/telegram/message"
	"github.com/gotd/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 xerrors.Errorf("draft: %w", err)
		}

		// Save styled draft message.
		if err := r.SaveStyledDraft(ctx, message.Bold("Hi!")); err != nil {
			return xerrors.Errorf("draft: %w", err)
		}

		// Clear draft for resolved @durov peer.
		if err := r.ClearDraft(ctx); err != nil {
			return xerrors.Errorf("draft: %w", err)
		}

		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 added in v0.26.0

func (b *Builder) SaveStyledDraft(ctx context.Context, text StyledTextOption, texts ...StyledTextOption) error

SaveStyledDraft saves given styled message as draft.

See https://core.telegram.org/api/drafts#saving-drafts.

func (*Builder) Schedule added in v0.26.0

func (b *Builder) Schedule(date time.Time) *Builder

Schedule sets scheduled message date for scheduled messages.

func (*Builder) ScheduleTS added in v0.26.0

func (b *Builder) ScheduleTS(date int) *Builder

ScheduleTS sets scheduled message timestamp for scheduled messages.

func (*Builder) Silent added in v0.26.0

func (b *Builder) Silent() *Builder

Silent sets flag to send this message silently (no notifications for the receivers).

func (*Builder) StyledText added in v0.26.0

func (b *Builder) StyledText(
	ctx context.Context, text StyledTextOption, texts ...StyledTextOption,
) (tg.UpdatesClass, error)

StyledText sends styled text message.

Example
package main

import (
	"context"
	"fmt"
	"os"
	"os/signal"

	"github.com/gotd/td/telegram"
	"github.com/gotd/td/telegram/message"
	"github.com/gotd/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{
			message.Plain("plaintext"), message.Plain("\n\n"),
			message.Mention("@durov"), message.Plain("\n\n"),
			message.Hashtag("#hashtag"), message.Plain("\n\n"),
			message.BotCommand("/command"), message.Plain("\n\n"),
			message.URL("https://google.org"), message.Plain("\n\n"),
			message.Email("example@example.org"), message.Plain("\n\n"),
			message.Bold("bold"), message.Plain("\n\n"),
			message.Italic("italic"), message.Plain("\n\n"),
			message.Underline("underline"), message.Plain("\n\n"),
			message.Strike("strike"), message.Plain("\n\n"),
			message.Code("fmt.Println(`Hello, World!`)"), message.Plain("\n\n"),
			message.Pre("fmt.Println(`Hello, World!`)", "Go"), message.Plain("\n\n"),
			message.TextURL("clickme", "https://google.com"), message.Plain("\n\n"),
			message.Phone("+71234567891"), message.Plain("\n\n"),
			message.Cashtag("$cashtag"), message.Plain("\n\n"),
			message.Blockquote("blockquote"), message.Plain("\n\n"),
			message.BankCard("5550111111111111"), message.Plain("\n\n"),
		}

		_, err := message.NewSender(tg.NewClient(client)).
			Self().StyledText(ctx, formats[0], formats[1:]...)
		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 added in v0.26.0

func (b *Builder) Text(ctx context.Context, msg string) (tg.UpdatesClass, error)

Text sends text message.

Example
package main

import (
	"context"
	"fmt"
	"os"
	"os/signal"

	"github.com/gotd/td/telegram"
	"github.com/gotd/td/telegram/message"
	"github.com/gotd/td/tg"
)

func sendText(ctx context.Context) error {
	client, err := telegram.ClientFromEnvironment(telegram.Options{})
	if err != nil {
		return err
	}

	// This example creates a plaing message and sends it
	// to your Saved Message folder.
	return client.Run(ctx, func(ctx context.Context) error {
		_, err := message.NewSender(tg.NewClient(client)).Self().Text(ctx, "Hi!")
		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) Upload added in v0.27.0

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 added in v0.26.0

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).

See https://core.telegram.org/method/messages.uploadMedia.

func (*Builder) UploadedPhoto added in v0.26.0

func (b *Builder) UploadedPhoto(
	ctx context.Context,
	file tg.InputFileClass, caption ...StyledTextOption,
) (tg.UpdatesClass, error)

UploadedPhoto sends uploaded file as photo.

func (*Builder) UploadedSticker added in v0.26.0

func (b *Builder) UploadedSticker(
	ctx context.Context,
	file tg.InputFileClass, caption ...StyledTextOption,
) (tg.UpdatesClass, error)

UploadedSticker sends uploaded file as sticker.

func (*Builder) Video added in v0.26.0

func (b *Builder) Video(
	ctx context.Context,
	file tg.InputFileClass, caption ...StyledTextOption,
) (tg.UpdatesClass, error)

Video sends video.

func (*Builder) Voice added in v0.26.0

func (b *Builder) Voice(ctx context.Context, file tg.InputFileClass) (tg.UpdatesClass, error)

Voice sends voice message.

type DocumentBuilder added in v0.26.0

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

DocumentBuilder is a Document media option.

func Document added in v0.26.0

func Document(doc FileLocation, caption ...StyledTextOption) *DocumentBuilder

Document adds document attachment.

func (*DocumentBuilder) Query added in v0.26.0

func (u *DocumentBuilder) Query(query string) *DocumentBuilder

Query sets query field of InputMediaDocument.

func (*DocumentBuilder) TTL added in v0.26.0

TTL sets time to live of self-destructing document.

func (*DocumentBuilder) TTLSeconds added in v0.26.0

func (u *DocumentBuilder) TTLSeconds(ttl int) *DocumentBuilder

TTLSeconds sets time to live in seconds of self-destructing document.

type DocumentExternalBuilder added in v0.26.0

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

DocumentExternalBuilder is a DocumentExternal media option.

func DocumentExternal added in v0.26.0

func DocumentExternal(url string, caption ...StyledTextOption) *DocumentExternalBuilder

DocumentExternal adds document attachment that will be downloaded by the Telegram servers.

func (*DocumentExternalBuilder) TTL added in v0.26.0

TTL sets time to live of self-destructing document.

func (*DocumentExternalBuilder) TTLSeconds added in v0.26.0

TTLSeconds sets time to live in seconds of self-destructing document.

type EditMessageBuilder added in v0.26.0

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

EditMessageBuilder creates edit message builder.

func (*EditMessageBuilder) Media added in v0.26.0

Media edits message using given media and text.

func (*EditMessageBuilder) StyledText added in v0.26.0

func (b *EditMessageBuilder) StyledText(
	ctx context.Context,
	text StyledTextOption, texts ...StyledTextOption,
) (tg.UpdatesClass, error)

StyledText edits message using given message.

func (*EditMessageBuilder) Text added in v0.26.0

Text edits message using given message.

type FileLocation added in v0.26.0

type FileLocation interface {
	GetID() (value int64)
	GetAccessHash() (value int64)
	GetFileReference() (value []byte)
}

FileLocation is a abstraction of Telegram file location.

type ForwardBuilder added in v0.26.0

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

ForwardBuilder is a forward request builder.

func (*ForwardBuilder) Send added in v0.26.0

Send sends forwarded messages.

func (*ForwardBuilder) WithMyScore added in v0.26.0

func (b *ForwardBuilder) WithMyScore() *ForwardBuilder

WithMyScore sets flag to include your score in the forwarded game.

type MediaOption added in v0.26.0

type MediaOption interface {
	// contains filtered or unexported methods
}

MediaOption is a option for sending media attachments.

func Basketball added in v0.26.0

func Basketball() MediaOption

Basketball adds a basketball animated sticker.

func Contact added in v0.26.0

func Contact(contact tg.InputMediaContact, caption ...StyledTextOption) MediaOption

Contact adds contact attachment.

func Darts added in v0.26.0

func Darts() MediaOption

Darts adds a darts animated sticker.

func Dice added in v0.26.0

func Dice() MediaOption

Dice adds a dice animated sticker.

func Game added in v0.26.0

func Game(id tg.InputGameClass, caption ...StyledTextOption) MediaOption

Game adds a game attachment.

func GeoPoint added in v0.26.0

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 added in v0.26.0

func Media(media tg.InputMediaClass, caption ...StyledTextOption) MediaOption

Media adds given media attachment to message.

func MediaDice added in v0.26.0

func MediaDice(emoticon string) MediaOption

MediaDice adds a dice-based animated sticker.

Example
package main

import (
	"context"
	"fmt"
	"os"
	"os/signal"

	"github.com/gotd/td/telegram"
	"github.com/gotd/td/telegram/message"
	"github.com/gotd/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 added in v0.26.0

type MultiMediaOption interface {
	MediaOption
	// contains filtered or unexported methods
}

MultiMediaOption is a option for sending albums.

func ForceMulti added in v0.26.0

func ForceMulti(opt MediaOption) MultiMediaOption

ForceMulti converts MediaOption to MultiMediaOption. It can produce unexpected RPC errors. Use carefully.

type PhotoBuilder added in v0.26.0

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

PhotoBuilder is a Photo media option.

func Photo added in v0.26.0

func Photo(photo FileLocation, caption ...StyledTextOption) *PhotoBuilder

Photo adds photo attachment.

func (*PhotoBuilder) TTL added in v0.26.0

func (u *PhotoBuilder) TTL(ttl time.Duration) *PhotoBuilder

TTL sets time to live of self-destructing photo.

func (*PhotoBuilder) TTLSeconds added in v0.26.0

func (u *PhotoBuilder) TTLSeconds(ttl int) *PhotoBuilder

TTLSeconds sets time to live in seconds of self-destructing photo.

type PhotoExternalBuilder added in v0.26.0

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

PhotoExternalBuilder is a PhotoExternal media option.

func PhotoExternal added in v0.26.0

func PhotoExternal(url string, caption ...StyledTextOption) *PhotoExternalBuilder

PhotoExternal adds photo attachment which will be downloaded by the Telegram servers.

func (*PhotoExternalBuilder) TTL added in v0.26.0

TTL sets time to live of self-destructing document.

func (*PhotoExternalBuilder) TTLSeconds added in v0.26.0

func (u *PhotoExternalBuilder) TTLSeconds(ttl int) *PhotoExternalBuilder

TTLSeconds sets time to live in seconds of self-destructing document.

type PollAnswerOption added in v0.26.0

type PollAnswerOption func(p *pollAnswerBuilder)

PollAnswerOption is a option to create poll answer.

func CorrectPollAnswer added in v0.26.0

func CorrectPollAnswer(text string) PollAnswerOption

CorrectPollAnswer creates new correct poll answer option.

func PollAnswer added in v0.26.0

func PollAnswer(text string) PollAnswerOption

PollAnswer creates new plain poll answer option.

func RawPollAnswer added in v0.26.0

func RawPollAnswer(poll tg.PollAnswer) PollAnswerOption

RawPollAnswer creates new raw poll answer option.

type PollBuilder added in v0.26.0

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

PollBuilder is a Poll media option.

func Poll added in v0.26.0

func Poll(question string, a, b PollAnswerOption, answers ...PollAnswerOption) *PollBuilder

Poll adds poll attachment.

func (*PollBuilder) Close added in v0.26.0

func (p *PollBuilder) Close() *PollBuilder

Close sets flag that the poll is closed and doesn't accept any more answers.

func (*PollBuilder) CloseDate added in v0.26.0

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 added in v0.26.0

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 added in v0.26.0

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 added in v0.26.0

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 added in v0.26.0

func (p *PollBuilder) Explanation(msg string) *PollBuilder

Explanation sets explanation message.

func (*PollBuilder) MultipleChoice added in v0.26.0

func (p *PollBuilder) MultipleChoice(multipleChoice bool) *PollBuilder

MultipleChoice sets flag that multiple options can be chosen as answer.

func (*PollBuilder) PollID added in v0.26.0

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 added in v0.26.0

func (p *PollBuilder) PublicVoters(publicVoters bool) *PollBuilder

PublicVoters sets flag that votes are publicly visible to all users (non-anonymous poll).

func (*PollBuilder) StyledExplanation added in v0.26.0

func (p *PollBuilder) StyledExplanation(text StyledTextOption, texts ...StyledTextOption) *PollBuilder

StyledExplanation sets styled explanation message.

type ReportBuilder added in v0.26.0

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

ReportBuilder is a reporting messages helper.

func (*ReportBuilder) ChildAbuse added in v0.26.0

func (b *ReportBuilder) ChildAbuse(ctx context.Context) (bool, error)

ChildAbuse sends report for child abuse.

func (*ReportBuilder) Copyright added in v0.26.0

func (b *ReportBuilder) Copyright(ctx context.Context) (bool, error)

Copyright sends report for copyrighted content.

func (*ReportBuilder) Fake added in v0.26.0

func (b *ReportBuilder) Fake(ctx context.Context) (bool, error)

Fake sends report for fake.

func (*ReportBuilder) GeoIrrelevant added in v0.26.0

func (b *ReportBuilder) GeoIrrelevant(ctx context.Context) (bool, error)

GeoIrrelevant sends report for irrelevant geogroup.

func (*ReportBuilder) Message added in v0.26.0

func (b *ReportBuilder) Message(msg string) *ReportBuilder

Message sets additional comment for report.

func (*ReportBuilder) Other added in v0.26.0

func (b *ReportBuilder) Other(ctx context.Context) (bool, error)

Other sends report for other.

func (*ReportBuilder) Pornography added in v0.26.0

func (b *ReportBuilder) Pornography(ctx context.Context) (bool, error)

Pornography sends report for pornography.

func (*ReportBuilder) Spam added in v0.26.0

func (b *ReportBuilder) Spam(ctx context.Context) (bool, error)

Spam sends report for spam.

func (*ReportBuilder) Violence added in v0.26.0

func (b *ReportBuilder) Violence(ctx context.Context) (bool, error)

Violence sends report for violence.

type RequestBuilder added in v0.26.0

type RequestBuilder struct {
	Builder
}

RequestBuilder is a intermediate builder to make different RPC calls using Sender.

func (*RequestBuilder) AsInputPeer added in v0.26.0

func (b *RequestBuilder) AsInputPeer(ctx context.Context) (tg.InputPeerClass, error)

AsInputPeer returns resolve result as InputPeerClass.

func (*RequestBuilder) PeerSettings added in v0.26.0

func (b *RequestBuilder) PeerSettings(ctx context.Context) (*tg.PeerSettings, error)

PeerSettings returns peer settings.

func (*RequestBuilder) PollVote added in v0.26.0

func (b *RequestBuilder) PollVote(
	ctx context.Context, msgID int,
	answer []byte, answers ...[]byte,
) (tg.UpdatesClass, error)

PollVote votes in a poll.

func (*RequestBuilder) Report added in v0.26.0

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 added in v0.26.0

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) Scheduled added in v0.26.0

func (b *RequestBuilder) Scheduled() *ScheduledManager

Scheduled creates new ScheduledManager using resolved peer.

func (*RequestBuilder) ScreenshotNotify added in v0.26.0

func (b *RequestBuilder) ScreenshotNotify(ctx context.Context, msgID int) (tg.UpdatesClass, error)

ScreenshotNotify sends notification about screenshot. Parameter msgID is a ID of message that was screenshotted, can be 0.

func (*RequestBuilder) StartBot added in v0.26.0

func (b *RequestBuilder) StartBot(ctx context.Context, opts ...StartBotOption) (tg.UpdatesClass, error)

StartBot starts a conversation with a bot using a deep linking parameter.

func (*RequestBuilder) TypingAction added in v0.26.0

func (b *RequestBuilder) TypingAction() *TypingActionBuilder

TypingAction creates TypingActionBuilder.

type ScheduledManager added in v0.26.0

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

ScheduledManager is a scheduled messages manager.

func (*ScheduledManager) Delete added in v0.26.0

func (m *ScheduledManager) Delete(ctx context.Context, id int, ids ...int) (tg.UpdatesClass, error)

Delete deletes scheduled messages.

func (*ScheduledManager) Get added in v0.26.0

Get gets scheduled messages.

func (*ScheduledManager) History added in v0.26.0

History gets scheduled messages history.

func (*ScheduledManager) HistoryWithHash added in v0.26.0

func (m *ScheduledManager) HistoryWithHash(ctx context.Context, hash int) (tg.ModifiedMessagesMessages, error)

HistoryWithHash gets scheduled messages history.

func (*ScheduledManager) Send added in v0.26.0

func (m *ScheduledManager) Send(ctx context.Context, id int, ids ...int) (tg.UpdatesClass, error)

Send sends scheduled messages.

type SearchDocumentBuilder added in v0.26.0

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 added in v0.26.0

func DocumentByHash(
	hash []byte, size int, 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 added in v0.26.0

Query sets query field of InputMediaDocument.

func (*SearchDocumentBuilder) TTL added in v0.26.0

TTL sets time to live of self-destructing document.

func (*SearchDocumentBuilder) TTLSeconds added in v0.26.0

func (u *SearchDocumentBuilder) TTLSeconds(ttl int) *SearchDocumentBuilder

TTLSeconds sets time to live in seconds of self-destructing document.

type Sender added in v0.26.0

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

Sender is a message sending helper.

func NewSender added in v0.26.0

func NewSender(raw *tg.Client) *Sender

NewSender creates a new Sender.

func (*Sender) Answer added in v0.26.0

Answer uses given message update to create message for same chat.

func (*Sender) ClearAllDrafts added in v0.26.0

func (s *Sender) ClearAllDrafts(ctx context.Context) error

ClearAllDrafts clears all drafts in all peers.

func (*Sender) Peer added in v0.26.0

func (s *Sender) Peer(p tg.InputPeerClass) *RequestBuilder

Peer uses given peer to create new message builder.

func (*Sender) PeerPromise added in v0.27.0

func (s *Sender) PeerPromise(p peer.Promise) *RequestBuilder

PeerPromise uses given peer promise to create new message builder.

func (*Sender) Reply added in v0.26.0

func (s *Sender) Reply(uctx tg.UpdateContext, upd AnswerableMessageUpdate) *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 added in v0.26.0

func (s *Sender) Resolve(from string) *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
func (s *Sender) ResolveDeeplink(deeplink string) *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 added in v0.26.0

func (s *Sender) ResolveDomain(domain string) *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) Self added in v0.26.0

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) WithRand added in v0.26.0

func (s *Sender) WithRand(r io.Reader) *Sender

WithRand sets random ID source.

func (*Sender) WithResolver added in v0.26.0

func (s *Sender) WithResolver(resolver peer.Resolver) *Sender

WithResolver sets peer resolver to use.

func (*Sender) WithUploader added in v0.26.0

func (s *Sender) WithUploader(u Uploader) *Sender

WithUploader sets file uploader to use.

type StartBotOption added in v0.26.0

type StartBotOption func(s *startBotBuilder)

StartBotOption is a option for StartBot method.

type StyledTextOption added in v0.26.0

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

StyledTextOption is functional option for styling text.

func BankCard added in v0.26.0

func BankCard(s string) StyledTextOption

BankCard formats text as BankCard entity. See https://core.telegram.org/constructor/messageEntityBankCard.

func Blockquote added in v0.26.0

func Blockquote(s string) StyledTextOption

Blockquote formats text as Blockquote entity. See https://core.telegram.org/constructor/messageEntityBlockquote.

func Bold added in v0.26.0

func Bold(s string) StyledTextOption

Bold formats text as Bold entity. See https://core.telegram.org/constructor/messageEntityBold.

func BotCommand added in v0.26.0

func BotCommand(s string) StyledTextOption

BotCommand formats text as BotCommand entity. See https://core.telegram.org/constructor/messageEntityBotCommand.

func Cashtag added in v0.26.0

func Cashtag(s string) StyledTextOption

Cashtag formats text as Cashtag entity. See https://core.telegram.org/constructor/messageEntityCashtag.

func Code added in v0.26.0

func Code(s string) StyledTextOption

Code formats text as Code entity. See https://core.telegram.org/constructor/messageEntityCode.

func Email added in v0.26.0

func Email(s string) StyledTextOption

Email formats text as Email entity. See https://core.telegram.org/constructor/messageEntityEmail.

func Hashtag added in v0.26.0

func Hashtag(s string) StyledTextOption

Hashtag formats text as Hashtag entity. See https://core.telegram.org/constructor/messageEntityHashtag.

func Italic added in v0.26.0

func Italic(s string) StyledTextOption

Italic formats text as Italic entity. See https://core.telegram.org/constructor/messageEntityItalic.

func Mention added in v0.26.0

func Mention(s string) StyledTextOption

Mention formats text as Mention entity. See https://core.telegram.org/constructor/messageEntityMention.

func MentionName added in v0.26.0

func MentionName(s string, userID int) StyledTextOption

MentionName formats text as MentionName entity. See https://core.telegram.org/constructor/messageEntityMentionName.

func Phone added in v0.26.0

func Phone(s string) StyledTextOption

Phone formats text as Phone entity. See https://core.telegram.org/constructor/messageEntityPhone.

func Plain added in v0.26.0

func Plain(s string) StyledTextOption

Plain formats text without any entities.

func Pre added in v0.26.0

func Pre(s, lang string) StyledTextOption

Pre formats text as Pre entity. See https://core.telegram.org/constructor/messageEntityPre.

func Strike added in v0.26.0

func Strike(s string) StyledTextOption

Strike formats text as Strike entity. See https://core.telegram.org/constructor/messageEntityStrike.

func TextURL added in v0.26.0

func TextURL(s, url string) StyledTextOption

TextURL formats text as TextURL entity. See https://core.telegram.org/constructor/messageEntityUrl.

func URL added in v0.26.0

func URL(s string) StyledTextOption

URL formats text as URL entity. See https://core.telegram.org/constructor/messageEntityUrl.

func Underline added in v0.26.0

func Underline(s string) StyledTextOption

Underline formats text as Underline entity. See https://core.telegram.org/constructor/messageEntityUnderline.

type TypingActionBuilder added in v0.26.0

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 added in v0.26.0

func (b *TypingActionBuilder) Cancel(ctx context.Context) error

Cancel sends SendMessageCancelAction.

func (*TypingActionBuilder) ChooseContact added in v0.26.0

func (b *TypingActionBuilder) ChooseContact(ctx context.Context) error

ChooseContact sends SendMessageChooseContactAction.

func (*TypingActionBuilder) GamePlay added in v0.26.0

func (b *TypingActionBuilder) GamePlay(ctx context.Context) error

GamePlay sends SendMessageGamePlayAction.

func (*TypingActionBuilder) GeoLocation added in v0.26.0

func (b *TypingActionBuilder) GeoLocation(ctx context.Context) error

GeoLocation sends SendMessageGeoLocationAction.

func (*TypingActionBuilder) HistoryImport added in v0.26.0

func (b *TypingActionBuilder) HistoryImport(ctx context.Context, progress int) error

HistoryImport sends SendMessageHistoryImportAction.

func (*TypingActionBuilder) RecordAudio added in v0.26.0

func (b *TypingActionBuilder) RecordAudio(ctx context.Context) error

RecordAudio sends SendMessageRecordAudioAction.

func (*TypingActionBuilder) RecordRound added in v0.26.0

func (b *TypingActionBuilder) RecordRound(ctx context.Context) error

RecordRound sends SendMessageRecordRoundAction.

func (*TypingActionBuilder) RecordVideo added in v0.26.0

func (b *TypingActionBuilder) RecordVideo(ctx context.Context) error

RecordVideo sends SendMessageRecordVideoAction.

func (*TypingActionBuilder) SpeakingInGroupCall added in v0.26.0

func (b *TypingActionBuilder) SpeakingInGroupCall(ctx context.Context) error

SpeakingInGroupCall sends SpeakingInGroupCallAction.

func (*TypingActionBuilder) ThreadID added in v0.26.0

func (b *TypingActionBuilder) ThreadID(id int) *TypingActionBuilder

ThreadID sets thread ID to send.

func (*TypingActionBuilder) ThreadMsg added in v0.26.0

ThreadMsg sets message's ID as thread ID to send.

func (*TypingActionBuilder) Typing added in v0.26.0

func (b *TypingActionBuilder) Typing(ctx context.Context) error

Typing sends SendMessageTypingAction.

func (*TypingActionBuilder) UploadAudio added in v0.26.0

func (b *TypingActionBuilder) UploadAudio(ctx context.Context, progress int) error

UploadAudio sends SendMessageUploadAudioAction.

func (*TypingActionBuilder) UploadDocument added in v0.26.0

func (b *TypingActionBuilder) UploadDocument(ctx context.Context, progress int) error

UploadDocument sends SendMessageUploadDocumentAction.

func (*TypingActionBuilder) UploadPhoto added in v0.26.0

func (b *TypingActionBuilder) UploadPhoto(ctx context.Context, progress int) error

UploadPhoto sends SendMessageUploadPhotoAction.

func (*TypingActionBuilder) UploadRound added in v0.26.0

func (b *TypingActionBuilder) UploadRound(ctx context.Context, progress int) error

UploadRound sends SendMessageUploadRoundAction.

func (*TypingActionBuilder) UploadVideo added in v0.26.0

func (b *TypingActionBuilder) UploadVideo(ctx context.Context, progress int) error

UploadVideo sends SendMessageUploadVideoAction.

type UploadBuilder added in v0.26.0

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

UploadBuilder is a attachment uploading helper.

func (*UploadBuilder) AsInputFile added in v0.26.0

func (u *UploadBuilder) AsInputFile(ctx context.Context) (tg.InputFileClass, error)

AsInputFile uploads and returns uploaded file entity.

func (*UploadBuilder) Audio added in v0.26.0

func (u *UploadBuilder) Audio(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)

Audio uploads and sends audio file.

func (*UploadBuilder) File added in v0.26.0

func (u *UploadBuilder) File(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)

File uploads and sends plain file.

func (*UploadBuilder) GIF added in v0.26.0

func (u *UploadBuilder) GIF(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)

GIF uploads and sends gif file.

func (*UploadBuilder) Photo added in v0.26.0

func (u *UploadBuilder) Photo(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)

Photo uploads and sends photo.

func (*UploadBuilder) RoundVideo added in v0.26.0

func (u *UploadBuilder) RoundVideo(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)

RoundVideo uploads and sends round video.

func (*UploadBuilder) Sticker added in v0.26.0

func (u *UploadBuilder) Sticker(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)

Sticker uploads and sends sticker.

func (*UploadBuilder) Video added in v0.26.0

func (u *UploadBuilder) Video(ctx context.Context, caption ...StyledTextOption) (tg.UpdatesClass, error)

Video uploads and sends video.

func (*UploadBuilder) Voice added in v0.26.0

func (u *UploadBuilder) Voice(ctx context.Context) (tg.UpdatesClass, error)

Voice uploads and sends voice message.

type UploadOption added in v0.26.0

type UploadOption interface {
	// contains filtered or unexported methods
}

UploadOption is a UploadBuilder creation option.

func FromBytes added in v0.26.0

func FromBytes(name string, data []byte) UploadOption

FromBytes uploads file from given byte slice.

func FromFS added in v0.26.0

func FromFS(filesystem fs.FS, path string) UploadOption

FromFS uploads file from given path using given fs.FS.

func FromFile added in v0.26.0

func FromFile(f uploader.File) UploadOption

FromFile uploads given File. NB: FromFile does not close given file.

func FromPath added in v0.26.0

func FromPath(path string) UploadOption

FromPath uploads file from given path.

func FromReader added in v0.26.0

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).

type UploadedDocumentBuilder added in v0.26.0

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

UploadedDocumentBuilder is a UploadedDocument media option.

func File added in v0.26.0

File adds document attachment and forces it to be used as plain file, not media.

func GIF added in v0.26.0

GIF adds gif attachment.

Example
package main

import (
	"context"
	"fmt"
	"os"
	"os/signal"

	"github.com/gotd/td/telegram"
	"github.com/gotd/td/telegram/message"
	"github.com/gotd/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 added in v0.26.0

func UploadedDocument(file tg.InputFileClass, caption ...StyledTextOption) *UploadedDocumentBuilder

UploadedDocument adds document attachment.

func (*UploadedDocumentBuilder) Attributes added in v0.26.0

Attributes adds given attributes to the document. Attribute specify the type of the document (video, audio, voice, sticker, etc.).

func (*UploadedDocumentBuilder) Audio added in v0.26.0

Audio creates new AudioDocumentBuilder to create audio attachment.

func (*UploadedDocumentBuilder) Filename added in v0.26.0

Filename sets name of uploaded file.

func (*UploadedDocumentBuilder) ForceFile added in v0.26.0

ForceFile sets flag to force the media file to be uploaded as document.

func (*UploadedDocumentBuilder) HasStickers added in v0.26.0

HasStickers sets flag that document attachment has stickers.

func (*UploadedDocumentBuilder) MIME added in v0.26.0

MIME sets MIME type of document.

func (*UploadedDocumentBuilder) NosoundVideo added in v0.26.0

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 added in v0.26.0

RoundVideo creates new VideoDocumentBuilder to create round video attachment.

func (*UploadedDocumentBuilder) Stickers added in v0.26.0

Stickers adds attached mask stickers.

func (*UploadedDocumentBuilder) TTL added in v0.26.0

TTL sets time to live of self-destructing document.

func (*UploadedDocumentBuilder) TTLSeconds added in v0.26.0

TTLSeconds sets time to live in seconds of self-destructing document.

func (*UploadedDocumentBuilder) Thumb added in v0.26.0

Thumb sets thumbnail of the document, uploaded as for the file.

func (*UploadedDocumentBuilder) UploadedSticker added in v0.26.0

func (u *UploadedDocumentBuilder) UploadedSticker() *UploadedStickerBuilder

UploadedSticker creates new UploadedStickerBuilder to create sticker attachment.

func (*UploadedDocumentBuilder) Video added in v0.26.0

Video creates new VideoDocumentBuilder to create video attachment.

func (*UploadedDocumentBuilder) Voice added in v0.26.0

Voice creates new AudioDocumentBuilder to create voice attachment.

type UploadedPhotoBuilder added in v0.26.0

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

UploadedPhotoBuilder is a UploadedPhoto media option.

func UploadedPhoto added in v0.26.0

func UploadedPhoto(file tg.InputFileClass, caption ...StyledTextOption) *UploadedPhotoBuilder

UploadedPhoto adds photo attachment.

func (*UploadedPhotoBuilder) Stickers added in v0.26.0

func (u *UploadedPhotoBuilder) Stickers(stickers ...FileLocation) *UploadedPhotoBuilder

Stickers adds attached mask stickers.

func (*UploadedPhotoBuilder) TTL added in v0.26.0

TTL sets time to live of self-destructing photo.

func (*UploadedPhotoBuilder) TTLSeconds added in v0.26.0

func (u *UploadedPhotoBuilder) TTLSeconds(ttl int) *UploadedPhotoBuilder

TTLSeconds sets time to live in seconds of self-destructing photo.

type UploadedStickerBuilder added in v0.26.0

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

UploadedStickerBuilder is a uploaded sticker media option.

func UploadedSticker added in v0.26.0

func UploadedSticker(file tg.InputFileClass, caption ...StyledTextOption) *UploadedStickerBuilder

UploadedSticker adds uploaded sticker attachment.

func (*UploadedStickerBuilder) Alt added in v0.26.0

Alt sets alternative emoji representation of sticker.

func (*UploadedStickerBuilder) Mask added in v0.26.0

Mask sets flag that is a mask sticker.

func (*UploadedStickerBuilder) MaskCoords added in v0.26.0

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 added in v0.26.0

StickerSet sets associated sticker set.

type Uploader added in v0.26.0

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)
}

Uploader is a abstraction for Telegram file uploader.

type VideoDocumentBuilder added in v0.26.0

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

VideoDocumentBuilder is a Video media option.

func RoundVideo added in v0.26.0

func RoundVideo(file tg.InputFileClass, caption ...StyledTextOption) *VideoDocumentBuilder

RoundVideo adds round video attachment.

func Video added in v0.26.0

func Video(file tg.InputFileClass, caption ...StyledTextOption) *VideoDocumentBuilder

Video adds video attachment.

func (*VideoDocumentBuilder) Duration added in v0.26.0

func (u *VideoDocumentBuilder) Duration(duration time.Duration) *VideoDocumentBuilder

Duration sets duration of video file.

func (*VideoDocumentBuilder) DurationSeconds added in v0.26.0

func (u *VideoDocumentBuilder) DurationSeconds(duration int) *VideoDocumentBuilder

DurationSeconds sets duration in seconds.

func (*VideoDocumentBuilder) Resolution added in v0.26.0

func (u *VideoDocumentBuilder) Resolution(w, h int) *VideoDocumentBuilder

Resolution sets resolution of this video.

func (*VideoDocumentBuilder) Round added in v0.26.0

Round sets flag to mark this video as round.

func (*VideoDocumentBuilder) SupportsStreaming added in v0.26.0

func (u *VideoDocumentBuilder) SupportsStreaming() *VideoDocumentBuilder

SupportsStreaming sets flag to mark this video as which supports streaming.

Directories

Path Synopsis
Package entity contains message formatting and styling helpers.
Package entity contains message formatting and styling helpers.
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.

Jump to

Keyboard shortcuts

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