func (n *Notify) Send(receiver MessageReceiver, message interface{}, options *MessageOptions) (MessageResult, error) {
	var result MessageResult
	if message == nil {
		return result, errors.New("message can not be nil")
	}

	msgBody := make(map[string]interface{})

	if len(receiver.ToUser) > 0 {
		msgBody["touser"] = receiver.ToUser
	}
	if len(receiver.ToParty) > 0 {
		msgBody["toparty"] = receiver.ToParty
	}
	if len(receiver.ToTag) > 0 {
		msgBody["totag"] = receiver.ToTag
	}
	if len(msgBody) == 0 {
		return result, errors.New("message receiver not set, set at least one")
	}

	msgBody["agentid"] = n.agentID
	if options != nil {
		if options.Safe {
			msgBody["safe"] = 1
		}
		if options.EnableIDTrans {
			msgBody["enable_id_trans"] = 1
		}
		if options.EnableDuplicateCheck {
			msgBody["enable_duplicate_check"] = 1
			if options.DuplicateCheckInterval != 0 {
				msgBody["duplicate_check_interval"] = options.DuplicateCheckInterval
			}
		}
	}

	switch v := message.(type) {
	case Text:
		msgBody["msgtype"] = "text"
		msgBody["text"] = v
	case Image:
		msgBody["msgtype"] = "image"
		msgBody["image"] = v
	case Voice:
		msgBody["msgtype"] = "voice"
		msgBody["voice"] = v
	case Video:
		msgBody["msgtype"] = "video"
		msgBody["video"] = v
	case File:
		msgBody["msgtype"] = "file"
		msgBody["file"] = v
	case TextCard:
		msgBody["msgtype"] = "textcard"
		msgBody["textcard"] = v
	case News:
		msgBody["msgtype"] = "news"
		msgBody["news"] = v
	case MpNews:
		msgBody["msgtype"] = "mpnews"
		msgBody["mpnews"] = v
	case Markdown:
		msgBody["msgtype"] = "markdown"
		msgBody["markdown"] = v
	case MiniProgram:
		msgBody["msgtype"] = "miniprogram_notice"
		msgBody["miniprogram_notice"] = v
	case TaskCard:
		msgBody["msgtype"] = "taskcard"
		msgBody["taskcard"] = v
	default:
		return result, fmt.Errorf("unrecognized message type: %T", v)
	}
	return n.sendInternal(msgBody)
}
// Send message with options to receiver, options can be nil
Send message with options to receiver, options can be nil
// Send message with options to receiver options can be nil
func (n *Notify) Send(receiver MessageReceiver, message interface{}, options *MessageOptions) (MessageResult, error) {
	var result MessageResult
	if message == nil {
		return result, errors.New("message can not be nil")
	}
	msgBody := make(map[string]interface{})
	if len(receiver.ToUser) > 0 {
		msgBody["touser"] = receiver.ToUser
	}
	if len(receiver.ToParty) > 0 {
		msgBody["toparty"] = receiver.ToParty
	}
	if len(receiver.ToTag) > 0 {
		msgBody["totag"] = receiver.ToTag
	}
	if len(msgBody) == 0 {
		return result, errors.New("message receiver not set, set at least one")
	}
	msgBody["agentid"] = n.agentID
	if options != nil {
		if options.Safe {
			msgBody["safe"] = 1
		}
		if options.EnableIDTrans {
			msgBody["enable_id_trans"] = 1
		}
		if options.EnableDuplicateCheck {
			msgBody["enable_duplicate_check"] = 1
			if options.DuplicateCheckInterval != 0 {
				msgBody["duplicate_check_interval"] = options.DuplicateCheckInterval
			}
		}
	}
	switch v := message.(type) {
	case Text:
		msgBody["msgtype"] = "text"
		msgBody["text"] = v
	case Image:
		msgBody["msgtype"] = "image"
		msgBody["image"] = v
	case Voice:
		msgBody["msgtype"] = "voice"
		msgBody["voice"] = v
	case Video:
		msgBody["msgtype"] = "video"
		msgBody["video"] = v
	case File:
		msgBody["msgtype"] = "file"
		msgBody["file"] = v
	case TextCard:
		msgBody["msgtype"] = "textcard"
		msgBody["textcard"] = v
	case News:
		msgBody["msgtype"] = "news"
		msgBody["news"] = v
	case MpNews:
		msgBody["msgtype"] = "mpnews"
		msgBody["mpnews"] = v
	case Markdown:
		msgBody["msgtype"] = "markdown"
		msgBody["markdown"] = v
	case MiniProgram:
		msgBody["msgtype"] = "miniprogram_notice"
		msgBody["miniprogram_notice"] = v
	case TaskCard:
		msgBody["msgtype"] = "taskcard"
		msgBody["taskcard"] = v
	default:
		return result, fmt.Errorf("unrecognized message type: %T", v)
	}
	return n.sendInternal(msgBody)
}
func ( n * Notify ) Send ( receiver MessageReceiver , message interface { } , options * MessageOptions ) ( MessageResult , error ) { var result MessageResult if message == nil { return result , errors . New ( " " ) } msgBody := make ( map [ string ] interface { } ) if len ( receiver . ToUser ) > 0 { msgBody [ " " ] = receiver . ToUser } if len ( receiver . ToParty ) > 0 { msgBody [ " " ] = receiver . ToParty } if len ( receiver . ToTag ) > 0 { msgBody [ " " ] = receiver . ToTag } if len ( msgBody ) == 0 { return result , errors . New ( " " ) } msgBody [ " " ] = n . agentID if options != nil { if options . Safe { msgBody [ " " ] = 1 } if options . EnableIDTrans { msgBody [ " " ] = 1 } if options . EnableDuplicateCheck { msgBody [ " " ] = 1 if options . DuplicateCheckInterval != 0 { msgBody [ " " ] = options . DuplicateCheckInterval } } } switch v := message . ( type ) { case Text : msgBody [ " " ] = " " msgBody [ " " ] = v case Image : msgBody [ " " ] = " " msgBody [ " " ] = v case Voice : msgBody [ " " ] = " " msgBody [ " " ] = v case Video : msgBody [ " " ] = " " msgBody [ " " ] = v case File : msgBody [ " " ] = " " msgBody [ " " ] = v case TextCard : msgBody [ " " ] = " " msgBody [ " " ] = v case News : msgBody [ " " ] = " " msgBody [ " " ] = v case MpNews : msgBody [ " " ] = " " msgBody [ " " ] = v case Markdown : msgBody [ " " ] = " " msgBody [ " " ] = v case MiniProgram : msgBody [ " " ] = " " msgBody [ " " ] = v case TaskCard : msgBody [ " " ] = " " msgBody [ " " ] = v default : return result , fmt . Errorf ( " " , v ) } return n . sendInternal ( msgBody ) }
Send message with options to receiver, options can be nil
Send message with options to receiver options can be nil