Skip to content

Commit

Permalink
Merge pull request #330 from gotd/fix/inline-some-minor-fixes
Browse files Browse the repository at this point in the history
fix(inline): passing fields
  • Loading branch information
ernado committed May 9, 2021
2 parents 2583050 + e178f01 commit e206540
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion session/storage_js.go
Expand Up @@ -35,7 +35,7 @@ func getStorage() (js.Value, bool) {
// ErrLocalStorageIsNotAvailable is returned if localStorage is not available and Storage can't use it.
var ErrLocalStorageIsNotAvailable = xerrors.New("localStorage is not available")

func catch(err *error) { // nolint:gocritic
func catch(err *error) { // nolint:gocritic
if r := recover(); r != nil {
rErr, ok := r.(error)
if !ok {
Expand Down
11 changes: 9 additions & 2 deletions telegram/message/inline/article.go
Expand Up @@ -16,8 +16,15 @@ func (b *ArticleResultBuilder) apply(r *resultPageBuilder) error {
return err
}

var t tg.InputBotInlineResult
t.FillFrom(b.result)
t := tg.InputBotInlineResult{
ID: b.result.ID,
Type: b.result.Type,
Title: b.result.Title,
Description: b.result.Description,
URL: b.result.URL,
Thumb: b.result.Thumb,
Content: b.result.Content,
}
if t.ID == "" {
t.ID, err = r.generateID()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion telegram/message/inline/article_test.go
Expand Up @@ -27,7 +27,7 @@ func TestArticle(t *testing.T) {
}
}).ThenTrue()
_, err := builder.Set(ctx,
Article(ArticleType, MessageText("article")).Title(ArticleType).
Article(ArticleType, MessageText("article")).
Description(ArticleType).URL(ArticleType),
Article(ArticleType, MediaAuto("article")).ID("10").Title(ArticleType).
Description(ArticleType).URL(ArticleType),
Expand Down
9 changes: 7 additions & 2 deletions telegram/message/inline/document.go
Expand Up @@ -14,8 +14,13 @@ func (b *DocumentResultBuilder) apply(r *resultPageBuilder) error {
return err
}

var t tg.InputBotInlineResultDocument
t.FillFrom(b.result)
t := tg.InputBotInlineResultDocument{
ID: b.result.ID,
Type: b.result.Type,
Title: b.result.Title,
Description: b.result.Description,
Document: b.result.Document,
}
if t.ID == "" {
t.ID, err = r.generateID()
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions telegram/message/inline/game.go
Expand Up @@ -16,8 +16,10 @@ func (b *GameResultBuilder) apply(r *resultPageBuilder) error {
return err
}

var t tg.InputBotInlineResultGame
t.FillFrom(b.result)
t := tg.InputBotInlineResultGame{
ID: b.result.ID,
ShortName: b.result.ShortName,
}
if t.ID == "" {
t.ID, err = r.generateID()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions telegram/message/inline/inline.go
Expand Up @@ -107,6 +107,7 @@ func (r *ResultBuilder) Set(ctx context.Context, opt ResultOption, opts ...Resul
CacheTime: r.cacheTime,
NextOffset: r.nextOffset,
SwitchPm: r.switchPm,
Gallery: r.gallery,
})
if err != nil {
return false, xerrors.Errorf("set inline results: %w", err)
Expand Down
7 changes: 5 additions & 2 deletions telegram/message/inline/photo.go
Expand Up @@ -16,8 +16,11 @@ func (b *PhotoResultBuilder) apply(r *resultPageBuilder) error {
return err
}

var t tg.InputBotInlineResultPhoto
t.FillFrom(b.result)
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 {
Expand Down

0 comments on commit e206540

Please sign in to comment.