// Create a new voice message for one or more recipients.
174138
func Create(c *messagebird.Client, recipients []string, body string, params *Params) (*VoiceMessage, error) {
	requestData, err := requestDataForVoiceMessage(recipients, body, params)
	if err != nil {
		return nil, err
	}

	message := &VoiceMessage{}
	if err := c.Request(message, http.MethodPost, path, requestData); err != nil {
		return nil, err
	}

	return message, nil
}
1362610
func MakeSlackMessage(target string, msg string, attachments []SlackAttachment) Composer {
	s := &slackMessage{
		raw: Slack{
			Target: target,
			Msg:    msg,
		},
	}
	if len(attachments) != 0 {
		s.raw.Attachments = make([]*slack.Attachment, 0, len(attachments))

		for i := range attachments {
			at := attachments[i].convert()
			s.raw.Attachments = append(s.raw.Attachments, at)
		}
	}

	return s
}
307903
func NewMessage(data []byte) (*Message, error) {
	message := &Message{}
	message.startByte = data[0]
	if len(data) <= 1 {
		return message, nil
	}
	message.Length = data[1]
	message.MessageType = data[2]
	message.Function = ZWaveFunction(data[3])

	var err error
	switch message.Function {
	case ApplicationCommandHandler:
		message.NodeID = data[5]

		message.Data, err = NewApplicationCommandHandler(data[7 : 7+data[6]])
	case DiscoveryNodes:

		message.Data, err = NewDiscoverdNodes(data[7 : 7+data[6]])
	case GetNodeProtocolInfo:

		message.Data, err = NewGetNodeProtocolInfo(data[4:])
	default:
		err = fmt.Errorf("Dropping message function='%s' with data %x (not implemented)", message.Function, data[4:])
	}

	if err != nil {
		return nil, err
	}

	logrus.Debugf("Message: %+v Message data: %+v", message, message.Data)
	return message, err

	// 1 FrameHeader (type of message)
	// 1 Message length
	// 1 Request (00) or Response (01)
	// 1 Function
	//
	// 1 (Node ID)
	// 1 (Command - length)
	// - (Command)
	// - (Transmit options)
	// - (Callback id)
	// 1 Checksum

	// Type
	//Request = 0x00,
	//Response = 0x01,
	//GetVersion = 0x15,
	//MemoryGetId = 0x20,
	//ClockSet = 0x30

	// Transmit options
	//Ack = 0x01,
	//LowPower = 0x02,
	//AutoRoute = 0x04,
	//ForceRoute = 0x08

}
460588
func NewMessagesReceivedTotalStatsHandler(sub Subsystem, vec *prometheus.CounterVec) *MessagesReceivedTotalStatsHandler {
	return &MessagesReceivedTotalStatsHandler{
		baseStatsHandler: baseStatsHandler{
			subsystem: sub,
			collector: vec,
		},
		vec: vec,
	}
}
196383
func NewJIRACommentMessage(p level.Priority, issueID, body string) Composer {
	s := MakeJIRACommentMessage(issueID, body)
	_ = s.SetPriority(p)

	return s
}
1156453
def voice_message_create(self, recipients, body, params=None):
        """"""
        if params is None: params = {}
        if type(recipients) == list:
            recipients = ','.join(recipients)

        params.update({'recipients': recipients, 'body': body})
        return VoiceMessage().load(self.request('voicemessages', 'POST', params))
