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/events.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/events.go#L39-L67 | go | train | // handleEvents handles incoming events and executes matching Chains. | func handleEvents() | // handleEvents handles incoming events and executes matching Chains.
func handleEvents() | {
for {
event, ok := <-eventsIn
if !ok {
log.Println()
log.Println("Stopped event handler!")
break
}
bee := GetBee(event.Bee)
(*bee).LogEvent()
log.Println()
log.Println("Event received:", event.Bee, "/", event.Name, "-", GetEventDescriptor(&event).Description)
for _, v := range event.Optio... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/mastodonbee/mastodonbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/mastodonbee/mastodonbee.go#L50-L81 | go | train | // Action triggers the action passed to it. | func (mod *mastodonBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *mastodonBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "toot":
var text string
action.Options.Bind("text", &text)
// Post status toot on mastodon
status, err := mod.client.PostStatus(context.Background(), &mastodon.Toot{
Status: text,
})
if err != nil {
mod.LogErrorf("Error sending toot: %v", ... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/mastodonbee/mastodonbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/mastodonbee/mastodonbee.go#L84-L114 | go | train | // Run executes the Bee's event loop. | func (mod *mastodonBee) Run(eventChan chan bees.Event) | // Run executes the Bee's event loop.
func (mod *mastodonBee) Run(eventChan chan bees.Event) | {
// Create the new api client
c := mastodon.NewClient(&mastodon.Config{
Server: mod.server,
ClientID: mod.clientID,
ClientSecret: mod.clientSecret,
})
// authorize it
err := c.Authenticate(context.Background(), mod.email, mod.password)
if err != nil {
mod.LogErrorf("Authorization failed, make ... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/mastodonbee/mastodonbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/mastodonbee/mastodonbee.go#L117-L125 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *mastodonBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *mastodonBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("server", &mod.server)
options.Bind("client_id", &mod.clientID)
options.Bind("client_secret", &mod.clientSecret)
options.Bind("email", &mod.email)
options.Bind("password", &mod.password)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/prometheusbee/prometheusbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/prometheusbee/prometheusbee.go#L53-L129 | go | train | // Run executes the Bee's event loop. | func (mod *PrometheusBee) Run(eventChan chan bees.Event) | // Run executes the Bee's event loop.
func (mod *PrometheusBee) Run(eventChan chan bees.Event) | {
// Counter vector registration
mod.counter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: mod.counterVecName,
Help: "Collection of all counter variables being iterated by hives",
},
[]string{"name"},
)
err := prometheus.Register(mod.counter)
if err != nil {
mod.LogErrorf("Error regist... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/prometheusbee/prometheusbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/prometheusbee/prometheusbee.go#L132-L242 | go | train | // Action triggers the action passed to it. | func (mod *PrometheusBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *PrometheusBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "counter_inc":
var label string
action.Options.Bind("label", &label)
c, err := mod.counter.GetMetricWithLabelValues(label)
if err != nil {
mod.LogErrorf("Error incrementing counter: %v", err)
} else {
c.Inc()
}
case "counter_add":
var lab... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/prometheusbee/prometheusbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/prometheusbee/prometheusbee.go#L245-L253 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *PrometheusBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *PrometheusBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("address", &mod.addr)
options.Bind("counter_vec_name", &mod.counterVecName)
options.Bind("gauge_vec_name", &mod.gaugeVecName)
options.Bind("histogram_vec_name", &mod.histogramVecName)
options.Bind("summary_vec_name", &mod.summaryVecName)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/nagiosbee/nagiosbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/nagiosbee/nagiosbee.go#L167-L173 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *NagiosBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *NagiosBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("url", &mod.url)
options.Bind("user", &mod.user)
options.Bind("password", &mod.password)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/socketbee/socketbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/socketbee/socketbee.go#L40-L47 | go | train | // Run executes the Bee's event loop. | func (mod *SocketBee) Run(cin chan bees.Event) | // Run executes the Bee's event loop.
func (mod *SocketBee) Run(cin chan bees.Event) | {
mod.eventChan = cin
select {
case <-mod.SigChan:
return
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/socketbee/socketbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/socketbee/socketbee.go#L50-L86 | go | train | // Action triggers the action passed to it. | func (mod *SocketBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *SocketBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
var data string
var addr string
var port int
action.Options.Bind("address", &addr)
action.Options.Bind("port", &port)
action.Options.Bind("data", &data)
switch action.Name {
case "send":
// log.Println("Sending", data, "to", addr, port)
sa, err := net.ResolveUDPAddr("udp... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | filters/filters.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/filters/filters.go#L46-L53 | go | train | // GetFilter returns a filter with a specific name | func GetFilter(identifier string) *FilterInterface | // GetFilter returns a filter with a specific name
func GetFilter(identifier string) *FilterInterface | {
filter, ok := filters[identifier]
if ok {
return filter
}
return nil
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/openweathermapbee/openweathermapbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/openweathermapbee/openweathermapbeefactory.go#L34-L41 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *OpenweathermapBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *OpenweathermapBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := OpenweathermapBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/openweathermapbee/openweathermapbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/openweathermapbee/openweathermapbeefactory.go#L96-L274 | go | train | // Events describes the available events provided by this Bee. | func (factory *OpenweathermapBeeFactory) Events() []bees.EventDescriptor | // Events describes the available events provided by this Bee.
func (factory *OpenweathermapBeeFactory) Events() []bees.EventDescriptor | {
events := []bees.EventDescriptor{
{
Namespace: factory.Name(),
Name: "current_weather",
Description: "Current weather holds measurement informations",
Options: []bees.PlaceholderDescriptor{
{
Name: "geo_pos_longitude",
Type: "float64",
Description: "Geo positi... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/actions/actions_response.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/actions/actions_response.go#L45-L50 | go | train | // Init a new response | func (r *ActionResponse) Init(context smolder.APIContext) | // Init a new response
func (r *ActionResponse) Init(context smolder.APIContext) | {
r.Parent = r
r.Context = context
r.Actions = []actionInfoResponse{}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/actions/actions_response.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/actions/actions_response.go#L53-L56 | go | train | // AddAction adds a action to the response | func (r *ActionResponse) AddAction(action *bees.Action) | // AddAction adds a action to the response
func (r *ActionResponse) AddAction(action *bees.Action) | {
r.actions = append(r.actions, action)
r.Actions = append(r.Actions, prepareActionResponse(r.Context, action))
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/actions/actions_response.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/actions/actions_response.go#L59-L68 | go | train | // EmptyResponse returns an empty API response for this endpoint if there's no data to respond with | func (r *ActionResponse) EmptyResponse() interface{} | // EmptyResponse returns an empty API response for this endpoint if there's no data to respond with
func (r *ActionResponse) EmptyResponse() interface{} | {
if len(r.actions) == 0 {
var out struct {
Actions interface{} `json:"actions"`
}
out.Actions = []actionInfoResponse{}
return out
}
return nil
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/huebee/huebeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/huebee/huebeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *HueBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *HueBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := HueBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/logs/logs_response.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/logs/logs_response.go#L48-L53 | go | train | // Init a new response | func (r *LogResponse) Init(context smolder.APIContext) | // Init a new response
func (r *LogResponse) Init(context smolder.APIContext) | {
r.Parent = r
r.Context = context
r.Logs = []logInfoResponse{}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/logs/logs_response.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/logs/logs_response.go#L56-L59 | go | train | // AddLog adds a log to the response | func (r *LogResponse) AddLog(log *bees.LogMessage) | // AddLog adds a log to the response
func (r *LogResponse) AddLog(log *bees.LogMessage) | {
r.logs = append(r.logs, log)
r.Logs = append(r.Logs, prepareLogResponse(r.Context, log))
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/logs/logs_response.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/logs/logs_response.go#L62-L71 | go | train | // EmptyResponse returns an empty API response for this endpoint if there's no data to respond with | func (r *LogResponse) EmptyResponse() interface{} | // EmptyResponse returns an empty API response for this endpoint if there's no data to respond with
func (r *LogResponse) EmptyResponse() interface{} | {
if len(r.logs) == 0 {
var out struct {
Logs interface{} `json:"logs"`
}
out.Logs = []logInfoResponse{}
return out
}
return nil
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/actions.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/actions.go#L51-L59 | go | train | // GetAction returns one action with a specific ID. | func GetAction(id string) *Action | // GetAction returns one action with a specific ID.
func GetAction(id string) *Action | {
for _, a := range actions {
if a.ID == id {
return &a
}
}
return nil
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/actions.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/actions.go#L67-L118 | go | train | // execAction executes an action and map its ins & outs. | func execAction(action Action, opts map[string]interface{}) bool | // execAction executes an action and map its ins & outs.
func execAction(action Action, opts map[string]interface{}) bool | {
a := Action{
Bee: action.Bee,
Name: action.Name,
}
for _, opt := range action.Options {
ph := Placeholder{
Name: opt.Name,
}
switch opt.Value.(type) {
case string:
var value bytes.Buffer
tmpl, err := template.New(action.Bee + "_" + action.Name + "_" + opt.Name).Funcs(templatehelper.FuncMa... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/context/context.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/context/context.go#L36-L41 | go | train | // NewAPIContext returns a new polly context | func (context *APIContext) NewAPIContext() smolder.APIContext | // NewAPIContext returns a new polly context
func (context *APIContext) NewAPIContext() smolder.APIContext | {
ctx := &APIContext{
Config: context.Config,
}
return ctx
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/context/context.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/context/context.go#L44-L56 | go | train | // Authentication parses the request for an access-/authtoken and returns the matching user | func (context *APIContext) Authentication(request *restful.Request) (interface{}, error) | // Authentication parses the request for an access-/authtoken and returns the matching user
func (context *APIContext) Authentication(request *restful.Request) (interface{}, error) | {
//FIXME: implement this properly
t := request.QueryParameter("accesstoken")
if len(t) == 0 {
t = request.HeaderParameter("authorization")
if strings.Index(t, " ") > 0 {
t = strings.TrimSpace(strings.Split(t, " ")[1])
}
}
return nil, nil // context.GetUserByAccessToken(t)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/simplepushbee/simplepushbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/simplepushbee/simplepushbeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *SimplepushBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *SimplepushBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := SimplepushBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/placeholders.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/placeholders.go#L45-L61 | go | train | // SetValue sets a value in the Placeholder slice. | func (ph *Placeholders) SetValue(name string, _type string, value interface{}) | // SetValue sets a value in the Placeholder slice.
func (ph *Placeholders) SetValue(name string, _type string, value interface{}) | {
if ph.Value(name) == nil {
p := Placeholder{
Name: name,
Type: _type,
Value: value,
}
*ph = append(*ph, p)
} else {
for i := 0; i < len(*ph); i++ {
if (*ph)[i].Name == name {
(*ph)[i].Type = _type
(*ph)[i].Value = value
}
}
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/placeholders.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/placeholders.go#L64-L72 | go | train | // Value retrieves a value from a Placeholder slice. | func (ph Placeholders) Value(name string) interface{} | // Value retrieves a value from a Placeholder slice.
func (ph Placeholders) Value(name string) interface{} | {
for _, p := range ph {
if p.Name == name {
return p.Value
}
}
return nil
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/placeholders.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/placeholders.go#L75-L82 | go | train | // Bind a value from a Placeholder slice. | func (ph Placeholders) Bind(name string, dst interface{}) error | // Bind a value from a Placeholder slice.
func (ph Placeholders) Bind(name string, dst interface{}) error | {
v := ph.Value(name)
if v == nil {
return errors.New("Placeholder with name " + name + " not found")
}
return ConvertValue(v, dst)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/placeholders.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/placeholders.go#L85-L233 | go | train | // ConvertValue tries to convert v to dst. | func ConvertValue(v interface{}, dst interface{}) error | // ConvertValue tries to convert v to dst.
func ConvertValue(v interface{}, dst interface{}) error | {
switch d := dst.(type) {
case *string:
switch vt := v.(type) {
case string:
*d = vt
case []string:
*d = strings.Join(vt, ",")
case bool:
*d = strconv.FormatBool(vt)
case int64:
*d = strconv.FormatInt(vt, 10)
case float64:
*d = strconv.FormatFloat(vt, 'f', -1, 64)
case int:
*d = strc... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/alertoverbee/alertoverbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/alertoverbee/alertoverbee.go#L41-L84 | go | train | // Action triggers the action passed to it. | func (mod *AlertOverBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *AlertOverBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "send":
var receiver, title, content, weburl, priority string
action.Options.Bind("receiver", &receiver)
action.Options.Bind("title", &title)
action.Options.Bind("content", &content)
action.Options.Bind("url", &weburl)
action.Options.Bind("priori... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/alertoverbee/alertoverbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/alertoverbee/alertoverbee.go#L87-L90 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *AlertOverBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *AlertOverBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("source", &mod.source)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/descriptors.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/descriptors.go#L65-L78 | go | train | // GetActionDescriptor returns the ActionDescriptor matching an action. | func GetActionDescriptor(action *Action) ActionDescriptor | // GetActionDescriptor returns the ActionDescriptor matching an action.
func GetActionDescriptor(action *Action) ActionDescriptor | {
bee := GetBee(action.Bee)
if bee == nil {
panic("Bee " + action.Bee + " not registered")
}
factory := (*GetFactory((*bee).Namespace()))
for _, ac := range factory.Actions() {
if ac.Name == action.Name {
return ac
}
}
return ActionDescriptor{}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/descriptors.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/descriptors.go#L81-L94 | go | train | // GetEventDescriptor returns the EventDescriptor matching an event. | func GetEventDescriptor(event *Event) EventDescriptor | // GetEventDescriptor returns the EventDescriptor matching an event.
func GetEventDescriptor(event *Event) EventDescriptor | {
bee := GetBee(event.Bee)
if bee == nil {
panic("Bee " + event.Bee + " not registered")
}
factory := (*GetFactory((*bee).Namespace()))
for _, ev := range factory.Events() {
if ev.Name == event.Name {
return ev
}
}
return EventDescriptor{}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/serialbee/serialbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/serialbee/serialbee.go#L45-L69 | go | train | // Action triggers the action passed to it. | func (mod *SerialBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *SerialBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
text := ""
switch action.Name {
case "send":
action.Options.Bind("text", &text)
bufOut := new(bytes.Buffer)
err := binary.Write(bufOut, binary.LittleEndian, []byte(text))
if err != nil {
panic(err)
}
_, err = mod.conn.Write(bufOut.Bytes())
if err != nil {
panic... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/serialbee/serialbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/serialbee/serialbee.go#L110-L139 | go | train | // Run executes the Bee's event loop. | func (mod *SerialBee) Run(eventChan chan bees.Event) | // Run executes the Bee's event loop.
func (mod *SerialBee) Run(eventChan chan bees.Event) | {
if mod.baudrate == 0 || mod.device == "" {
return
}
var err error
options := serial.OpenOptions{
PortName: mod.device,
BaudRate: uint(mod.baudrate),
}
mod.conn, err = serial.Open(options)
if err != nil {
mod.LogFatal(err)
}
defer mod.conn.Close()
go func() {
for {
if err := mod.handleEvents... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/serialbee/serialbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/serialbee/serialbee.go#L142-L147 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *SerialBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *SerialBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("device", &mod.device)
options.Bind("baudrate", &mod.baudrate)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/mastodonbee/mastodonbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/mastodonbee/mastodonbeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *mastodonBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *mastodonBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := mastodonBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/mastodonbee/mastodonbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/mastodonbee/mastodonbeefactory.go#L68-L102 | go | train | // Options returns the options available to configure this Bee. | func (factory *mastodonBeeFactory) Options() []bees.BeeOptionDescriptor | // Options returns the options available to configure this Bee.
func (factory *mastodonBeeFactory) Options() []bees.BeeOptionDescriptor | {
opts := []bees.BeeOptionDescriptor{
{
Name: "server",
Description: "URL for the desired mastodon server",
Type: "string",
Mandatory: true,
},
{
Name: "client_id",
Description: "Client id for the mastodon client",
Type: "string",
Mandatory: true,
},
{... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/cricketbee/cricketbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cricketbee/cricketbee.go#L101-L104 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *CricketBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *CricketBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("favourite_team", &mod.favTeam)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/twitterbee/twitterbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/twitterbee/twitterbeefactory.go#L34-L41 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *TwitterBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *TwitterBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := TwitterBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/twitterbee/twitterbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/twitterbee/twitterbeefactory.go#L69-L93 | go | train | // Options returns the options available to configure this Bee. | func (factory *TwitterBeeFactory) Options() []bees.BeeOptionDescriptor | // Options returns the options available to configure this Bee.
func (factory *TwitterBeeFactory) Options() []bees.BeeOptionDescriptor | {
opts := []bees.BeeOptionDescriptor{
{
Name: "consumer_key",
Description: "Consumer key for Twitter API",
Type: "string",
},
{
Name: "consumer_secret",
Description: "Consumer secret for Twitter API",
Type: "string",
},
{
Name: "access_token",
Descr... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/ircbee/ircbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/ircbee/ircbeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *IrcBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *IrcBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := IrcBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/ircbee/ircbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/ircbee/ircbeefactory.go#L68-L102 | go | train | // Options returns the options available to configure this Bee. | func (factory *IrcBeeFactory) Options() []bees.BeeOptionDescriptor | // Options returns the options available to configure this Bee.
func (factory *IrcBeeFactory) Options() []bees.BeeOptionDescriptor | {
opts := []bees.BeeOptionDescriptor{
{
Name: "address",
Description: "Hostname of IRC server, eg: irc.example.org:6667",
Type: "address",
Mandatory: true,
},
{
Name: "nick",
Description: "Nickname to use for IRC",
Type: "string",
Default: "beehive",
... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/ircbee/ircbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/ircbee/ircbeefactory.go#L105-L119 | go | train | // States returns the state values provided by this Bee. | func (factory *IrcBeeFactory) States() []bees.StateDescriptor | // States returns the state values provided by this Bee.
func (factory *IrcBeeFactory) States() []bees.StateDescriptor | {
opts := []bees.StateDescriptor{
{
Name: "connected",
Description: "Whether this bee is currently connected to IRC",
Type: "bool",
},
{
Name: "channels",
Description: "Which channels this bee is currently connected to",
Type: "[]string",
},
}
return opts
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/bees/bees_get.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees_get.go#L54-L69 | go | train | // GetByIDs sends out all items matching a set of IDs | func (r *BeeResource) GetByIDs(ctx smolder.APIContext, request *restful.Request, response *restful.Response, ids []string) | // GetByIDs sends out all items matching a set of IDs
func (r *BeeResource) GetByIDs(ctx smolder.APIContext, request *restful.Request, response *restful.Response, ids []string) | {
resp := BeeResponse{}
resp.Init(ctx)
for _, id := range ids {
bee := bees.GetBee(id)
if bee == nil {
r.NotFound(request, response)
return
}
resp.AddBee(bee)
}
resp.Send(response)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/bees/bees_get.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees_get.go#L72-L83 | go | train | // Get sends out items matching the query parameters | func (r *BeeResource) Get(ctx smolder.APIContext, request *restful.Request, response *restful.Response, params map[string][]string) | // Get sends out items matching the query parameters
func (r *BeeResource) Get(ctx smolder.APIContext, request *restful.Request, response *restful.Response, params map[string][]string) | {
// ctxapi := ctx.(*context.APIContext)
bees := bees.GetBees()
resp := BeeResponse{}
resp.Init(ctx)
for _, bee := range bees {
resp.AddBee(bee)
}
resp.Send(response)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/chains/chains_response.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/chains/chains_response.go#L50-L55 | go | train | // Init a new response | func (r *ChainResponse) Init(context smolder.APIContext) | // Init a new response
func (r *ChainResponse) Init(context smolder.APIContext) | {
r.Parent = r
r.Context = context
r.chains = make(map[string]*bees.Chain)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/chains/chains_response.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/chains/chains_response.go#L58-L60 | go | train | // AddChain adds a chain to the response | func (r *ChainResponse) AddChain(chain bees.Chain) | // AddChain adds a chain to the response
func (r *ChainResponse) AddChain(chain bees.Chain) | {
r.chains[chain.Name] = &chain
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/chains/chains_response.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/chains/chains_response.go#L63-L75 | go | train | // Send responds to a request with http.StatusOK | func (r *ChainResponse) Send(response *restful.Response) | // Send responds to a request with http.StatusOK
func (r *ChainResponse) Send(response *restful.Response) | {
var keys []string
for k := range r.chains {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
r.Chains = append(r.Chains, prepareChainResponse(r.Context, r.chains[k]))
}
r.Response.Send(response)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/chains/chains_response.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/chains/chains_response.go#L78-L87 | go | train | // EmptyResponse returns an empty API response for this endpoint if there's no data to respond with | func (r *ChainResponse) EmptyResponse() interface{} | // EmptyResponse returns an empty API response for this endpoint if there's no data to respond with
func (r *ChainResponse) EmptyResponse() interface{} | {
if len(r.chains) == 0 {
var out struct {
Chains interface{} `json:"chains"`
}
out.Chains = []chainInfoResponse{}
return out
}
return nil
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/notificationbee/notificationbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/notificationbee/notificationbee.go#L65-L87 | go | train | // Action triggers the action passed to it. | func (mod *NotificationBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *NotificationBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "notify":
text := ""
u := ""
urgency := UrgencyNormal
action.Options.Bind("text", &text)
action.Options.Bind("urgency", &u)
text = strings.TrimSpace(text)
urgency, _ = urgencyMap[u]
if len(text) > 0 {
mod.execAction(text, urgency)
}
... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/cronbee/cron/cronparser.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/cronparser.go#L41-L110 | go | train | // ParseInput parses the input and returns a pointer to the generated datastructure.
// input[0]: Second
// input[1]: Minute
// input[2]: Hour
// input[3]: Weekday
// input[4]: Day (of Month)
// input[5]: Month | func ParseInput(input [6]string) *crontime | // ParseInput parses the input and returns a pointer to the generated datastructure.
// input[0]: Second
// input[1]: Minute
// input[2]: Hour
// input[3]: Weekday
// input[4]: Day (of Month)
// input[5]: Month
func ParseInput(input [6]string) *crontime | {
var result crontime
// Check the syntax of the input
for i := 0; i != len(input); i++ {
if checkSyntax(input[i]) == false {
log.Panicln("Invalid config at Line", i) // TODO be more helpful
}
}
// Parse Input like 23-05
for i := 0; i != len(input); i++ {
if strings.Contains(input[i], "-") {
result.p... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/cronbee/cron/cronparser.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/cronparser.go#L285-L321 | go | train | // Look for obvious nonsense in the config. | func (c *crontime) checkValues() | // Look for obvious nonsense in the config.
func (c *crontime) checkValues() | {
for _, sec := range c.second {
if sec >= 60 || sec < 0 {
log.Panicln("Cronbee: Your config seems messed up. Check the range of \"Second\".")
}
}
for _, min := range c.second {
if min >= 60 || min < 0 {
log.Panicln("Cronbee: Your config seems messed up. Check the range of \"Minute\".")
}
}
for _,... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/cronbee/cron/cronparser.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/cronparser.go#L331-L342 | go | train | // 'Absolute' value (or distance) with an variable base.
// Example: absoluteOverBreakpoint(59, 1, 60) returns 2 | func absoluteOverBreakpoint(a, b, base int) int | // 'Absolute' value (or distance) with an variable base.
// Example: absoluteOverBreakpoint(59, 1, 60) returns 2
func absoluteOverBreakpoint(a, b, base int) int | {
if a >= base || b >= base {
panic("Invalid Values")
}
if a < b {
return b - a
} else if a == b {
return 0
} else {
return (base - a) + b
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/cronbee/cron/cronparser.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/cronparser.go#L346-L358 | go | train | // Returns an array filled with all values between a and b considering
// the base. | func valueRange(a, b, base int) []int | // Returns an array filled with all values between a and b considering
// the base.
func valueRange(a, b, base int) []int | {
value := make([]int, absoluteOverBreakpoint(a, b, base)+1)
i := 0
for ; a != b; a++ {
if a == base {
a = 0
}
value[i] = a
i++
}
value[i] = a
return value
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/hellobee/hellobee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/hellobee/hellobee.go#L49-L51 | go | train | // Action triggers the action passed to it. | func (mod *HelloBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *HelloBee) Action(action bees.Action) []bees.Placeholder | {
return []bees.Placeholder{}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/transmissionbee/transmissionbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/transmissionbee/transmissionbeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *TransmissionBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *TransmissionBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := TransmissionBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/transmissionbee/transmissionbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/transmissionbee/transmissionbeefactory.go#L68-L90 | go | train | // Options returns the options available to configure this Bee. | func (factory *TransmissionBeeFactory) Options() []bees.BeeOptionDescriptor | // Options returns the options available to configure this Bee.
func (factory *TransmissionBeeFactory) Options() []bees.BeeOptionDescriptor | {
opts := []bees.BeeOptionDescriptor{
{
Name: "url",
Description: "Server URL",
Type: "url",
Mandatory: true,
Default: "http://localhost:9091/transmission/rpc",
},
{
Name: "username",
Description: "Username",
Type: "string",
Mandatory: true,
},
... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/anelpowerctrlbee/anelpowerctrlbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/anelpowerctrlbee/anelpowerctrlbee.go#L70-L87 | go | train | // Action triggers the action passed to it. | func (mod *AnelPowerCtrlBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *AnelPowerCtrlBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "switch":
socket := 0
state := false
action.Options.Bind("socket", &socket)
action.Options.Bind("state", &state)
mod.anelSwitch(socket, state)
default:
panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
}
return outs
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/anelpowerctrlbee/anelpowerctrlbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/anelpowerctrlbee/anelpowerctrlbee.go#L90-L96 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *AnelPowerCtrlBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *AnelPowerCtrlBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("address", &mod.addr)
options.Bind("user", &mod.user)
options.Bind("password", &mod.password)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/webbee/webbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/webbee/webbee.go#L46-L69 | go | train | // Run executes the Bee's event loop. | func (mod *WebBee) Run(cin chan bees.Event) | // Run executes the Bee's event loop.
func (mod *WebBee) Run(cin chan bees.Event) | {
mod.eventChan = cin
srv := &http.Server{Addr: mod.addr, Handler: mod}
l, err := net.Listen("tcp", mod.addr)
if err != nil {
mod.LogErrorf("Can't listen on %s", mod.addr)
return
}
defer l.Close()
go func() {
err := srv.Serve(l)
if err != nil {
mod.LogErrorf("Server error: %v", err)
}
// Go 1.8... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/webbee/webbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/webbee/webbee.go#L123-L127 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *WebBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *WebBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("address", &mod.addr)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/chains/chains_post.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/chains/chains_post.go#L58-L84 | go | train | // Post processes an incoming POST (create) request | func (r *ChainResource) Post(context smolder.APIContext, data interface{}, request *restful.Request, response *restful.Response) | // Post processes an incoming POST (create) request
func (r *ChainResource) Post(context smolder.APIContext, data interface{}, request *restful.Request, response *restful.Response) | {
resp := ChainResponse{}
resp.Init(context)
pps := data.(*ChainPostStruct)
dupe := bees.GetChain(pps.Chain.Name)
if dupe != nil {
smolder.ErrorResponseHandler(request, response, nil, smolder.NewErrorResponse(
422, // Go 1.7+: http.StatusUnprocessableEntity,
errors.New("A Chain with that name exists alre... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/httpbee/httpbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/httpbee/httpbeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *HTTPBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *HTTPBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := HTTPBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/rssbee/rssbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/rssbee/rssbee.go#L157-L162 | go | train | // Run executes the Bee's event loop. | func (mod *RSSBee) Run(cin chan bees.Event) | // Run executes the Bee's event loop.
func (mod *RSSBee) Run(cin chan bees.Event) | {
mod.eventChan = cin
time.Sleep(10 * time.Second)
mod.pollFeed(mod.url, 5)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/rssbee/rssbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/rssbee/rssbee.go#L165-L170 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *RSSBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *RSSBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("skip_first", &mod.skipNextFetch)
options.Bind("url", &mod.url)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/webbee/webbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/webbee/webbeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *WebBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *WebBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := WebBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/webbee/webbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/webbee/webbeefactory.go#L68-L78 | go | train | // Options returns the options available to configure this Bee. | func (factory *WebBeeFactory) Options() []bees.BeeOptionDescriptor | // Options returns the options available to configure this Bee.
func (factory *WebBeeFactory) Options() []bees.BeeOptionDescriptor | {
opts := []bees.BeeOptionDescriptor{
{
Name: "address",
Description: "Which addr to listen on, eg: 0.0.0.0:12345",
Type: "address",
Mandatory: true,
},
}
return opts
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/bees/bees_put.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees_put.go#L45-L68 | go | train | // Put processes an incoming PUT (update) request | func (r *BeeResource) Put(context smolder.APIContext, data interface{}, request *restful.Request, response *restful.Response) | // Put processes an incoming PUT (update) request
func (r *BeeResource) Put(context smolder.APIContext, data interface{}, request *restful.Request, response *restful.Response) | {
resp := BeeResponse{}
resp.Init(context)
pps := data.(*BeePostStruct)
id := request.PathParameter("bee-id")
bee := bees.GetBee(id)
if bee == nil {
r.NotFound(request, response)
return
}
(*bee).SetDescription(pps.Bee.Description)
(*bee).ReloadOptions(pps.Bee.Options)
if pps.Bee.Active {
bees.Restar... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/actions/actions_get.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/actions/actions_get.go#L54-L69 | go | train | // GetByIDs sends out all items matching a set of IDs | func (r *ActionResource) GetByIDs(ctx smolder.APIContext, request *restful.Request, response *restful.Response, ids []string) | // GetByIDs sends out all items matching a set of IDs
func (r *ActionResource) GetByIDs(ctx smolder.APIContext, request *restful.Request, response *restful.Response, ids []string) | {
resp := ActionResponse{}
resp.Init(ctx)
for _, id := range ids {
action := bees.GetAction(id)
if action == nil {
r.NotFound(request, response)
return
}
resp.AddAction(action)
}
resp.Send(response)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/actions/actions_get.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/actions/actions_get.go#L72-L88 | go | train | // Get sends out items matching the query parameters | func (r *ActionResource) Get(ctx smolder.APIContext, request *restful.Request, response *restful.Response, params map[string][]string) | // Get sends out items matching the query parameters
func (r *ActionResource) Get(ctx smolder.APIContext, request *restful.Request, response *restful.Response, params map[string][]string) | {
// ctxapi := ctx.(*context.APIContext)
actions := bees.GetActions()
if len(actions) == 0 {
r.NotFound(request, response)
return
}
resp := ActionResponse{}
resp.Init(ctx)
for _, action := range actions {
resp.AddAction(&action)
}
resp.Send(response)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/logs.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/logs.go#L52-L60 | go | train | // NewLogMessage returns a newly composed LogMessage | func NewLogMessage(bee string, message string, messageType uint) LogMessage | // NewLogMessage returns a newly composed LogMessage
func NewLogMessage(bee string, message string, messageType uint) LogMessage | {
return LogMessage{
ID: UUID(),
Bee: bee,
Message: message,
MessageType: messageType,
Timestamp: time.Now(),
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/logs.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/logs.go#L63-L68 | go | train | // Log adds a new LogMessage to the log | func Log(bee string, message string, messageType uint) | // Log adds a new LogMessage to the log
func Log(bee string, message string, messageType uint) | {
logMutex.Lock()
defer logMutex.Unlock()
logs[bee] = append(logs[bee], NewLogMessage(bee, message, messageType))
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/logs.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/logs.go#L71-L86 | go | train | // GetLogs returns all logs for a Bee. | func GetLogs(bee string) []LogMessage | // GetLogs returns all logs for a Bee.
func GetLogs(bee string) []LogMessage | {
r := []LogMessage{}
logMutex.RLock()
for b, ls := range logs {
if len(bee) == 0 || bee == b {
for _, l := range ls {
r = append(r, l)
}
}
}
logMutex.RUnlock()
sort.Sort(LogSorter(r))
return r
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/s3bee/s3bee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/s3bee/s3bee.go#L39-L66 | go | train | // Action triggers the action passed to it. | func (bee *S3Bee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (bee *S3Bee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "upload":
bucket := ""
action.Options.Bind("bucket", &bucket)
path := ""
action.Options.Bind("path", &path)
objectPath := ""
action.Options.Bind("object_path", &objectPath)
if objectPath == "" {
objectPath = filepath.Base(path)
}
_, ... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/ircbee/irctools/irctools.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/ircbee/irctools/irctools.go#L38-L80 | go | train | // Colored wraps val in color styling tags. | func Colored(val string, color string) string | // Colored wraps val in color styling tags.
func Colored(val string, color string) string | {
// 00 white 01 black 02 blue (navy) 03 green 04 red 05 brown (maroon)
// 06 purple 07 orange (olive) 08 yellow 09 light green (lime)
// 10 teal (a green/blue cyan) 11 light cyan (cyan) (aqua) 12 light blue (royal)
// 13 pink (light purple) (fuchsia) 14 grey 15 light grey (silver)
c := "01"
switch color {
case... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/cleverbotbee/cleverbotbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cleverbotbee/cleverbotbee.go#L44-L76 | go | train | // Action triggers the action passed to it. | func (mod *CleverbotBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *CleverbotBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "send_message":
var text string
action.Options.Bind("text", &text)
resp, err := mod.client.Ask(text)
if err != nil {
mod.LogErrorf("Failed to ask cleverbot: %v", err)
return nil
}
ev := bees.Event{
Bee: mod.Name(),
Name: "answer",
... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/cleverbotbee/cleverbotbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cleverbotbee/cleverbotbee.go#L79-L93 | go | train | // Run executes the Bee's event loop. | func (mod *CleverbotBee) Run(eventChan chan bees.Event) | // Run executes the Bee's event loop.
func (mod *CleverbotBee) Run(eventChan chan bees.Event) | {
mod.evchan = eventChan
client, err := cleverbot.New(mod.api_user, mod.api_key, mod.session_nick)
if err != nil {
mod.LogErrorf("Failed to start session: %v", err)
return
}
mod.client = client
select {
case <-mod.SigChan:
return
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/cleverbotbee/cleverbotbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cleverbotbee/cleverbotbee.go#L96-L102 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *CleverbotBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *CleverbotBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("api_user", &mod.api_user)
options.Bind("api_key", &mod.api_key)
options.Bind("session_nick", &mod.session_nick)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/notificationbee/notificationbee_osx.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/notificationbee/notificationbee_osx.go#L29-L33 | 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) | {
note := gosxnotifier.NewNotification("Beehive")
note.Title = text
note.Push()
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/nagiosbee/nagiosbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/nagiosbee/nagiosbeefactory.go#L35-L43 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *NagiosBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *NagiosBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := NagiosBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.services = make(map[string]map[string]service)
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/chains/chains_delete.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/chains/chains_delete.go#L45-L67 | go | train | // Delete processes an incoming DELETE request | func (r *ChainResource) Delete(context smolder.APIContext, request *restful.Request, response *restful.Response) | // Delete processes an incoming DELETE request
func (r *ChainResource) Delete(context smolder.APIContext, request *restful.Request, response *restful.Response) | {
resp := ChainResponse{}
resp.Init(context)
id := request.PathParameter("chain-id")
found := false
chains := []bees.Chain{}
for _, v := range bees.GetChains() {
if v.Name == id {
found = true
} else {
chains = append(chains, v)
}
}
if found {
bees.SetChains(chains)
resp.Send(response)
} el... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/transmissionbee/transmissionbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/transmissionbee/transmissionbee.go#L41-L54 | go | train | // Action triggers the action passed to it. | func (mod *TransmissionBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *TransmissionBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "add_torrent":
torrentMsg := ""
action.Options.Bind("torrent", &torrentMsg)
_, err := mod.client.Add(torrentMsg)
if err != nil {
mod.LogErrorf("Error adding torrent/magnet: %s", err)
}
}
return outs
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/transmissionbee/transmissionbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/transmissionbee/transmissionbee.go#L57-L70 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *TransmissionBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *TransmissionBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
conf := transmission.Config{}
options.Bind("url", &conf.Address)
options.Bind("username", &conf.User)
options.Bind("password", &conf.Password)
t, err := transmission.New(conf)
if err != nil {
pretty.Println(err)
}
mod.client = t
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/options.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/options.go#L46-L54 | go | train | // Value retrieves a value from a BeeOptions slice. | func (opts BeeOptions) Value(name string) interface{} | // Value retrieves a value from a BeeOptions slice.
func (opts BeeOptions) Value(name string) interface{} | {
for _, opt := range opts {
if opt.Name == name {
return opt.Value
}
}
return nil
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/options.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/options.go#L57-L64 | go | train | // Bind a value from a BeeOptions slice. | func (opts BeeOptions) Bind(name string, dst interface{}) error | // Bind a value from a BeeOptions slice.
func (opts BeeOptions) Bind(name string, dst interface{}) error | {
v := opts.Value(name)
if v == nil {
return errors.New("Option with name " + name + " not found")
}
return ConvertValue(v, dst)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/mumblebee/mumblebee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/mumblebee/mumblebee.go#L52-L89 | go | train | // Action triggers the action passed to it. | func (mod *MumbleBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *MumbleBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "send_to_user":
user, text := "", ""
action.Options.Bind("user", &user)
action.Options.Bind("text", &text)
mod.client.Users.Find(user).Send(text)
case "send_to_channel":
channel, text := "", ""
action.Options.Bind("channel", &channel)
ac... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/mumblebee/mumblebee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/mumblebee/mumblebee.go#L109-L317 | go | train | // Run executes the Bee's event loop. | func (mod *MumbleBee) Run(eventChan chan bees.Event) | // Run executes the Bee's event loop.
func (mod *MumbleBee) Run(eventChan chan bees.Event) | {
if len(mod.server) == 0 {
return
}
// channel signaling mumble connection status
mod.connectedState = make(chan bool)
host, port, err := net.SplitHostPort(mod.server)
if err != nil {
host = mod.server
port = strconv.Itoa(gumble.DefaultPort)
}
config := gumble.NewConfig()
config.Username = mod.user
... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/mumblebee/mumblebee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/mumblebee/mumblebee.go#L320-L328 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *MumbleBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *MumbleBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("address", &mod.server)
options.Bind("channel", &mod.channel)
options.Bind("user", &mod.user)
options.Bind("password", &mod.password)
options.Bind("insecure", &mod.insecure)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/pushoverbee/pushoverbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/pushoverbee/pushoverbeefactory.go#L34-L41 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *PushoverBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *PushoverBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := PushoverBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/hellobee/hellobeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/hellobee/hellobeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *HelloBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *HelloBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := HelloBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/httpbee/httpbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/httpbee/httpbee.go#L45-L52 | go | train | // Run executes the Bee's event loop. | func (mod *HTTPBee) Run(cin chan bees.Event) | // Run executes the Bee's event loop.
func (mod *HTTPBee) Run(cin chan bees.Event) | {
mod.eventChan = cin
select {
case <-mod.SigChan:
return
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/httpbee/httpbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/httpbee/httpbee.go#L55-L123 | go | train | // Action triggers the action passed to it. | func (mod *HTTPBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *HTTPBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
u := ""
action.Options.Bind("url", &u)
switch action.Name {
case "get":
resp, err := http.Get(u)
if err != nil {
mod.LogErrorf("Error: %s", err)
return outs
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
mod.LogErrorf("Error: %s... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/telegrambee/telegrambee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/telegrambee/telegrambee.go#L48-L71 | go | train | // Action triggers the action passed to it. | func (mod *TelegramBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *TelegramBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "send":
chatID := ""
text := ""
action.Options.Bind("chat_id", &chatID)
action.Options.Bind("text", &text)
cid, err := strconv.ParseInt(chatID, 10, 64)
if err != nil {
panic("Invalid telegram chat ID")
}
msg := telegram.NewMessage(cid, t... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/telegrambee/telegrambee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/telegrambee/telegrambee.go#L74-L124 | go | train | // Run executes the Bee's event loop. | func (mod *TelegramBee) Run(eventChan chan bees.Event) | // Run executes the Bee's event loop.
func (mod *TelegramBee) Run(eventChan chan bees.Event) | {
var err error
mod.bot, err = telegram.NewBotAPI(mod.apiKey)
if err != nil {
mod.LogErrorf("Authorization failed, make sure the Telegram API key is correct: %s", err)
return
}
mod.Logf("Authorized on account %s", mod.bot.Self.UserName)
u := telegram.NewUpdate(0)
u.Timeout = 60
updates, err := mod.bot.Ge... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/telegrambee/telegrambee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/telegrambee/telegrambee.go#L127-L132 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *TelegramBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *TelegramBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
apiKey := getAPIKey(&options)
mod.apiKey = apiKey
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/telegrambee/telegrambee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/telegrambee/telegrambee.go#L136-L154 | go | train | // Gets the Bot's API key from a file, the recipe config or the
// TELEGRAM_API_KEY environment variable. | func getAPIKey(options *bees.BeeOptions) string | // Gets the Bot's API key from a file, the recipe config or the
// TELEGRAM_API_KEY environment variable.
func getAPIKey(options *bees.BeeOptions) string | {
var apiKey string
options.Bind("api_key", &apiKey)
if strings.HasPrefix(apiKey, "file://") {
buf, err := ioutil.ReadFile(strings.TrimPrefix(apiKey, "file://"))
if err != nil {
panic("Error reading API key file " + apiKey)
}
apiKey = string(buf)
}
if strings.HasPrefix(apiKey, "env://") {
buf := st... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/s3bee/s3beefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/s3bee/s3beefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *S3BeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *S3BeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := S3Bee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/config.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/config.go#L35-L56 | go | train | // NewBeeConfig validates a configuration and sets up a new BeeConfig | func NewBeeConfig(name, class, description string, options BeeOptions) (BeeConfig, error) | // NewBeeConfig validates a configuration and sets up a new BeeConfig
func NewBeeConfig(name, class, description string, options BeeOptions) (BeeConfig, error) | {
if len(name) == 0 {
return BeeConfig{}, errors.New("A Bee's name can't be empty")
}
b := GetBee(name)
if b != nil {
return BeeConfig{}, errors.New("A Bee with that name already exists")
}
f := GetFactory(class)
if f == nil {
return BeeConfig{}, errors.New("Invalid class specified")
}
return BeeConf... |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/config.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/config.go#L59-L66 | go | train | // BeeConfigs returns configs for all Bees. | func BeeConfigs() []BeeConfig | // BeeConfigs returns configs for all Bees.
func BeeConfigs() []BeeConfig | {
bs := []BeeConfig{}
for _, b := range bees {
bs = append(bs, (*b).Config())
}
return bs
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.