// SendAction send the one of "typing", "upload_photo", "record_video", "upload_video", "record_audio", "upload_audio", "upload_document", "find_location"
184378
func (c *Context) SendAction(s string) error {
	_, err := c.Bot().API.Send(tg.NewChatAction(c.Chat.ID, s))
	return err
}
544966
func (bot TgBot) SendDocumentWithForceReply(cid int, document string, rmi *int, rm ForceReply) ResultWithMessage {
	var rkm ReplyMarkupInt = rm
	return bot.SendDocument(cid, document, rmi, &rkm)
}
109691
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", &htmlText)

		m := mail.NewMessage()
		if len(from) > 0 {
			m.SetHeader("From", from)
		} else {
			m.SetHeader("From", mod.username)
		}
		m.SetHeader("To", to)
		m.SetHeader("Subject", subject)
		if plainText != "" {
			m.SetBody("text/plain", plainText)
		}
		if htmlText != "" {
			m.SetBody("text/html", htmlText)
		}

		host, portstr, err := net.SplitHostPort(mod.server)
		if err != nil {
			host = mod.server
			portstr = "587"
		}
		port, _ := strconv.Atoi(portstr)
		s, _ := mail.NewDialer(host, port, mod.username, mod.password).Dial()

		// Send the email.
		if err := mail.Send(s, m); err != nil {
			panic(err)
		}

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

	return outs
}
255982
func (t *Transaction) sendAction(a *Action) error {
	switch a.kind {
	case commandAction:
		return t.conn.Send(a.name, a.args...)
	case scriptAction:
		return a.script.Send(t.conn, a.args...)
	}
	return nil
}
798710
func (bot TgBot) SendChatAction(cid int, ca ChatAction) {
	bot.SendChatActionQuery(SendChatActionQuery{cid, ca.String()})
}
264184
func (s *ByteMatchSetUpdate) SetAction(v string) *ByteMatchSetUpdate {
	s.Action = &v
	return s
}
560170
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 action.Options {
			if opt.Name == "channel" {
				tos = append(tos, opt.Value.(string))
			}
		}

		for _, recv := range tos {
			if recv == "*" {
				// special: send to all joined channels
				for _, to := range mod.channels {
					sendFunc(to, text)
				}
			} else {
				// needs stripping hostname when sending to user!host
				if strings.Index(recv, "!") > 0 {
					recv = recv[0:strings.Index(recv, "!")]
				}

				sendFunc(recv, text)
			}
		}

	case "join":
		for _, opt := range action.Options {
			if opt.Name == "channel" {
				mod.join(opt.Value.(string))
			}
		}
	case "part":
		for _, opt := range action.Options {
			if opt.Name == "channel" {
				mod.part(opt.Value.(string))
			}
		}

	case "kick":
		var c, n, m string
		action.Options.Bind("channel", &c)
		action.Options.Bind("user", &n)
		action.Options.Bind("message", &m)
		mod.client.Kick(c, n, m)

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

	return outs
}
968260
func (mod *SimplepushBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "send":
		sm := simplepush.Message{
			SimplePushKey: mod.key,
			Encrypt:       mod.password != "",
			Password:      mod.password,
			Salt:          mod.salt,
		}
		action.Options.Bind("title", &sm.Title)
		action.Options.Bind("message", &sm.Message)
		action.Options.Bind("event", &sm.Event)

		simplepush.Send(sm)

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

	return outs
}
340842
func (s *RegexMatchSetUpdate) SetAction(v string) *RegexMatchSetUpdate {
	s.Action = &v
	return s
}
556289
func (s *ActivatedRule) SetAction(v *WafAction) *ActivatedRule {
	s.Action = v
	return s
}
282796
func (s *SqlInjectionMatchSetUpdate) SetAction(v string) *SqlInjectionMatchSetUpdate {
	s.Action = &v
	return s
}
360935
func (a *Action) ChainAction(f ActionInterface) ActionInterface {
	if a == f {
		return a
	}

	return a.UseThen(func(b interface{}, to ActionInterface) {
		to.Fullfill(b)
	}, f)
}
982800
func (s *TcpRoute) SetAction(v *TcpRouteAction) *TcpRoute {
	s.Action = v
	return s
}
513155
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(err)
		}

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

	return outs
}
417394
func (s *GreenFleetProvisioningOption) SetAction(v string) *GreenFleetProvisioningOption {
	s.Action = &v
	return s
}
555396
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.client.PasteAnonymous(content, title, "text", expire, exposure)
		if err != nil {
			mod.LogErrorf("Error occurred during posting to Pastebin: %v", err)
		} else {
			mod.Logln("Paste URL:", ret)
		}

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}
	return outs
}
411022
func (m *Machine) AddAction(name string, payload map[string]interface{}) (Action, error) {
	spec, ok := actions.PredefinedActionsSpec[name]
	if !ok {
		return nil, errors.Errorf("cannot add action %q to a machine; only predefined actions allowed", name)
	}

	// Reject bad payloads before attempting to insert defaults.
	err := spec.ValidateParams(payload)
	if err != nil {
		return nil, err
	}
	payloadWithDefaults, err := spec.InsertDefaults(payload)
	if err != nil {
		return nil, err
	}

	model, err := m.st.Model()
	if err != nil {
		return nil, errors.Trace(err)
	}

	return model.EnqueueAction(m.Tag(), name, payloadWithDefaults)
}