Documentation ¶
Index ¶
- Constants
- Variables
- func HTTPGet(host string, path string, qp map[string]string, collection interface{}) error
- func HTTPGetByURL(url string, collection interface{}) error
- type BadgeCountsObj
- type Config
- type Database
- func (d *Database) Close() error
- func (d *Database) FindSlackQuestion(QID int) SlackQuestion
- func (d *Database) FindStackExchangeQuestion(QID int) StackExchangeQuestion
- func (d *Database) FindStackExchangeUser(UID int) StackExchangeUser
- func (d *Database) LatestStackExchangeQuestion() (StackExchangeQuestion, error)
- func (d *Database) SetPath(file path.Obj)
- func (d *Database) SlackQuestionCreate(slq SlackQuestion) (msg string, err error)
- func (d *Database) SlackQuestionDelete(slq SlackQuestion) error
- func (d *Database) SlackQuestionGetAll() (links []SlackQuestion, count int)
- func (d *Database) StackExchangeQuestionCreate(seq StackExchangeQuestion) (msg string, err error)
- func (d *Database) StackExchangeQuestionDelete(seq StackExchangeQuestion) error
- func (d *Database) StackExchangeQuestionTrackedIds(qToWatch int) (ids string, count int)
- func (d *Database) StackExchangeQuestionUpdate(seq StackExchangeQuestion) (msg string, err error)
- func (d *Database) StackExchangeQuestionsTracked(qToWatch int) (questions []StackExchangeQuestion, count int)
- func (d *Database) StackExchangeUserCreate(seu StackExchangeUser) (msg string, err error)
- func (d *Database) StackExchangeUserUpdate(seu StackExchangeUser) (msg string, err error)
- func (d *Database) SyncStackExchangeQuestion(q QuestionObj, site string) (msg string, err error)
- func (d *Database) SyncStackExchangeUserShallowUser(user ShallowUserObj) (msg string, err error)
- func (d *Database) VerifyTables(w *cli.Worker) (err error)
- type Paging
- type Parameter
- type Parameters
- func (p *Parameters) Allow(param string, value interface{}, desc string)
- func (p *Parameters) ApplyDefaults()
- func (p *Parameters) Delete(param string)
- func (p *Parameters) GetAllowed() map[string]Parameter
- func (p *Parameters) GetApplied() map[string]Parameter
- func (p *Parameters) IsAllowed(param string) bool
- func (p *Parameters) IsSet(param string) bool
- func (p *Parameters) Set(param string, value interface{})
- func (p *Parameters) ValueOf(param string) string
- type QuestionObj
- type Questions
- type QuestionsWrapperObj
- type SearchAdvanced
- type ShallowUserObj
- type SlackConfig
- type SlackOverflow
- type SlackQuestion
- type StackExchangeClient
- func (s *StackExchangeClient) GetEndpont(path string) (*url.URL, error)
- func (s *StackExchangeClient) GetQuotaMax() int
- func (s *StackExchangeClient) GetQuotaRemaining() int
- func (s *StackExchangeClient) Questions() *Questions
- func (s *StackExchangeClient) SearchAdvanced() *SearchAdvanced
- func (s *StackExchangeClient) SetAPIVersion(varsion string)
- func (s *StackExchangeClient) SetHost(host string)
- func (s *StackExchangeClient) SetKey(apiKey string)
- func (s *StackExchangeClient) SetQuotaMax(quotaMax int)
- func (s *StackExchangeClient) SetQuotaRemaining(quotaRemaining int)
- type StackExchangeConfig
- type StackExchangeQuestion
- type StackExchangeUser
- type Table
- type TableCol
Constants ¶
const (
// ErrNotConfigured is used when SlackOverflow is not configured
ErrNotConfigured = "You must execute 'slackoverflow reconfigure' or correct errors in ~/.slackoverflow/slackoverflow.yaml"
)
Variables ¶
var ( // Name of the application Name = "slackoverflow" // Version number Version = "17.11.10" // ShortDesc of the app ShortDesc = "Slackoverflow enables you to post tagged Stack Overflow questions to Slack, updated using reaction emojis." // BuildDate of the application BuildDate = "2017-11-10T01:18:26+02:00" // Contributors of the application Contributors = []string{ "Marko Kungla <marko.kungla@gmail.com>", } // CLIheader template CLIheader = `` /* 347-byte string literal not displayed */ CLIfooter = `` /* 191-byte string literal not displayed */ )
Functions ¶
func HTTPGetByURL ¶
HTTPGetByURL make Get request
Types ¶
type BadgeCountsObj ¶
type BadgeCountsObj struct { Bronze int `json:"bronze"` Silver int `json:"silver"` Gold int `json:"gold"` }
BadgeCountsObj of Stack Exchange User
type Config ¶
type Config struct { Slack SlackConfig `yaml:"slack"` StackExchange StackExchangeConfig `yaml:"stackexchange"` // contains filtered or unexported fields }
Config of SlackOverflow
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database for SlackOverflow
func (*Database) FindSlackQuestion ¶
func (d *Database) FindSlackQuestion(QID int) SlackQuestion
FindSlackQuestion link
func (*Database) FindStackExchangeQuestion ¶
func (d *Database) FindStackExchangeQuestion(QID int) StackExchangeQuestion
FindStackExchangeQuestion by ID
func (*Database) FindStackExchangeUser ¶
func (d *Database) FindStackExchangeUser(UID int) StackExchangeUser
FindStackExchangeUser by ID
func (*Database) LatestStackExchangeQuestion ¶
func (d *Database) LatestStackExchangeQuestion() (StackExchangeQuestion, error)
LatestStackExchangeQuestion return latest locl question if any
func (*Database) SlackQuestionCreate ¶
func (d *Database) SlackQuestionCreate(slq SlackQuestion) (msg string, err error)
SlackQuestionCreate new Question
func (*Database) SlackQuestionDelete ¶
func (d *Database) SlackQuestionDelete(slq SlackQuestion) error
SlackQuestionDelete by ID
func (*Database) SlackQuestionGetAll ¶
func (d *Database) SlackQuestionGetAll() (links []SlackQuestion, count int)
SlackQuestionGetAll linked questions
func (*Database) StackExchangeQuestionCreate ¶
func (d *Database) StackExchangeQuestionCreate(seq StackExchangeQuestion) (msg string, err error)
StackExchangeQuestionCreate stores new Question
func (*Database) StackExchangeQuestionDelete ¶
func (d *Database) StackExchangeQuestionDelete(seq StackExchangeQuestion) error
StackExchangeQuestionDelete by ID
func (*Database) StackExchangeQuestionTrackedIds ¶
StackExchangeQuestionTrackedIds return tracked question ids
func (*Database) StackExchangeQuestionUpdate ¶
func (d *Database) StackExchangeQuestionUpdate(seq StackExchangeQuestion) (msg string, err error)
StackExchangeQuestionUpdate updates existsing question
func (*Database) StackExchangeQuestionsTracked ¶
func (d *Database) StackExchangeQuestionsTracked(qToWatch int) (questions []StackExchangeQuestion, count int)
StackExchangeQuestionsTracked returns tracked questions
func (*Database) StackExchangeUserCreate ¶
func (d *Database) StackExchangeUserCreate(seu StackExchangeUser) (msg string, err error)
StackExchangeUserCreate creates new User
func (*Database) StackExchangeUserUpdate ¶
func (d *Database) StackExchangeUserUpdate(seu StackExchangeUser) (msg string, err error)
StackExchangeUserUpdate existsing User
func (*Database) SyncStackExchangeQuestion ¶
func (d *Database) SyncStackExchangeQuestion(q QuestionObj, site string) (msg string, err error)
SyncStackExchangeQuestion create or update question received from defined site
func (*Database) SyncStackExchangeUserShallowUser ¶
func (d *Database) SyncStackExchangeUserShallowUser(user ShallowUserObj) (msg string, err error)
SyncStackExchangeUserShallowUser Create or update Stack Exchange User
type Paging ¶
type Paging struct {
// contains filtered or unexported fields
}
Paging - https://api.stackexchange.com/docs/paging
func (*Paging) GetCurrentPageNr ¶
GetCurrentPageNr return current page number
func (*Paging) SetPageSize ¶
SetPageSize sets current page
type Parameter ¶
type Parameter struct {
// contains filtered or unexported fields
}
Parameter Stack Exchange parameter
type Parameters ¶
type Parameters struct {
// contains filtered or unexported fields
}
Parameters Stack Exchange query parameters
func (*Parameters) Allow ¶
func (p *Parameters) Allow(param string, value interface{}, desc string)
Allow parameter to be set
func (*Parameters) ApplyDefaults ¶
func (p *Parameters) ApplyDefaults()
ApplyDefaults apply default parameters
func (*Parameters) GetAllowed ¶
func (p *Parameters) GetAllowed() map[string]Parameter
GetAllowed returns parameters accepted by this endpoint
func (*Parameters) GetApplied ¶
func (p *Parameters) GetApplied() map[string]Parameter
GetApplied returns parameters which have been set
func (*Parameters) IsAllowed ¶
func (p *Parameters) IsAllowed(param string) bool
IsAllowed return true is parameter is allowed by this endpoint
func (*Parameters) IsSet ¶
func (p *Parameters) IsSet(param string) bool
IsSet return true is parameter is set
func (*Parameters) Set ¶
func (p *Parameters) Set(param string, value interface{})
Set adds or moifies a parameter given by the key and value
func (*Parameters) ValueOf ¶
func (p *Parameters) ValueOf(param string) string
ValueOf returns value of given parameter if it is set
type QuestionObj ¶
type QuestionObj struct { QID int `json:"question_id"` Title string `json:"title"` CreationDate int64 `json:"creation_date"` LastActivityDate int64 `json:"last_activity_date"` Owner ShallowUserObj `json:"owner"` IsAnswered bool `json:"is_answered"` ClosedReason string `json:"closed_reason"` Tags []string `json:"tags"` Score int `json:"score"` ViewCount int `json:"view_count"` AnswerCount int `json:"answer_count"` CommentCount int `json:"comment_count"` UpVoteCount int `json:"up_vote_count"` DownVoteCount int `json:"down_vote_count"` DeleteVoteCount int `json:"delete_vote_count"` FavoriteCount int `json:"favorite_count"` ReOpenVoteCount int `json:"reopen_vote_count"` }
QuestionObj is question item returned by StackExchange API
type Questions ¶
type Questions struct { Client *StackExchangeClient Parameters Parameters Paging Result *QuestionsWrapperObj }
Questions - https://api.stackexchange.com/docs/questions-by-ids
type QuestionsWrapperObj ¶
type QuestionsWrapperObj struct { Backoff int `json:"backoff"` ErrorID int `json:"error_id"` ErrorName string `json:"error_name"` ErrorMessage string `json:"error_message"` HasMore bool `json:"has_more"` Page int `json:"page"` QuotaMax int `json:"quota_max"` QuotaRemaining int `json:"quota_remaining"` Items []QuestionObj `json:"items"` }
QuestionsWrapperObj is a API response type
type SearchAdvanced ¶
type SearchAdvanced struct { Client *StackExchangeClient Parameters Parameters Paging Result *QuestionsWrapperObj }
SearchAdvanced - https://api.stackexchange.com/docs/advanced-search
func (*SearchAdvanced) DrawQuery ¶
func (sa *SearchAdvanced) DrawQuery(w *cli.Worker)
DrawQuery output table of search query
func (*SearchAdvanced) GetURL ¶
func (sa *SearchAdvanced) GetURL() (string, error)
GetURL composed from current parameters
func (*SearchAdvanced) Init ¶
func (sa *SearchAdvanced) Init()
Init initializes Search Advanced module
type ShallowUserObj ¶
type ShallowUserObj struct { UID int `json:"user_id"` Reputation int `json:"reputation"` ProfileImage string `json:"profile_image"` DisplayName string `json:"display_name"` Link string `json:"link"` AcceptRate int `json:"accept_rate"` BadgeCounts BadgeCountsObj `json:"badge_counts"` }
ShallowUserObj returned by Stack Exchange API
type SlackConfig ¶
type SlackConfig struct { Enabled bool `yaml:"enabled"` TeamURL bool `yaml:"team-url"` Channel string `yaml:"channel"` ChannelName string `yaml:"channel-name"` Token string `yaml:"token"` APIHost string `yaml:"api-host"` TeamInfo slack.TeamInfo `yaml:"team-info"` }
SlackConfig for Slack Overflow
func (*SlackConfig) SetAPIhost ¶
func (s *SlackConfig) SetAPIhost(h string)
SetAPIhost for Slack API
func (*SlackConfig) SetChannel ¶
func (s *SlackConfig) SetChannel(ch string)
SetChannel sets the slack channel where questions will be posted
func (*SlackConfig) SetChannelName ¶
func (s *SlackConfig) SetChannelName(n string)
SetChannelName sets the name of the slack channel where questions will be posted
func (*SlackConfig) SetTeamInfo ¶
func (s *SlackConfig) SetTeamInfo(t *slack.TeamInfo)
SetTeamInfo for current Slack configuration
func (*SlackConfig) SetToken ¶
func (s *SlackConfig) SetToken(t string)
SetToken sets Slack API token
type SlackOverflow ¶
type SlackOverflow struct { // Path retursn SlackOverflow config path Path path.Obj ConfigFilePath path.Obj DatabaseFilePath path.Obj Config Config DB Database StackExchange StackExchangeClient }
SlackOverflow application instance
func (*SlackOverflow) IsConfigured ¶
func (so *SlackOverflow) IsConfigured() (bool, error)
IsConfigured returns false with error if SlackOverflow is not configured
func (*SlackOverflow) Load ¶
func (so *SlackOverflow) Load(w *cli.Worker) (err error)
Load SlackOverflow and try to load configuration from given path
func (*SlackOverflow) Session ¶
func (so *SlackOverflow) Session(w *cli.Worker) error
Session loads everything for SlackOverfloe
func (*SlackOverflow) SyncQuestion ¶
func (so *SlackOverflow) SyncQuestion(w *cli.Worker, q QuestionObj)
SyncQuestion questions
type SlackQuestion ¶
type SlackQuestion struct { // Id of StackExchangeQuestion question QID int Channel string TS string }
SlackQuestion table Records in this table keep track of qustions between Stack Exchange and Slack
type StackExchangeClient ¶
type StackExchangeClient struct {
// contains filtered or unexported fields
}
StackExchangeClient to call Stack Exchange API
func (*StackExchangeClient) GetEndpont ¶
func (s *StackExchangeClient) GetEndpont(path string) (*url.URL, error)
GetEndpont returns base endpoint
func (*StackExchangeClient) GetQuotaMax ¶
func (s *StackExchangeClient) GetQuotaMax() int
GetQuotaMax return maximum allowed quota
func (*StackExchangeClient) GetQuotaRemaining ¶
func (s *StackExchangeClient) GetQuotaRemaining() int
GetQuotaRemaining return remaining quota for today
func (*StackExchangeClient) Questions ¶
func (s *StackExchangeClient) Questions() *Questions
Questions https://api.stackexchange.com/docs/questions-by-ids
func (*StackExchangeClient) SearchAdvanced ¶
func (s *StackExchangeClient) SearchAdvanced() *SearchAdvanced
SearchAdvanced https://api.stackexchange.com/docs/advanced-search
func (*StackExchangeClient) SetAPIVersion ¶
func (s *StackExchangeClient) SetAPIVersion(varsion string)
SetAPIVersion set Stack Exchange API version
func (*StackExchangeClient) SetHost ¶
func (s *StackExchangeClient) SetHost(host string)
SetHost set Stack Exchange API host
func (*StackExchangeClient) SetKey ¶
func (s *StackExchangeClient) SetKey(apiKey string)
SetKey Set Stack Exchange API to receive a higher request quota if exists
func (*StackExchangeClient) SetQuotaMax ¶
func (s *StackExchangeClient) SetQuotaMax(quotaMax int)
SetQuotaMax set maximum allowed quota
func (*StackExchangeClient) SetQuotaRemaining ¶
func (s *StackExchangeClient) SetQuotaRemaining(quotaRemaining int)
SetQuotaRemaining set remaining quota for today
type StackExchangeConfig ¶
type StackExchangeConfig struct { Enabled bool `yaml:"enabled"` Key string `yaml:"key"` APIVersion string `yaml:"api-version"` APIHost string `yaml:"api-host"` Site string `yaml:"site"` QuestionsToWatch int `yaml:"questions-to-watch"` SearchAdvanced map[string]string `yaml:"search-advanced"` Questions map[string]string `yaml:"questions"` }
StackExchangeConfig for Slack Overflow
func (*StackExchangeConfig) Disable ¶
func (s *StackExchangeConfig) Disable()
Disable Stack Exchange
func (*StackExchangeConfig) SetAPIVersion ¶
func (s *StackExchangeConfig) SetAPIVersion(v string)
SetAPIVersion for Stack Exchange API
func (*StackExchangeConfig) SetAPIhost ¶
func (s *StackExchangeConfig) SetAPIhost(h string)
SetAPIhost for Stack Exchange API
type StackExchangeQuestion ¶
type StackExchangeQuestion struct { QID int UID int Title string CreationDate time.Time LastActivityDate time.Time ClosedReason string Tags string Site string IsAnswered bool Score int ViewCount int AnswerCount int CommentCount int UpVoteCount int DownVoteCount int DeleteVoteCount int FavoriteCount int ReOpenVoteCount int }
StackExchangeQuestion table
type StackExchangeUser ¶
type StackExchangeUser struct { UID int DisplayName string ProfileImage string Link string Reputation int AcceptRate int BadgeBronze int BadgeSilver int BadgeGold int }
StackExchangeUser table