func (s *Story) ToDeleteMessageRequest() DeleteMessageRequest {
	return DeleteMessageRequest{
		ChatID:    DefaultChatID,
		MessageID: s.MessageID,
	}
}
ToDeleteMessageRequest returns a DeleteMessageRequest.
package bots
import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"time"
	"github.com/pkg/errors"
	"google.golang.org/appengine/datastore"
	"google.golang.org/appengine/log"
)
const Hot = "🔥"
type Story struct {
	ID                  int64     `json:"id"`
	URL                 string    `json:"url"`
	Title               string    `json:"title"`
	Descendants         int64     `json:"descendants"`
	Score               int64     `json:"score"`
	MessageID           int64     `json:"-"`
	LastSave            time.Time `json:"-"`
	Type                string    `json:"type"`
	missingFieldsLoaded bool
}
func NewFromDatastore(ctx context.Context, id int64) (Story, error) {
	var story Story
	if err := datastore.Get(ctx, GetKey(ctx, id), &story); err != nil {
		return story, errors.WithStack(err)
	}
	return story, nil
}
func (s *Story) Load(ps []datastore.Property) error {
	return datastore.LoadStruct(s, ps)
}
func (s *Story) Save() ([]datastore.Property, error) {
	return []datastore.Property{
		{
			Name:  "MessageID",
			Value: s.MessageID,
		},
		{
			Name:  "ID",
			Value: s.ID,
		},
		{
			Name:  "LastSave",
			Value: time.Now(),
		},
	}, nil
}
func (s *Story) FillMissingFields(ctx context.Context) error {
	resp, err := myHTTPClient(ctx).Get(ItemURL(s.ID))
	if err != nil {
		return errors.WithStack(err)
	}
	defer resp.Body.Close()
	err = json.NewDecoder(resp.Body).Decode(s)
	if err != nil {
		return errors.WithStack(err)
	}
	s.missingFieldsLoaded = true
	return nil
}
func (s *Story) ShouldIgnore() bool {
	return s.Type != "story" ||
		s.Score < ScoreThreshold ||
		s.Descendants < NumCommentsThreshold ||
		s.URL == ""
}
func (s *Story) ToSendMessageRequest() SendMessageRequest {
	return SendMessageRequest{
		ChatID:              DefaultChatID,
		Text:                fmt.Sprintf("<b>%s</b>  %s", s.Title, s.URL),
		ParseMode:           "HTML",
		ReplyMarkup:         s.GetReplyMarkup(),
		DisableNotification: true,
	}
}
func (s *Story) ToEditMessageTextRequest() EditMessageTextRequest {
	return EditMessageTextRequest{
		ChatID:      DefaultChatID,
		MessageID:   s.MessageID,
		Text:        fmt.Sprintf("<b>%s</b>  %s", s.Title, s.URL),
		ParseMode:   "HTML",
		ReplyMarkup: s.GetReplyMarkup(),
	}
}
func (s *Story) GetReplyMarkup() InlineKeyboardMarkup {
	var scoreSuffix, commentSuffix string
	if s.Score > 100 {
		scoreSuffix = " " + Hot
	}
	if s.Descendants > 100 {
		commentSuffix = " " + Hot
	}
	return InlineKeyboardMarkup{
		InlineKeyboard: [][]InlineKeyboardButton{
			{
				{
					Text: fmt.Sprintf("Score: %d+%s", s.Score, scoreSuffix),
					URL:  s.URL,
				},
				{
					Text: fmt.Sprintf("Comments: %d+%s", s.Descendants, commentSuffix),
					URL:  NewsURL(s.ID),
				},
			},
		},
	}
}