50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
|
|
namespace Tianyi.DingtalkRobotKit
|
|
{
|
|
/// <summary>
|
|
/// 文本消息
|
|
/// </summary>
|
|
public class TextMessage : MessageBase
|
|
{
|
|
public TextMessage(TextOption option) :base()
|
|
{
|
|
this.text = option;
|
|
}
|
|
|
|
public TextMessage(string message) : base()
|
|
{
|
|
var option = new TextOption()
|
|
{
|
|
content = message
|
|
};
|
|
this.text = option;
|
|
}
|
|
|
|
public TextOption text { get; set; }
|
|
|
|
/// <summary>
|
|
/// 消息类型
|
|
/// </summary>
|
|
public override string msgtype { get => "text"; }
|
|
|
|
/// <summary>
|
|
/// 转换为json字符串
|
|
/// </summary>
|
|
public override string ToJson()
|
|
{
|
|
var meaasge = new
|
|
{
|
|
msgtype = this.msgtype,
|
|
text = this.text,
|
|
at = this.at
|
|
};
|
|
|
|
string messageJson = JsonConvert.SerializeObject(meaasge);
|
|
|
|
return messageJson;
|
|
}
|
|
}
|
|
}
|