Documentation ¶
Index ¶
- Constants
- type Anecdote
- type BroadcastParams
- type BroadcastStatus
- type Duck
- type Entity
- type Excerpt
- type HTTPClient
- type Image
- type Interface
- type Message
- type MockHTTPClient
- type MockInterface
- type MockSuperUser
- type MultiBot
- type News
- type Podcasts
- type PrepPost
- type Response
- type StackOverflow
- type SuperUser
- type Sys
- type User
- type WTF
Constants ¶
const ( // MsgBroadcastStarted defines text to be sent by the bot when the broadcast started MsgBroadcastStarted = "Вещание началось. Приобщиться можно тут: https://stream.radio-t.com/" // MsgBroadcastFinished defines text to be sent by the bot when the broadcast finished MsgBroadcastFinished = "Вещание завершилось" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Anecdote ¶
type Anecdote struct {
// contains filtered or unexported fields
}
Anecdote bot, returns from http://rzhunemogu.ru/RandJSON.aspx?CType=1
func NewAnecdote ¶
func NewAnecdote(client HTTPClient) *Anecdote
NewAnecdote makes a bot for http://rzhunemogu.ru
type BroadcastParams ¶
type BroadcastParams struct { URL string // URL for "ping" PingInterval time.Duration // Ping interval DelayToOff time.Duration // State will be switched to off in no ok replies from URL in this intrval Client http.Client // http client }
BroadcastParams defines parameters for broadcast detection
type BroadcastStatus ¶
type BroadcastStatus struct {
// contains filtered or unexported fields
}
BroadcastStatus bot replies with current broadcast status
func NewBroadcastStatus ¶
func NewBroadcastStatus(ctx context.Context, params BroadcastParams) *BroadcastStatus
NewBroadcastStatus starts status checking goroutine and returns bot instance
func (*BroadcastStatus) OnMessage ¶
func (b *BroadcastStatus) OnMessage(_ Message) (response Response)
OnMessage returns current broadcast status if it was changed
type Duck ¶
type Duck struct {
// contains filtered or unexported fields
}
Duck bot, returns from duckduckgo via mashape
type Entity ¶
type Entity struct { Type string Offset int Length int URL string `json:",omitempty"` // For “text_link” only, url that will be opened after user taps on the text User *User `json:",omitempty"` // For “text_mention” only, the mentioned user }
Entity represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
type Excerpt ¶
type Excerpt struct {
// contains filtered or unexported fields
}
Excerpt bot, returns link excerpt
func NewExcerpt ¶
NewExcerpt makes a bot extracting articles excerpt
type HTTPClient ¶
HTTPClient wrap http.Client to allow mocking
type Image ¶
type Image struct { // FileID corresponds to Telegram file_id FileID string Width int Height int Caption string `json:",omitempty"` Entities *[]Entity `json:",omitempty"` }
Image represents image
type Interface ¶
type Interface interface { OnMessage(msg Message) (response Response) ReactOn() []string Help() string }
Interface is a bot reactive spec. response will be sent if "send" result is true
type Message ¶
type Message struct { ID int From User Sent time.Time HTML string `json:",omitempty"` Text string `json:",omitempty"` Entities *[]Entity `json:",omitempty"` Image *Image `json:",omitempty"` }
Message is primary record to pass data from/to bots
type MockHTTPClient ¶
MockHTTPClient is an autogenerated mock type for the HTTPClient type
type MockInterface ¶
MockInterface is an autogenerated mock type for the Interface type
func (*MockInterface) Help ¶
func (_m *MockInterface) Help() string
Help provides a mock function with given fields:
func (*MockInterface) OnMessage ¶
func (_m *MockInterface) OnMessage(msg Message) Response
OnMessage provides a mock function with given fields: msg
func (*MockInterface) ReactOn ¶
func (_m *MockInterface) ReactOn() []string
ReactOn provides a mock function with given fields:
type MockSuperUser ¶
MockSuperUser is an autogenerated mock type for the SuperUser type
func (*MockSuperUser) IsSuper ¶
func (_m *MockSuperUser) IsSuper(userName string) bool
IsSuper provides a mock function with given fields: userName
type MultiBot ¶
type MultiBot []Interface
MultiBot combines many bots to one virtual
type News ¶
type News struct {
// contains filtered or unexported fields
}
News bot, returns numArticles last articles in MD format from https://news.radio-t.com/api/v1/news/lastmd/5
func NewNews ¶
func NewNews(client HTTPClient, api string, max int) *News
NewNews makes new News bot
type Podcasts ¶
type Podcasts struct {
// contains filtered or unexported fields
}
Podcasts search bot, returns search result via site-api see https://radio-t.com/api-docs/ GET /search?q=text-to-search&skip=10&limit=5, example: : https://radio-t.com/site-api/search?q=mongo&limit=10
func NewPodcasts ¶
func NewPodcasts(client HTTPClient, api string, maxResults int) *Podcasts
NewPodcasts makes new Podcasts bot
func (*Podcasts) OnMessage ¶
OnMessage returns result of search via https://radio-t.com/site-api/search?
type PrepPost ¶
type PrepPost struct {
// contains filtered or unexported fields
}
PrepPost bot notifies on new prep topic on the site
func NewPrepPost ¶
func NewPrepPost(client HTTPClient, api string, d time.Duration) *PrepPost
NewPrepPost makes new PrepPost bot sending and pinning message "Начался сбор тем"
type Response ¶
type Response struct { Text string Send bool // status Pin bool // enable pin Unpin bool // enable unpin Preview bool // enable web preview BanInterval time.Duration // bots banning user set the interval }
Response describes bot's answer on particular message
type StackOverflow ¶
type StackOverflow struct{}
StackOverflow bot, returns from "https://api.stackexchange.com/2.2/questions?order=desc&sort=activity&site=stackoverflow" reacts on "so!" prefix, i.e. "so! golang"
func (StackOverflow) OnMessage ¶
func (s StackOverflow) OnMessage(msg Message) (response Response)
OnMessage returns one entry
type Sys ¶
type Sys struct {
// contains filtered or unexported fields
}
Sys implements basic bot function to responds on ping and others from basic.data file. also reacts and say! with keys/values from say.data file