1030632
func (c *Channel) SendMessage(message *Message) {
	c.lastEventID = message.id

	for c, open := range c.clients {
		if open {
			c.send <- message
		}
	}
}
1200325
func newMessageView(g *libkb.GlobalContext, conversationID chat1.ConversationID, m chat1.MessageUnboxed) (mv messageView, err error) {
	state, err := m.State()
	if err != nil {
		return mv, fmt.Errorf("unexpected empty message")
	}
	switch state {
	case chat1.MessageUnboxedState_ERROR:
		return newMessageViewError(g, conversationID, m.Error())
	case chat1.MessageUnboxedState_OUTBOX:
		return newMessageViewOutbox(g, conversationID, m.Outbox())
	case chat1.MessageUnboxedState_VALID:
		return newMessageViewValid(g, conversationID, m.Valid())
	default:
		return mv, fmt.Errorf("unexpected message state: %v", state)
	}

}
1314345
func NewMessageCopy(m Message) Message {
	m2 := NewMessage()
	m2.Copy(m)
	return m2
}
482763
func (api *PublicWhisperAPI) NewMessageFilter(req Criteria) (string, error) {
	var (
		src     *ecdsa.PublicKey
		keySym  []byte
		keyAsym *ecdsa.PrivateKey
		topics  [][]byte

		symKeyGiven  = len(req.SymKeyID) > 0
		asymKeyGiven = len(req.PrivateKeyID) > 0

		err error
	)

	// user must specify either a symmetric or an asymmetric key
	if (symKeyGiven && asymKeyGiven) || (!symKeyGiven && !asymKeyGiven) {
		return "", ErrSymAsym
	}

	if len(req.Sig) > 0 {
		if src, err = crypto.UnmarshalPubkey(req.Sig); err != nil {
			return "", ErrInvalidSigningPubKey
		}
	}

	if symKeyGiven {
		if keySym, err = api.w.GetSymKey(req.SymKeyID); err != nil {
			return "", err
		}
		if !validateDataIntegrity(keySym, aesKeyLength) {
			return "", ErrInvalidSymmetricKey
		}
	}

	if asymKeyGiven {
		if keyAsym, err = api.w.GetPrivateKey(req.PrivateKeyID); err != nil {
			return "", err
		}
	}

	if len(req.Topics) > 0 {
		topics = make([][]byte, len(req.Topics))
		for i, topic := range req.Topics {
			topics[i] = make([]byte, TopicLength)
			copy(topics[i], topic[:])
		}
	}

	f := &Filter{
		Src:      src,
		KeySym:   keySym,
		KeyAsym:  keyAsym,
		PoW:      req.MinPow,
		AllowP2P: req.AllowP2P,
		Topics:   topics,
		Messages: make(map[common.Hash]*ReceivedMessage),
	}

	id, err := api.w.Subscribe(f)
	if err != nil {
		return "", err
	}

	api.mu.Lock()
	api.lastUsed[id] = time.Now()
	api.mu.Unlock()

	return id, nil
}
1335013
func (s *DirectMessageConfiguration) SetVoiceMessage(v *VoiceMessage) *DirectMessageConfiguration {
	s.VoiceMessage = v
	return s
}
225227
func NewMessage(command, family, flags int) (*Message, error) {
	nlm := C.nlmsg_alloc()
	if nlm == nil {
		return nil, errors.New("failed to create netlink message")
	}
	C.genlmsg_put(nlm, C.NL_AUTO_PID, C.NL_AUTO_SEQ, C.int(family), 0, C.int(flags), C.uint8_t(command), genlVersion)
	return &Message{nlm: nlm}, nil
}
963666
func updateMessage(message editingMessage) error {
	return createMessage(message, message.NumericSender(), message.NumericReference(), message.Text(), message.Language())
}
291598
func createMessage(message newMessage, sender, reference uint64, text, language string) error {
	message.ClearDefaults()
	message.SetSender(sender)
	message.SetReference(reference)
	message.SetText(html.EscapeString(text))
	return message.SetLanguage(language)
}
852123
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {

	// Ignore all messages created by the bot itself
	// This isn't required in this specific example but it's a good practice.
	if m.Author.ID == s.State.User.ID {
		return
	}

	// check if the message is "!airhorn"
	if strings.HasPrefix(m.Content, "!airhorn") {

		// Find the channel that the message came from.
		c, err := s.State.Channel(m.ChannelID)
		if err != nil {
			// Could not find channel.
			return
		}

		// Find the guild for that channel.
		g, err := s.State.Guild(c.GuildID)
		if err != nil {
			// Could not find guild.
			return
		}

		// Look for the message sender in that guild's current voice states.
		for _, vs := range g.VoiceStates {
			if vs.UserID == m.Author.ID {
				err = playSound(s, g.ID, vs.ChannelID)
				if err != nil {
					fmt.Println("Error playing sound:", err)
				}

				return
			}
		}
	}
}
170291
func (msg *Message) Clone() *Message {
	clone := *msg

	clone.data.payload = make([]byte, len(msg.data.payload))
	copy(clone.data.payload, msg.data.payload)

	return &clone
}
1138116
func NewMessageToChannel(username string, text string) MessageConfig {
	return MessageConfig{
		BaseChat: BaseChat{
			ChannelUsername: username,
		},
		Text: text,
	}
}