trends

package module
v0.0.0-...-38d82ff Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

README

Slack bot messages daily trends

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchAndPostTrends

func FetchAndPostTrends(e Event) error

func GoogleTrendsBot

func GoogleTrendsBot(w http.ResponseWriter, r *http.Request)

func PostMessage

func PostMessage(trends []Trend, channel string) error

Types

type Attachment

type Attachment struct {
	Fallback   string  `json:"fallback"`    //"Required plain-text summary of the attachment."
	Color      string  `json:"color"`       //"#2eb886"
	Pretext    string  `json:"pretext"`     //"Optional text that appears above the attachment block"
	AuthorName string  `json:"author_name"` //"Bobby Tables"
	AuthorLink string  `json:"author_link"` //"http://flickr.com/bobby/"
	AuthorIcon string  `json:"author_icon"` //"http://flickr.com/icons/bobby.jpg"
	Title      string  `json:"title"`       //"Slack API Documentation"
	TitleLink  string  `json:"title_link"`  //"https://api.slack.com/"
	Text       string  `json:"text"`        //"Optional text that appears within the attachment"
	Fields     []Field `json:"fields"`
	ImageURL   string  `json:"image_url"`   //"http://my-website.com/path/to/image.jpg"
	ThumbURL   string  `json:"thumb_url"`   //"http://example.com/path/to/thumb.png"
	Footer     string  `json:"footer"`      //"Slack API"
	FooterIcon string  `json:"footer_icon"` //"https://platform.slack-edge.com/img/default_application_icon.png"
	TS         string  `json:"ts"`          //12345678
}

type Body

type Body struct {
	Event Event `json:"event"`
}

type Challenge

type Challenge struct {
	Token     string `json:"token"`
	Challenge string `json:"challenge"`
	Type      string `json:"type"`
}

type Channel

type Channel struct {
	Title       string // Daily Search Trends
	Description string `xml:"description"` // Recent searches
	Link        string `xml:"link"`        // https://trends.google.co.jp/trends/trendingsearches/daily?geo=JP
	// AtomLink `xml:"atom:link,attr"` // https://trends.google.co.jp/trends/trendingsearches/daily/rss?geo=JP
	Items []Trend `xml:"item"`
}

type Event

type Event struct {
	ClientMsgID string `json:"client_msg_id"`
	Text        string `json:"text"`
	Channel     string `json:"channel"`
}

type Field

type Field struct {
	Title string `json:"title"` //"Priority"
	Value string `json:"value"` //"High"
	Short bool   `json:"short"` //fals
}

type Message

type Message struct {
	Channel     string       `json:"channel"`
	Text        string       `json:"text"`
	Markdown    bool         `json:"mrkdwn"`
	Attachments []Attachment `json:"attachments"`
}

type NewsItem

type NewsItem struct {
	Title   string `xml:"https://trends.google.co.jp/trends/trendingsearches/daily news_item_title"`   // <b>Copa America</b> quarter-finals - Argentina set up Brazil semi-final
	Snippet string `xml:"https://trends.google.co.jp/trends/trendingsearches/daily news_item_snippet"` // Lionel Messi was quiet for much of the game but he won&#39;t mind as Argentina made it through. Have a read of the report. We will return for more <b>Copa America</b> action during the semi-finals. Until then. Article Reactions. Like. 4 likes4. Dislike. 0 dislikes0.
	URL     string `xml:"https://trends.google.co.jp/trends/trendingsearches/daily news_item_url"`     // https://www.bbc.co.uk/sport/live/football/48766803
	Source  string `xml:"https://trends.google.co.jp/trends/trendingsearches/daily news_item_source"`  // BBC Sport
}

type RSS

type RSS struct {
	Channel Channel `xml:"channel"`
}

type Trend

type Trend struct {
	Title         string     `xml:"title"`                                                                    // Copa America
	ApproxTraffic string     `xml:"https://trends.google.co.jp/trends/trendingsearches/daily approx_traffic"` // 500,000+
	Description   string     `xml:"description"`                                                              // fox sports, Venezuela vs Argentina, argentina copa america, argentina vs venezuela 2019
	Link          string     `xml:"link"`                                                                     // https://trends.google.co.jp/trends/trendingsearches/daily?geo=US#Copa%20America
	PubDate       string     `xml:"pubDate"`                                                                  // Fri, 28 Jun 2019 13:00:00 -0700
	Picture       string     `xml:"https://trends.google.co.jp/trends/trendingsearches/daily picture"`        // https://t2.gstatic.com/images?q=tbn:ANd9GcQHkjNN41ODsg8kdwlXugG21c9CeDnfVu5YMbT8PgPxYPOvFynG8kNlLzCMDGQ53U1z6nljwIXG
	PictureSource string     `xml:"https://trends.google.co.jp/trends/trendingsearches/daily picture_source"` // BBC Sport
	NewsItems     []NewsItem `xml:"https://trends.google.co.jp/trends/trendingsearches/daily news_item"`
}

func Fetch

func Fetch(geo string) ([]Trend, error)

Jump to

Keyboard shortcuts

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