Documentation ¶
Overview ¶
Package unpack contains some updates result unpacking helpers.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Message ¶
Message tries to unpack sent message and returns it as 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/telegram/message/unpack" "github.com/gotd/td/tg" ) func unpackMessage(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)) msg, err := unpack.Message(sender.Resolve("@durovschat").Dice(ctx)) // Sends dice "🎲" to the @durovschat. if err != nil { return err } fmt.Println("Sent message ID:", msg.ID) return nil }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := unpackMessage(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
func MessageClass ¶
func MessageClass(u tg.UpdatesClass, err error) (tg.MessageClass, error)
MessageClass tries to unpack sent message and returns it as MessageClass.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.