7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
53 lines
1.0 KiB
Go
53 lines
1.0 KiB
Go
package inline
|
|
|
|
import (
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tg"
|
|
)
|
|
|
|
// PhotoResultBuilder is photo result option builder.
|
|
type PhotoResultBuilder struct {
|
|
result *tg.InputBotInlineResultPhoto
|
|
msg MessageOption
|
|
}
|
|
|
|
func (b *PhotoResultBuilder) apply(r *resultPageBuilder) error {
|
|
m, err := b.msg.apply()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
t := tg.InputBotInlineResultPhoto{
|
|
ID: b.result.ID,
|
|
Type: b.result.Type,
|
|
Photo: b.result.Photo,
|
|
}
|
|
if t.ID == "" {
|
|
t.ID, err = r.generateID()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
t.SendMessage = m
|
|
r.results = append(r.results, &t)
|
|
return nil
|
|
}
|
|
|
|
// ID sets ID of result.
|
|
// Should not be empty, so if id is not provided, random will be used.
|
|
func (b *PhotoResultBuilder) ID(id string) *PhotoResultBuilder {
|
|
b.result.ID = id
|
|
return b
|
|
}
|
|
|
|
// Photo creates game result option builder.
|
|
func Photo(photo tg.InputPhotoClass, msg MessageOption) *PhotoResultBuilder {
|
|
return &PhotoResultBuilder{
|
|
result: &tg.InputBotInlineResultPhoto{
|
|
Type: PhotoType,
|
|
Photo: photo,
|
|
},
|
|
msg: msg,
|
|
}
|
|
}
|