Documentation ¶
Overview ¶
Package data is a collection of data commonly used by mybot.
Index ¶
- type Action
- type Cache
- type CacheProperties
- func (c *CacheProperties) GetLatestDMID() int64
- func (c *CacheProperties) GetLatestFavoriteID(screenName string) int64
- func (c *CacheProperties) GetLatestImages(num int) []models.ImageCacheData
- func (c *CacheProperties) GetLatestTweetID(screenName string) int64
- func (c *CacheProperties) GetTweetAction(tweetID int64) Action
- func (c *CacheProperties) SetImage(data models.ImageCacheData)
- func (c *CacheProperties) SetLatestDMID(id int64)
- func (c *CacheProperties) SetLatestFavoriteID(screenName string, id int64)
- func (c *CacheProperties) SetLatestTweetID(screenName string, id int64)
- func (c *CacheProperties) SetTweetAction(tweetID int64, action Action)
- type DBCache
- type FileCache
- type SlackAction
- type TwitterAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { Twitter TwitterAction `json:"twitter" toml:"twitter" bson:"twitter" yaml:"twitter"` Slack SlackAction `json:"slack" toml:"slack" bson:"slack" yaml:"slack"` }
type Cache ¶
type Cache interface { utils.Savable utils.Deletable GetLatestTweetID(screenName string) int64 SetLatestTweetID(screenName string, id int64) GetLatestFavoriteID(screenName string) int64 SetLatestFavoriteID(screenName string, id int64) GetLatestDMID() int64 SetLatestDMID(id int64) GetTweetAction(tweetID int64) Action SetTweetAction(tweetID int64, action Action) GetLatestImages(num int) []models.ImageCacheData SetImage(data models.ImageCacheData) }
Cache provides a set of functions to access cache of this application.
type CacheProperties ¶
type CacheProperties struct { // LatestTweetID associates Twitter screen name with the latest tweet // ID in timeline. LatestTweetID map[string]int64 `json:"latest_tweet_id" toml:"latest_tweet_id" bson:"latest_tweet_id" yaml:"latest_tweet_id"` // LatestFavoriteID associates Twitter screen name with the latest // tweet ID in favorite list. LatestFavoriteID map[string]int64 `json:"latest_favorite_id" toml:"lates_favorite_id" bson:"latest_favorite_id" yaml:"latest_favorite_id"` // LatestDMID is latest direct message ID of the authenticated user // with the latest direct message ID. LatestDMID int64 `json:"latest_dm_id" toml:"latest_dm_id" bson:"latest_dm_id" yaml:"latest_dm_id"` // Tweet2Action associates tweet ID with Mybot action. // This is not an instance of map[int64]Action because it can't be // converted to json when Go Runtime is v1.6 or older Tweet2Action map[string]Action `json:"tweet_to_action" toml:"tweet_to_action" bson:"tweet_to_action" yaml:"tweet_to_action"` // Images is cache data of images analyzed by some API or method. Images []models.ImageCacheData `json:"images" toml:"images" bson:"images" yaml:"images"` // contains filtered or unexported fields }
CacheProperties contains common actual cache variables and is intended to be embedded into other structs. All functions of this struct are thread-safe.
func (*CacheProperties) GetLatestDMID ¶
func (c *CacheProperties) GetLatestDMID() int64
GetLatestDMID returns latest direct message ID of the authenticated user.
func (*CacheProperties) GetLatestFavoriteID ¶
func (c *CacheProperties) GetLatestFavoriteID(screenName string) int64
GetLatestFavoriteID returns the latest favorite tweet ID of screenName. If there is no ID of screenName in c, this returns 0 (tweet ID can't be 0, which is known by Twitter API specification).
func (*CacheProperties) GetLatestImages ¶
func (c *CacheProperties) GetLatestImages(num int) []models.ImageCacheData
GetLatestImages returns the num latest pieces of cache image data.
func (*CacheProperties) GetLatestTweetID ¶
func (c *CacheProperties) GetLatestTweetID(screenName string) int64
GetLatestTweetID returns the latest tweet ID associated with screenName in timeline. If there is no ID of screenName in c , this returns 0 (tweet ID can't be 0, which is known by Twitter API specification).
func (*CacheProperties) GetTweetAction ¶
func (c *CacheProperties) GetTweetAction(tweetID int64) Action
GetTweetAction returns Mybot action associated with tweetID.
func (*CacheProperties) SetImage ¶
func (c *CacheProperties) SetImage(data models.ImageCacheData)
SetImage sets data as the latest image cache data.
func (*CacheProperties) SetLatestDMID ¶
func (c *CacheProperties) SetLatestDMID(id int64)
SetLatestDMID sets id as the latest direct message ID of the authenticated user.
func (*CacheProperties) SetLatestFavoriteID ¶
func (c *CacheProperties) SetLatestFavoriteID(screenName string, id int64)
SetLatestFavoriteID stores id as the latest favorite tweet ID and associates it with screeName.
func (*CacheProperties) SetLatestTweetID ¶
func (c *CacheProperties) SetLatestTweetID(screenName string, id int64)
SetLatestTweetID stores id as the latest tweet ID and associates it with screenName.
func (*CacheProperties) SetTweetAction ¶
func (c *CacheProperties) SetTweetAction(tweetID int64, action Action)
SetTweetAction associates action with tweetID.
type DBCache ¶
type DBCache struct { CacheProperties `yaml:",inline"` ID string `json:"id" toml:"id" bson:"id" yaml:"id"` // contains filtered or unexported fields }
func NewDBCache ¶
func NewDBCache(col models.MgoCollection, id string) (*DBCache, error)
type FileCache ¶
type FileCache struct { CacheProperties `yaml:",inline"` File string `json:"-" toml:"-" bson:"-" yaml:"-"` }
FileCache is a cache data associated with a specified file.
func NewFileCache ¶
NewFileCache returns a new FileCache. If no file specified, this returns an empty Cache instance, which has no data and can't save the content to any file.
type SlackAction ¶
type SlackAction struct { models.SlackActionProperties `yaml:",inline"` Reactions []string `json:"reactions,omitempty" toml:"reactions,omitempty" bson:"reactions,omitempty" yaml:"reactions,omitempty"` Channels []string `json:"channels,omitempty" toml:"channels,omitempty" bson:"channels,omitempty" yaml:"channels,omitempty"` }
func NewSlackAction ¶
func NewSlackAction() SlackAction
func (SlackAction) Add ¶
func (a SlackAction) Add(action SlackAction) SlackAction
func (SlackAction) IsEmpty ¶
func (a SlackAction) IsEmpty() bool
func (SlackAction) Sub ¶
func (a SlackAction) Sub(action SlackAction) SlackAction
type TwitterAction ¶
type TwitterAction struct { models.TwitterActionProperties `yaml:",inline"` Collections []string `json:"collections" toml:"collections" bson:"collections" yaml:"collections"` }
TwitterAction can indicate for various actions for Twitter's tweets.
func NewTwitterAction ¶
func NewTwitterAction() TwitterAction
func (TwitterAction) Add ¶
func (a TwitterAction) Add(action TwitterAction) TwitterAction
func (TwitterAction) IsEmpty ¶
func (a TwitterAction) IsEmpty() bool
func (TwitterAction) Sub ¶
func (a TwitterAction) Sub(action TwitterAction) TwitterAction