repo
stringlengths
5
67
sha
stringlengths
40
40
path
stringlengths
4
234
url
stringlengths
85
339
language
stringclasses
6 values
split
stringclasses
3 values
doc
stringlengths
3
51.2k
sign
stringlengths
5
8.01k
problem
stringlengths
13
51.2k
output
stringlengths
0
3.87M
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/pastebinbee/pastebinbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/pastebinbee/pastebinbeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *PastebinBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *PastebinBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := PastebinBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/pastebinbee/pastebinbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/pastebinbee/pastebinbeefactory.go#L68-L77
go
train
// Options returns the options available to configure this Bee.
func (factory *PastebinBeeFactory) Options() []bees.BeeOptionDescriptor
// Options returns the options available to configure this Bee. func (factory *PastebinBeeFactory) Options() []bees.BeeOptionDescriptor
{ opts := []bees.BeeOptionDescriptor{ { Name: "api_dev_key", Description: "Developer key for Pastebin API", Type: "string", }, } return opts }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/htmlextractbee/htmlextractbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/htmlextractbee/htmlextractbee.go#L42-L107
go
train
// Action triggers the action passed to it.
func (mod *HTMLExtractBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *HTMLExtractBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "extract": var url string action.Options.Bind("url", &url) if start := strings.Index(url, "http"); start >= 0 { url = url[start:] if end := strings.Index(url, " "); end >= 0 { url = url[:end] } } g := goose.New() article, _ := g.Ext...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/execbee/execbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/execbee/execbeefactory.go#L36-L43
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *ExecBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *ExecBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := ExecBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/timebee/timebee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/timebee/timebee.go#L92-L105
go
train
// Run executes the Bee's event loop.
func (mod *TimeBee) Run(eventChan chan bees.Event)
// Run executes the Bee's event loop. func (mod *TimeBee) Run(eventChan chan bees.Event)
{ mod.eventChan = eventChan for { select { case <-mod.SigChan: return default: } mod.timer() time.Sleep(500 * time.Millisecond) } }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/timebee/timebee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/timebee/timebee.go#L108-L118
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *TimeBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *TimeBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("second", &mod.second) options.Bind("minute", &mod.minute) options.Bind("hour", &mod.hour) options.Bind("day_of_week", &mod.dayofweek) options.Bind("day_of_month", &mod.dayofmonth) options.Bind("month", &mod.month) options.Bind("year", &mod.year) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/anelpowerctrlbee/anelpowerctrlbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/anelpowerctrlbee/anelpowerctrlbeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *AnelPowerCtrlBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *AnelPowerCtrlBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := AnelPowerCtrlBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/filters.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/filters.go#L38-L49
go
train
// execFilter executes a filter. Returns whether the filter passed or not.
func execFilter(filter string, opts map[string]interface{}) bool
// execFilter executes a filter. Returns whether the filter passed or not. func execFilter(filter string, opts map[string]interface{}) bool
{ f := *filters.GetFilter("template") log.Println("\tExecuting filter:", filter) defer func() { if e := recover(); e != nil { log.Println("Fatal filter event:", e) } }() return f.Passes(opts, filter) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/ircbee/ircbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/ircbee/ircbee.go#L53-L116
go
train
// Action triggers the action passed to it.
func (mod *IrcBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *IrcBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} var sendFunc func(t, msg string) switch action.Name { case "notice": sendFunc = mod.client.Notice fallthrough case "send": if sendFunc == nil { sendFunc = mod.client.Privmsg } tos := []string{} text := "" action.Options.Bind("text", &text) for _, opt := range ac...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/ircbee/ircbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/ircbee/ircbee.go#L176-L303
go
train
// Run executes the Bee's event loop.
func (mod *IrcBee) Run(eventChan chan bees.Event)
// Run executes the Bee's event loop. func (mod *IrcBee) Run(eventChan chan bees.Event)
{ if len(mod.server) == 0 { return } // channel signaling IRC connection status mod.connectedState = make(chan bool) // setup IRC client: cfg := irc.NewConfig(mod.nick, "beehive", "beehive") cfg.SSL = mod.ssl if mod.ssl { h, _, _ := net.SplitHostPort(mod.server) if h == "" { h = mod.server } cfg...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/ircbee/ircbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/ircbee/ircbee.go#L306-L316
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *IrcBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *IrcBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("address", &mod.server) options.Bind("nick", &mod.nick) options.Bind("password", &mod.password) options.Bind("ssl", &mod.ssl) options.Bind("channels", &mod.channels) mod.ContextSet("channels", &mod.channels) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/rssbee/rssbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/rssbee/rssbeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *RSSBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *RSSBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := RSSBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/jabberbee/jabberbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/jabberbee/jabberbee.go#L45-L62
go
train
// Action triggers the action passed to it.
func (mod *JabberBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *JabberBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "send": chat := xmpp.Chat{Type: "chat"} action.Options.Bind("user", &chat.Remote) action.Options.Bind("text", &chat.Text) mod.client.Send(chat) default: panic("Unknown action triggered in " + mod.Name() + ": " + action.Name) } return outs }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/jabberbee/jabberbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/jabberbee/jabberbee.go#L101-L134
go
train
// Run executes the Bee's event loop.
func (mod *JabberBee) Run(eventChan chan bees.Event)
// Run executes the Bee's event loop. func (mod *JabberBee) Run(eventChan chan bees.Event)
{ if len(mod.server) == 0 { return } options := xmpp.Options{ Host: mod.server, User: mod.user, Password: mod.password, NoTLS: mod.notls, Debug: false, } var err error mod.client, err = options.NewClient() if err != nil { mod.LogErrorf("Connection error: %s", err) return } defe...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/jabberbee/jabberbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/jabberbee/jabberbee.go#L137-L144
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *JabberBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *JabberBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("address", &mod.server) options.Bind("user", &mod.user) options.Bind("password", &mod.password) options.Bind("notls", &mod.notls) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/facebookbee/facebookbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/facebookbee/facebookbeefactory.go#L43-L50
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *FacebookBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *FacebookBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := FacebookBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/facebookbee/facebookbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/facebookbee/facebookbeefactory.go#L78-L94
go
train
// OAuth2AccessToken returns the oauth2 access token.
func (factory *FacebookBeeFactory) OAuth2AccessToken(id, secret, code string) (*oauth2.Token, error)
// OAuth2AccessToken returns the oauth2 access token. func (factory *FacebookBeeFactory) OAuth2AccessToken(id, secret, code string) (*oauth2.Token, error)
{ // Get facebook access token. conf := &oauth2.Config{ ClientID: id, ClientSecret: secret, RedirectURL: api.CanonicalURL().String() + "/" + path.Join("oauth2", factory.ID(), id, secret), Scopes: []string{"public_profile", "publish_actions"}, Endpoint: oauth2fb.Endpoint, } token, err := co...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/facebookbee/facebookbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/facebookbee/facebookbeefactory.go#L97-L135
go
train
// Options returns the options available to configure this Bee.
func (factory *FacebookBeeFactory) Options() []bees.BeeOptionDescriptor
// Options returns the options available to configure this Bee. func (factory *FacebookBeeFactory) Options() []bees.BeeOptionDescriptor
{ conf := &oauth2.Config{ ClientID: "__client_id__", ClientSecret: "__client_secret__", RedirectURL: api.CanonicalURL().String() + "/" + path.Join("oauth2", factory.ID(), "__client_id__", "__client_secret__"), Scopes: []string{"public_profile", "publish_actions"}, Endpoint: oauth2fb.Endpoint,...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/openweathermapbee/event.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/openweathermapbee/event.go#L31-L183
go
train
// TriggerCurrentWeatherEvent triggers all current weather events
func (mod *OpenweathermapBee) TriggerCurrentWeatherEvent()
// TriggerCurrentWeatherEvent triggers all current weather events func (mod *OpenweathermapBee) TriggerCurrentWeatherEvent()
{ ev := bees.Event{ Bee: mod.Name(), Name: "current_weather", Options: []bees.Placeholder{ { Name: "geo_pos_longitude", Type: "float64", Value: mod.current.GeoPos.Longitude, }, { Name: "geo_pos_latitude", Type: "float64", Value: mod.current.GeoPos.Latitude, }, { N...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/openweathermapbee/event.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/openweathermapbee/event.go#L186-L214
go
train
// WeatherInformationEvent triggers a weather event
func (mod *OpenweathermapBee) TriggerWeatherInformationEvent(v *owm.Weather)
// WeatherInformationEvent triggers a weather event func (mod *OpenweathermapBee) TriggerWeatherInformationEvent(v *owm.Weather)
{ weather := bees.Event{ Bee: mod.Name(), Name: "main_weather", Options: []bees.Placeholder{ { Name: "id", Type: "int", Value: v.ID, }, { Name: "main", Type: "string", Value: v.Main, }, { Name: "description", Type: "string", Value: v.Description, }, ...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/spaceapibee/spaceapibeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/spaceapibee/spaceapibeefactory.go#L34-L41
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *SpaceAPIBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *SpaceAPIBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := SpaceAPIBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/spaceapibee/spaceapibeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/spaceapibee/spaceapibeefactory.go#L81-L91
go
train
// Actions describes the available actions provided by this Bee.
func (factory *SpaceAPIBeeFactory) Actions() []bees.ActionDescriptor
// Actions describes the available actions provided by this Bee. func (factory *SpaceAPIBeeFactory) Actions() []bees.ActionDescriptor
{ actions := []bees.ActionDescriptor{ { Namespace: factory.Name(), Name: "status", Description: "Gets the Status of a LabAPI instance", Options: []bees.PlaceholderDescriptor{}, }, } return actions }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/spaceapibee/spaceapibeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/spaceapibee/spaceapibeefactory.go#L94-L110
go
train
// Events describes the available events provided by this Bee.
func (factory *SpaceAPIBeeFactory) Events() []bees.EventDescriptor
// Events describes the available events provided by this Bee. func (factory *SpaceAPIBeeFactory) Events() []bees.EventDescriptor
{ events := []bees.EventDescriptor{ { Namespace: factory.Name(), Name: "result", Description: "is triggered as soon as the query has been executed", Options: []bees.PlaceholderDescriptor{ { Name: "open", Description: "open-state of the spaceapi instance that was queried", ...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cronbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cronbee.go#L41-L64
go
train
// Run executes the Bee's event loop.
func (mod *CronBee) Run(eventChan chan bees.Event)
// Run executes the Bee's event loop. func (mod *CronBee) Run(eventChan chan bees.Event)
{ mod.eventChan = eventChan timer := cron.ParseInput(mod.input) for { select { case <-mod.SigChan: return case <-time.After(timer.DurationUntilNextEvent()): event := bees.Event{ Bee: mod.Name(), Name: "time", Options: []bees.Placeholder{ { Name: "timestamp", Type: "strin...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cronbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cronbee.go#L67-L76
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *CronBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *CronBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("second", &mod.input[0]) options.Bind("minute", &mod.input[1]) options.Bind("hour", &mod.input[2]) options.Bind("day_of_week", &mod.input[3]) options.Bind("day_of_month", &mod.input[4]) options.Bind("month", &mod.input[5]) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/jabberbee/jabberbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/jabberbee/jabberbeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *JabberBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *JabberBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := JabberBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/tumblrbee/tumblrbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/tumblrbee/tumblrbee.go#L48-L116
go
train
// Action triggers the action passed to it.
func (mod *TumblrBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *TumblrBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "post_text": text := "" action.Options.Bind("text", &text) state := "published" err := mod.client.CreateText(mod.blogname, map[string]string{ "body": text, "state": state}) if err != nil { mod.LogErrorf("Failed to post text: %v", err) ...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/tumblrbee/tumblrbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/tumblrbee/tumblrbee.go#L119-L126
go
train
// Run executes the Bee's event loop.
func (mod *TumblrBee) Run(eventChan chan bees.Event)
// Run executes the Bee's event loop. func (mod *TumblrBee) Run(eventChan chan bees.Event)
{ mod.evchan = eventChan select { case <-mod.SigChan: return } }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/tumblrbee/tumblrbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/tumblrbee/tumblrbee.go#L129-L142
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *TumblrBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *TumblrBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("blogname", &mod.blogname) options.Bind("callback_url", &mod.callbackURL) options.Bind("consumer_key", &mod.consumerKey) options.Bind("consumer_secret", &mod.consumerSecret) options.Bind("token", &mod.token) options.Bind("token_secret", &mod.tokenSecret) mod.client = go...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
filters/template/templatefilter.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/filters/template/templatefilter.go#L48-L70
go
train
// Passes returns true when the Filter matched the data.
func (filter *TemplateFilter) Passes(data interface{}, value interface{}) bool
// Passes returns true when the Filter matched the data. func (filter *TemplateFilter) Passes(data interface{}, value interface{}) bool
{ switch v := value.(type) { case string: var res bytes.Buffer if strings.Index(v, "{{test") >= 0 { v = strings.Replace(v, "{{test", "{{if", -1) v += "true{{end}}" } tmpl, err := template.New("_" + v).Funcs(templatehelper.FuncMap).Parse(v) if err == nil { err = tmpl.Execute(&res, data) } if ...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/prometheusbee/prometheusbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/prometheusbee/prometheusbeefactory.go#L35-L42
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *PrometheusBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *PrometheusBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := PrometheusBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/prometheusbee/prometheusbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/prometheusbee/prometheusbeefactory.go#L111-L281
go
train
// Actions describes the available actions provided by this Bee.
func (factory *PrometheusBeeFactory) Actions() []bees.ActionDescriptor
// Actions describes the available actions provided by this Bee. func (factory *PrometheusBeeFactory) Actions() []bees.ActionDescriptor
{ actions := []bees.ActionDescriptor{ { Namespace: factory.Name(), Name: "counter_inc", Description: "Increments the value of a counter by 1", Options: []bees.PlaceholderDescriptor{ { Name: "label", Description: "Label of the counter to increment", Type: "string...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/hives/hives_response.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/hives/hives_response.go#L56-L61
go
train
// Init a new response
func (r *HiveResponse) Init(context smolder.APIContext)
// Init a new response func (r *HiveResponse) Init(context smolder.APIContext)
{ r.Parent = r r.Context = context r.hives = make(map[string]*bees.BeeFactoryInterface) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/hives/hives_response.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/hives/hives_response.go#L64-L66
go
train
// AddHive adds a hive to the response
func (r *HiveResponse) AddHive(hive *bees.BeeFactoryInterface)
// AddHive adds a hive to the response func (r *HiveResponse) AddHive(hive *bees.BeeFactoryInterface)
{ r.hives[(*hive).Name()] = hive }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/hives/hives_response.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/hives/hives_response.go#L69-L81
go
train
// Send responds to a request with http.StatusOK
func (r *HiveResponse) Send(response *restful.Response)
// Send responds to a request with http.StatusOK func (r *HiveResponse) Send(response *restful.Response)
{ var keys []string for k := range r.hives { keys = append(keys, k) } sort.Strings(keys) for _, k := range keys { r.Hives = append(r.Hives, PrepareHiveResponse(r.Context, r.hives[k])) } r.Response.Send(response) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/hives/hives_response.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/hives/hives_response.go#L84-L93
go
train
// EmptyResponse returns an empty API response for this endpoint if there's no data to respond with
func (r *HiveResponse) EmptyResponse() interface{}
// EmptyResponse returns an empty API response for this endpoint if there's no data to respond with func (r *HiveResponse) EmptyResponse() interface{}
{ if len(r.hives) == 0 { var out struct { Hives interface{} `json:"hives"` } out.Hives = []HiveInfoResponse{} return out } return nil }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/bees/bees_response.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees_response.go#L57-L63
go
train
// Init a new response
func (r *BeeResponse) Init(context smolder.APIContext)
// Init a new response func (r *BeeResponse) Init(context smolder.APIContext)
{ r.Parent = r r.Context = context r.bees = make(map[string]*bees.BeeInterface) r.hives = make(map[string]*bees.BeeFactoryInterface) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/bees/bees_response.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees_response.go#L66-L76
go
train
// AddBee adds a bee to the response
func (r *BeeResponse) AddBee(bee *bees.BeeInterface)
// AddBee adds a bee to the response func (r *BeeResponse) AddBee(bee *bees.BeeInterface)
{ r.bees[(*bee).Name()] = bee hive := bees.GetFactory((*bee).Namespace()) if hive == nil { panic("Hive for Bee not found") } r.hives[(*hive).Name()] = hive r.Hives = append(r.Hives, hives.PrepareHiveResponse(r.Context, hive)) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/bees/bees_response.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees_response.go#L79-L91
go
train
// Send responds to a request with http.StatusOK
func (r *BeeResponse) Send(response *restful.Response)
// Send responds to a request with http.StatusOK func (r *BeeResponse) Send(response *restful.Response)
{ var keys []string for k := range r.bees { keys = append(keys, k) } sort.Strings(keys) for _, k := range keys { r.Bees = append(r.Bees, prepareBeeResponse(r.Context, r.bees[k])) } r.Response.Send(response) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/bees/bees_response.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees_response.go#L94-L103
go
train
// EmptyResponse returns an empty API response for this endpoint if there's no data to respond with
func (r *BeeResponse) EmptyResponse() interface{}
// EmptyResponse returns an empty API response for this endpoint if there's no data to respond with func (r *BeeResponse) EmptyResponse() interface{}
{ if len(r.bees) == 0 { var out struct { Bees interface{} `json:"bees"` } out.Bees = []beeInfoResponse{} return out } return nil }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/execbee/execbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/execbee/execbee.go#L44-L140
go
train
// Action triggers the action passed to it.
func (mod *ExecBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *ExecBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "execute": var command string var stdin string action.Options.Bind("command", &command) action.Options.Bind("stdin", &stdin) mod.Logln("Executing locally: ", command) go func() { c := strings.Split(command, " ") cmd := exec.Command(c[0], ...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/pushoverbee/pushoverbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/pushoverbee/pushoverbee.go#L48-L89
go
train
// Action triggers the action passed to it.
func (mod *PushoverBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *PushoverBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "send": var message, title, nurl, urlTitle string action.Options.Bind("message", &message) action.Options.Bind("title", &title) action.Options.Bind("url", &nurl) action.Options.Bind("url_title", &urlTitle) msg := url.Values{} msg.Set("token", ...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/pushoverbee/pushoverbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/pushoverbee/pushoverbee.go#L92-L96
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *PushoverBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *PushoverBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("token", &mod.token) options.Bind("user_token", &mod.userToken) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/api.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/api.go#L71-L82
go
train
// Try to read a local/embedded asset. Gracefully fail and read index.html if // if not found.
func readAssetOrIndex(path string) (string, []byte, error)
// Try to read a local/embedded asset. Gracefully fail and read index.html if // if not found. func readAssetOrIndex(path string) (string, []byte, error)
{ b, err := Asset(path) if err != nil { path = "config/index.html" b, err = Asset(path) if err != nil { return path, nil, err } } return path, b, nil }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/api.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/api.go#L164-L202
go
train
// Run sets up the restful API container and an HTTP server go-routine
func Run()
// Run sets up the restful API container and an HTTP server go-routine func Run()
{ // to see what happens in the package, uncomment the following //restful.TraceLogger(log.New(os.Stdout, "[restful] ", log.LstdFlags|log.Lshortfile)) // Setup web-service smolderConfig := smolder.APIConfig{ BaseURL: canonicalURL, PathPrefix: "v1/", } context := &context.APIContext{ Config: smolderConf...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/mumblebee/mumblebeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/mumblebee/mumblebeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *MumbleBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *MumbleBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := MumbleBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/tumblrbee/tumblrbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/tumblrbee/tumblrbeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *TumblrBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *TumblrBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := TumblrBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/tumblrbee/tumblrbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/tumblrbee/tumblrbeefactory.go#L68-L108
go
train
// Options returns the options available to configure this Bee.
func (factory *TumblrBeeFactory) Options() []bees.BeeOptionDescriptor
// Options returns the options available to configure this Bee. func (factory *TumblrBeeFactory) Options() []bees.BeeOptionDescriptor
{ opts := []bees.BeeOptionDescriptor{ { Name: "blogname", Description: "Name of the Tumblr blog", Type: "string", Mandatory: true, }, { Name: "consumer_key", Description: "Consumer Key", Type: "string", Mandatory: true, }, { Name: "consumer_s...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/githubbee/githubbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/githubbee/githubbeefactory.go#L35-L42
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *GitHubBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *GitHubBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := GitHubBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/githubbee/githubbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/githubbee/githubbeefactory.go#L95-L514
go
train
// Events describes the available events provided by this Bee.
func (factory *GitHubBeeFactory) Events() []bees.EventDescriptor
// Events describes the available events provided by this Bee. func (factory *GitHubBeeFactory) Events() []bees.EventDescriptor
{ events := []bees.EventDescriptor{ { Namespace: factory.Name(), Name: "push", Description: "Commits were pushed to a repository", Options: []bees.PlaceholderDescriptor{ { Name: "public", Description: "Indicates whether this was a public activity", Type: "string...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/huebee/huebee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/huebee/huebee.go#L44-L113
go
train
// Action triggers the action passed to it.
func (mod *HueBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *HueBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "setcolor": var lightID int var color string brightness := 254 action.Options.Bind("light", &lightID) action.Options.Bind("color", &color) action.Options.Bind("brightness", &brightness) light, err := mod.client.FindLightById(strconv.Itoa(light...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/huebee/huebee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/huebee/huebee.go#L116-L123
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *HueBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *HueBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("address", &mod.bridge) options.Bind("key", &mod.key) mod.client = hue.NewBridge(mod.bridge, mod.key) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/socketbee/socketbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/socketbee/socketbeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *SocketBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *SocketBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := SocketBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cronbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cronbeefactory.go#L35-L42
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *CronBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *CronBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := CronBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cron/crontime.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L52-L54
go
train
// Returns the time.Duration until the next event.
func (c *crontime) DurationUntilNextEvent() time.Duration
// Returns the time.Duration until the next event. func (c *crontime) DurationUntilNextEvent() time.Duration
{ return c.nextEvent().Sub(time.Now()) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cron/crontime.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L93-L106
go
train
// This functions calculates the next event
func (c *crontime) calculateEvent(baseTime time.Time) time.Time
// This functions calculates the next event func (c *crontime) calculateEvent(baseTime time.Time) time.Time
{ c.calculationInProgress = true defer c.setCalculationInProgress(false) baseTime = setNanoecond(baseTime, 10000) c.calculatedTime = baseTime // Ignore all Events in the Past & initial 'result' //c.calculatedTime = setNanoecond(c.calculatedTime, 10000) c.nextValidMonth(baseTime) c.nextValidDay(baseTime) c.next...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cron/crontime.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L109-L123
go
train
// Calculates the next valid Month based upon the previous results.
func (c *crontime) nextValidMonth(baseTime time.Time)
// Calculates the next valid Month based upon the previous results. func (c *crontime) nextValidMonth(baseTime time.Time)
{ for _, mon := range c.month { if mon >= int(c.calculatedTime.Month()) { //log.Print("Inside Month", mon, c.calculatedTime) c.calculatedTime = setMonth(c.calculatedTime, mon) //log.Println(" :: and out", c.calculatedTime) return } } // If no result was found try it again in the following year c.ca...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cron/crontime.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L126-L152
go
train
// Calculates the next valid Day based upon the previous results.
func (c *crontime) nextValidDay(baseTime time.Time)
// Calculates the next valid Day based upon the previous results. func (c *crontime) nextValidDay(baseTime time.Time)
{ for _, dom := range c.dom { if dom >= c.calculatedTime.Day() { for _, dow := range c.dow { if monthHasDow(dow, dom, int(c.calculatedTime.Month()), c.calculatedTime.Year()) { c.calculatedTime = setDay(c.calculatedTime, dom) //log.Println("Cronbee: Day-INS-1:", c.calculatedTime) return } ...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cron/crontime.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L155-L174
go
train
// Calculates the next valid Hour based upon the previous results.
func (c *crontime) nextValidHour(baseTime time.Time)
// Calculates the next valid Hour based upon the previous results. func (c *crontime) nextValidHour(baseTime time.Time)
{ for _, hour := range c.hour { if c.calculatedTime.Day() == baseTime.Day() { if !hasPassed(hour, c.calculatedTime.Hour()) { c.calculatedTime = setHour(c.calculatedTime, hour) return } } else { c.calculatedTime = setHour(c.calculatedTime, hour) return } } // If no result was found try it a...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cron/crontime.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L177-L194
go
train
// Calculates the next valid Minute based upon the previous results.
func (c *crontime) nextValidMinute(baseTime time.Time)
// Calculates the next valid Minute based upon the previous results. func (c *crontime) nextValidMinute(baseTime time.Time)
{ for _, min := range c.minute { if c.calculatedTime.Hour() == baseTime.Hour() { if !hasPassed(min, c.calculatedTime.Minute()) { c.calculatedTime = setMinute(c.calculatedTime, min) return } } else { c.calculatedTime = setMinute(c.calculatedTime, min) return } } c.calculatedTime = c.calcula...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cron/crontime.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L197-L215
go
train
// Calculates the next valid Second based upon the previous results.
func (c *crontime) nextValidSecond(baseTime time.Time)
// Calculates the next valid Second based upon the previous results. func (c *crontime) nextValidSecond(baseTime time.Time)
{ for _, sec := range c.second { if !c.minuteHasPassed(baseTime) { // check if sec is in the past. <= prevents triggering the same event twice if sec > c.calculatedTime.Second() { c.calculatedTime = setSecond(c.calculatedTime, sec) return } } else { c.calculatedTime = setSecond(c.calculatedTim...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cronbee/cron/crontime.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L271-L319
go
train
// Check if the combination of day(of month), month and year is the weekday dow.
func monthHasDow(dow, dom, month, year int) bool
// Check if the combination of day(of month), month and year is the weekday dow. func monthHasDow(dow, dom, month, year int) bool
{ if !monthHasDom(dom, month, year) { return false } Nday := dom % 7 var Nmonth int switch month { case 1: Nmonth = 0 case 2: Nmonth = 3 case 3: Nmonth = 3 case 4: Nmonth = 6 case 5: Nmonth = 1 case 6: Nmonth = 4 case 7: Nmonth = 6 case 8: Nmonth = 2 case 9: Nmonth = 5 case 10: Nmo...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/alertoverbee/alertoverbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/alertoverbee/alertoverbeefactory.go#L36-L43
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *AlertOverBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *AlertOverBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := AlertOverBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/slackbee/slackbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/slackbee/slackbeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *SlackBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *SlackBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := SlackBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/devrantbee/devrantbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/devrantbee/devrantbee.go#L41-L81
go
train
// Action triggers the action passed to it.
func (mod *DevrantBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *DevrantBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "surprise": rant, err := mod.client.Surprise() if err != nil { mod.LogErrorf("Failed to fetch surprise rant: %v", err) } mod.triggerEvent(rant) case "weekly": rants, err := mod.client.WeeklyRants() if err != nil { mod.LogErrorf("Failed t...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/devrantbee/devrantbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/devrantbee/devrantbee.go#L144-L149
go
train
// Run executes the Bee's event loop.
func (mod *DevrantBee) Run(eventChan chan bees.Event)
// Run executes the Bee's event loop. func (mod *DevrantBee) Run(eventChan chan bees.Event)
{ mod.evchan = eventChan // Setting up the client, unfortunately we can't really log in as an user mod.client = devgorant.New() }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/pastebinbee/pastebinbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/pastebinbee/pastebinbee.go#L38-L64
go
train
// Action triggers the action passed to it.
func (mod *PastebinBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *PastebinBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "post": title := "" content := "" expire := "" exposure := "" action.Options.Bind("title", &title) action.Options.Bind("content", &content) action.Options.Bind("expire", &expire) action.Options.Bind("exposure", &exposure) ret, err := mod....
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/pastebinbee/pastebinbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/pastebinbee/pastebinbee.go#L67-L69
go
train
// Run executes the Bee's event loop.
func (mod *PastebinBee) Run(eventChan chan bees.Event)
// Run executes the Bee's event loop. func (mod *PastebinBee) Run(eventChan chan bees.Event)
{ mod.client = pastebin.NewPastebin(mod.apiDevKey) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/pastebinbee/pastebinbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/pastebinbee/pastebinbee.go#L72-L76
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *PastebinBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *PastebinBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("api_dev_key", &mod.apiDevKey) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/notificationbee/notificationbee_unix.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/notificationbee/notificationbee_unix.go#L31-L45
go
train
// Run executes the Bee's event loop.
func (mod *NotificationBee) execAction(text string, urgency uint32)
// Run executes the Bee's event loop. func (mod *NotificationBee) execAction(text string, urgency uint32)
{ conn, err := dbus.SessionBus() if err != nil { panic(err) } notifier := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") call := notifier.Call("org.freedesktop.Notifications.Notify", 0, "", uint32(0), "", "Beehive", text, []string{}, map[string]dbus.Variant{"urgency": dbus.M...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/factories.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/factories.go#L45-L47
go
train
// OAuth2AccessToken returns the oauth2 access token.
func (factory *BeeFactory) OAuth2AccessToken(id, secret, code string) (*oauth2.Token, error)
// OAuth2AccessToken returns the oauth2 access token. func (factory *BeeFactory) OAuth2AccessToken(id, secret, code string) (*oauth2.Token, error)
{ return nil, errors.New("This Hive does not implement OAuth2") }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/factories.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/factories.go#L118-L125
go
train
// GetFactory returns the factory with a specific name.
func GetFactory(identifier string) *BeeFactoryInterface
// GetFactory returns the factory with a specific name. func GetFactory(identifier string) *BeeFactoryInterface
{ factory, ok := factories[identifier] if ok { return factory } return nil }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/factories.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/factories.go#L128-L135
go
train
// GetFactories returns all known bee factories.
func GetFactories() []*BeeFactoryInterface
// GetFactories returns all known bee factories. func GetFactories() []*BeeFactoryInterface
{ r := []*BeeFactoryInterface{} for _, factory := range factories { r = append(r, factory) } return r }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/htmlextractbee/htmlextractbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/htmlextractbee/htmlextractbeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *HTMLExtractBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *HTMLExtractBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := HTMLExtractBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/spaceapibee/spaceapibee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/spaceapibee/spaceapibee.go#L43-L88
go
train
// Action triggers the action passed to it.
func (mod *SpaceAPIBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *SpaceAPIBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "status": type SpaceAPIResult struct { State struct { Open bool `json:"open"` } `json:"state"` } apiState := new(SpaceAPIResult) // get json data resp, err := http.Get(mod.url) if err != nil { mod.Logln("Error: SpaceAPI instance @ "...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/spaceapibee/spaceapibee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/spaceapibee/spaceapibee.go#L96-L100
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *SpaceAPIBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *SpaceAPIBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("url", &mod.url) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/devrantbee/devrantbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/devrantbee/devrantbeefactory.go#L34-L41
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *DevrantBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *DevrantBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := DevrantBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/fsnotifybee/fsnotifybeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/fsnotifybee/fsnotifybeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *FSNotifyBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *FSNotifyBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := FSNotifyBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/chains.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/chains.go#L52-L60
go
train
// GetChain returns a chain with a specific id
func GetChain(id string) *Chain
// GetChain returns a chain with a specific id func GetChain(id string) *Chain
{ for _, c := range chains { if c.Name == id { return &c } } return nil }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/chains.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/chains.go#L63-L84
go
train
// SetChains sets the currently configured chains
func SetChains(cs []Chain)
// SetChains sets the currently configured chains func SetChains(cs []Chain)
{ newcs := []Chain{} // migrate old chain style for _, c := range cs { for _, el := range c.Elements { if el.Action.Name != "" { el.Action.ID = UUID() c.Actions = append(c.Actions, el.Action.ID) actions = append(actions, el.Action) } if el.Filter.Name != "" { //FIXME: migrate old style fi...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/chains.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/chains.go#L87-L123
go
train
// execChains executes chains for an event we received
func execChains(event *Event)
// execChains executes chains for an event we received func execChains(event *Event)
{ for _, c := range chains { if c.Event.Name != event.Name || c.Event.Bee != event.Bee { continue } m := make(map[string]interface{}) for _, opt := range event.Options { m[opt.Name] = opt.Value } ctx.FillMap(m) failed := false log.Println("Executing chain:", c.Name, "-", c.Description) for _...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/logs/logs_get.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/logs/logs_get.go#L46-L51
go
train
// GetParams returns the parameters supported by this API endpoint
func (r *LogResource) GetParams() []*restful.Parameter
// GetParams returns the parameters supported by this API endpoint func (r *LogResource) GetParams() []*restful.Parameter
{ params := []*restful.Parameter{} params = append(params, restful.QueryParameter("bee", "id of a bee").DataType("string")) return params }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/logs/logs_get.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/logs/logs_get.go#L64-L77
go
train
// GetByIDs sends out all items matching a set of IDs /* func (r *LogResource) GetByIDs(ctx smolder.APIContext, request *restful.Request, response *restful.Response, ids []string) { resp := LogResponse{} resp.Init(ctx) resp.Send(response) } */ // Get sends out items matching the query parameters
func (r *LogResource) Get(ctx smolder.APIContext, request *restful.Request, response *restful.Response, params map[string][]string)
// GetByIDs sends out all items matching a set of IDs /* func (r *LogResource) GetByIDs(ctx smolder.APIContext, request *restful.Request, response *restful.Response, ids []string) { resp := LogResponse{} resp.Init(ctx) resp.Send(response) } */ // Get sends out items matching the query parameters func (r *LogResourc...
{ // ctxapi := ctx.(*context.APIContext) bee := request.QueryParameter("bee") resp := LogResponse{} resp.Init(ctx) logs := bees.GetLogs(bee) for _, log := range logs { resp.AddLog(&log) } resp.Send(response) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/horizonboxbee/horizonboxbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/horizonboxbee/horizonboxbeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *HorizonBoxBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *HorizonBoxBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := HorizonBoxBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/telegrambee/telegrambeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/telegrambee/telegrambeefactory.go#L33-L40
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *TelegramBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *TelegramBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := TelegramBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/gitterbee/gitterbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/gitterbee/gitterbee.go#L47-L93
go
train
// Action triggers the actions passed to it.
func (mod *GitterBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the actions passed to it. func (mod *GitterBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "send": var room string var message string action.Options.Bind("room", &room) action.Options.Bind("message", &message) roomID, err := mod.client.GetRoomId(room) if err != nil { mod.LogErrorf("Failed to fetch room ID from uri: %v", err) re...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/gitterbee/gitterbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/gitterbee/gitterbee.go#L96-L119
go
train
// Run executes the Bee's event loop.
func (mod *GitterBee) Run(eventChan chan bees.Event)
// Run executes the Bee's event loop. func (mod *GitterBee) Run(eventChan chan bees.Event)
{ mod.eventChan = eventChan mod.roomChans = make(map[string]chan interface{}) mod.client = gitter.New(mod.accessToken) user, err := mod.client.GetUser() if err != nil { mod.LogErrorf("Failed to fetch current user: %v", err) return } mod.userID = user.ID for _, room := range mod.rooms { mod.join(room) ...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/gitterbee/gitterbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/gitterbee/gitterbee.go#L214-L219
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *GitterBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *GitterBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("access_token", &mod.accessToken) options.Bind("rooms", &mod.rooms) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/bees/bees_delete.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees_delete.go#L45-L61
go
train
// Delete processes an incoming DELETE request
func (r *BeeResource) Delete(context smolder.APIContext, request *restful.Request, response *restful.Response)
// Delete processes an incoming DELETE request func (r *BeeResource) Delete(context smolder.APIContext, request *restful.Request, response *restful.Response)
{ resp := BeeResponse{} resp.Init(context) id := request.PathParameter("bee-id") bee := bees.GetBee(id) if bee == nil { r.NotFound(request, response) return } go func() { bees.DeleteBee(bee) }() resp.Send(response) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/githubbee/githubbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/githubbee/githubbee.go#L48-L93
go
train
// Action triggers the actions passed to it.
func (mod *GitHubBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the actions passed to it. func (mod *GitHubBee) Action(action bees.Action) []bees.Placeholder
{ ctx := context.Background() outs := []bees.Placeholder{} switch action.Name { case "follow": var user string action.Options.Bind("username", &user) if _, err := mod.client.Users.Follow(ctx, user); err != nil { mod.LogErrorf("Failed to follow user: %v", err) } case "unfollow": var user string ac...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/githubbee/githubbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/githubbee/githubbee.go#L96-L118
go
train
// Run executes the Bee's event loop.
func (mod *GitHubBee) Run(eventChan chan bees.Event)
// Run executes the Bee's event loop. func (mod *GitHubBee) Run(eventChan chan bees.Event)
{ ts := oauth2.StaticTokenSource( &oauth2.Token{AccessToken: mod.accessToken}, ) tc := oauth2.NewClient(oauth2.NoContext, ts) mod.eventChan = eventChan mod.client = github.NewClient(tc) since := time.Now() // .Add(-time.Duration(24 * time.Hour)) timeout := time.Duration(time.Second * 10) for { select { ...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/githubbee/githubbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/githubbee/githubbee.go#L218-L224
go
train
/* func (mod *GitHubBee) getNotifications() { opts := &github.NotificationListOptions{ All: true, // Participating: true, ListOptions: github.ListOptions{ PerPage: 10, }, } notif, _, err := mod.client.Activity.ListNotifications(opts) if err != nil { mod.LogErrorf("Failed to fetch notifications: %v", er...
func (mod *GitHubBee) ReloadOptions(options bees.BeeOptions)
/* func (mod *GitHubBee) getNotifications() { opts := &github.NotificationListOptions{ All: true, // Participating: true, ListOptions: github.ListOptions{ PerPage: 10, }, } notif, _, err := mod.client.Activity.ListNotifications(opts) if err != nil { mod.LogErrorf("Failed to fetch notifications: %v", er...
{ mod.SetOptions(options) options.Bind("accesstoken", &mod.accessToken) options.Bind("owner", &mod.owner) options.Bind("repository", &mod.repository) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
api/resources/actions/actions_post.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/actions/actions_post.go#L54-L70
go
train
// Post processes an incoming POST (create) request
func (r *ActionResource) Post(context smolder.APIContext, data interface{}, request *restful.Request, response *restful.Response)
// Post processes an incoming POST (create) request func (r *ActionResource) Post(context smolder.APIContext, data interface{}, request *restful.Request, response *restful.Response)
{ resp := ActionResponse{} resp.Init(context) pps := data.(*ActionPostStruct) action := bees.Action{ ID: bees.UUID(), Bee: pps.Action.Bee, Name: pps.Action.Name, Options: pps.Action.Options, } actions := append(bees.GetActions(), action) bees.SetActions(actions) resp.AddAction(&action) r...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cleverbotbee/cleverbotbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cleverbotbee/cleverbotbeefactory.go#L34-L41
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *CleverbotBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *CleverbotBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := CleverbotBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cleverbotbee/cleverbotbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cleverbotbee/cleverbotbeefactory.go#L69-L91
go
train
// Options returns the options available to configure this Bee.
func (factory *CleverbotBeeFactory) Options() []bees.BeeOptionDescriptor
// Options returns the options available to configure this Bee. func (factory *CleverbotBeeFactory) Options() []bees.BeeOptionDescriptor
{ opts := []bees.BeeOptionDescriptor{ { Name: "api_user", Description: "Your cleverbot api username", Type: "string", Mandatory: true, }, { Name: "api_key", Description: "Your cleverbot api key", Type: "string", Mandatory: true, }, { Name: "s...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/emailbee/emailbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/emailbee/emailbee.go#L43-L88
go
train
// Action triggers the action passed to it.
func (mod *EmailBee) Action(action bees.Action) []bees.Placeholder
// Action triggers the action passed to it. func (mod *EmailBee) Action(action bees.Action) []bees.Placeholder
{ outs := []bees.Placeholder{} switch action.Name { case "send": var from, to, plainText, htmlText, subject string action.Options.Bind("sender", &from) action.Options.Bind("recipient", &to) action.Options.Bind("subject", &subject) action.Options.Bind("text", &plainText) action.Options.Bind("html", &htm...
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/emailbee/emailbee.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/emailbee/emailbee.go#L91-L97
go
train
// ReloadOptions parses the config options and initializes the Bee.
func (mod *EmailBee) ReloadOptions(options bees.BeeOptions)
// ReloadOptions parses the config options and initializes the Bee. func (mod *EmailBee) ReloadOptions(options bees.BeeOptions)
{ mod.SetOptions(options) options.Bind("username", &mod.username) options.Bind("password", &mod.password) options.Bind("address", &mod.server) }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cricketbee/cricketbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cricketbee/cricketbeefactory.go#L33-L39
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *CricketBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *CricketBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := CricketBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/cricketbee/cricketbeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cricketbee/cricketbeefactory.go#L67-L78
go
train
// Options returns the options available to configure this Bee.
func (factory *CricketBeeFactory) Options() []bees.BeeOptionDescriptor
// Options returns the options available to configure this Bee. func (factory *CricketBeeFactory) Options() []bees.BeeOptionDescriptor
{ opts := []bees.BeeOptionDescriptor{ { Name: "favourite_team", Default: "Ind", Description: "Please mention for which team you want to get updates", Type: "string", Mandatory: true, }, } return opts }
muesli/beehive
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
bees/timebee/timebeefactory.go
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/timebee/timebeefactory.go#L35-L42
go
train
// New returns a new Bee instance configured with the supplied options.
func (factory *TimeBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
// New returns a new Bee instance configured with the supplied options. func (factory *TimeBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface
{ bee := TimeBee{ Bee: bees.NewBee(name, factory.ID(), description, options), } bee.ReloadOptions(options) return &bee }