// Action triggers the action passed to it.
190152
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.ExtractFromURL(url)
		article.Title = strings.TrimSpace(strings.Replace(article.TitleUnmodified, "\n", " ", -1))
		if strings.HasPrefix(article.TopImage, "http://data:image") {
			article.TopImage = ""
		}
		if len(article.Title) > 0 {
			ev := bees.Event{
				Bee:  mod.Name(),
				Name: "info_extracted",
				Options: []bees.Placeholder{
					{
						Name:  "title",
						Type:  "string",
						Value: article.Title,
					},
					{
						Name:  "domain",
						Type:  "string",
						Value: article.Domain,
					},
					{
						Name:  "top_image",
						Type:  "url",
						Value: article.TopImage,
					},
					{
						Name:  "final_url",
						Type:  "url",
						Value: article.FinalURL,
					},
					{
						Name:  "meta_description",
						Type:  "string",
						Value: article.MetaDescription,
					},
					{
						Name:  "meta_keywords",
						Type:  "string",
						Value: article.MetaKeywords,
					},
				},
			}
			mod.evchan <- ev
		}

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
1339553
func (k *KeyBindings) Action(qc func(key string, operator Op, operand interface{}, match_all bool) bool) (kb *KeyBinding) {
	p := Prof.Enter("key.action")
	defer p.Exit()

	for {
		for i := range k.Bindings {
			if len(k.Bindings[i].Keys) > k.seqIndex {
				// This key binding is of a key sequence longer than what is currently
				// probed for. For example, the binding is for the sequence ['a','b','c'], but
				// the user has only pressed ['a','b'] so far.
				continue
			}
			for _, c := range k.Bindings[i].Context {
				if !qc(c.Key, c.Operator, c.Operand, c.MatchAll) {
					goto skip
				}
			}
			if kb == nil || kb.priority < k.Bindings[i].priority {
				kb = k.Bindings[i]
			}
		skip:
		}
		if kb != nil || k.parent == nil {
			break
		}
		k = k.parent.KeyBindings()
	}
	return
}
246592
func (mod *JenkinsBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}
	switch action.Name {
	case "trigger":
		jobname := ""
		action.Options.Bind("job", &jobname)

		mod.triggerBuild(jobname)

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}
	return outs
}
1328357
func (w *Ware) Action(handler Handler) {
	validateHandler(handler)
	w.action = handler
}
477388
func Execute(a *Action) error {
	seen := make(map[*Action]error)
	return execute(seen, a)
}
727233
func (kf *KeyspaceFixer) Action(ctx context.Context, name string) error {
	if name == "Create" {
		return kf.ts.CreateKeyspace(ctx, kf.keyspace, &topodatapb.Keyspace{})
	}
	if name == "Delete" {
		return kf.ts.DeleteKeyspace(ctx, kf.keyspace)
	}
	return fmt.Errorf("unknown KeyspaceFixer action: %v", name)
}
724694
func (s *XssMatchSetUpdate) SetAction(v string) *XssMatchSetUpdate {
	s.Action = &v
	return s
}
821598
func Action(baseURL string, resourceType string, id string, action string) (*jsh.Document, *http.Response, error) {
	request, err := ActionRequest(baseURL, resourceType, id, action)
	if err != nil {
		return nil, nil, err
	}

	return Do(request, jsh.ObjectMode)
}
401424
func (kf *UITestFixer) Action(ctx context.Context, name string) error {
	if name == "Success" {
		return nil
	}
	if name == "Error" {
		return fmt.Errorf("oh no, you pressed the Error button")
	}
	return fmt.Errorf("unknown UITestFixer action: %v", name)
}
463023
func (runner *runner) RunAction(actionName string) error {
	if _, err := runner.context.ActionData(); err != nil {
		return errors.Trace(err)
	}
	if actionName == actions.JujuRunActionName {
		return runner.runJujuRunAction()
	}
	return runner.runCharmHookWithLocation(actionName, "actions")
}
2391
func Action(a func(*cli.Context)) Option {
	return func(o *Options) {
		o.Action = a
	}
}
261234
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
		action.Options.Bind("username", &user)

		if _, err := mod.client.Users.Unfollow(ctx, user); err != nil {
			mod.LogErrorf("Failed to follow user: %v", err)
		}

	case "star":
		var user string
		var repo string
		action.Options.Bind("owner", &user)
		action.Options.Bind("repository", &repo)

		if _, err := mod.client.Activity.Star(ctx, user, repo); err != nil {
			mod.LogErrorf("Failed to star repository: %v", err)
		}

	case "unstar":
		var user string
		var repo string
		action.Options.Bind("owner", &user)
		action.Options.Bind("repository", &repo)

		if _, err := mod.client.Activity.Unstar(ctx, user, repo); err != nil {
			mod.LogErrorf("Failed to unstar repository: %v", err)
		}

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
1127877
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, text)
		_, err = mod.bot.Send(msg)
		if err != nil {
			mod.Logf("Error sending message %v", err)
		}
	}

	return outs
}
668924
func (r *ResourceDefinition) CanonicalAction() *ActionDefinition {
	name := r.CanonicalActionName
	if name == "" {
		name = "show"
	}
	ca, _ := r.Actions[name]
	return ca
}
1038938
func (res *Resource) Action(actionName string, storage store.Get) {
	matcher := path.Join(patID, actionName)

	res.HandleFunc(
		pat.Get(matcher),
		func(w http.ResponseWriter, r *http.Request) {
			res.actionHandler(w, r, storage)
		},
	)

	res.addRoute(patch, matcher)
}
836376
func (m *Broadcaster) Action(action EventType, obj runtime.Object) {
	m.incoming <- Event{action, obj}
}
1342636
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)
			return outs
		}

		if _, err = mod.client.SendMessage(roomID, message); err != nil {
			mod.LogErrorf("Failed to send message: %v", err)
			return outs
		}

	case "join":
		var room string
		action.Options.Bind("room", &room)

		if err := mod.join(room); err != nil {
			mod.LogErrorf("Failed to join room: %v", err)
		}

	case "leave":
		var room string
		action.Options.Bind("room", &room)

		err := mod.leave(room)
		if err != nil {
			mod.LogErrorf("Can't leave room: %v", err)
		} else {
			mod.Logln("Left room:", room)
		}

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}