예제 #1
0
    /// <summary>
    /// 截取消息中的文字部分
    /// </summary>
    public string GetText()
    {
        var text = new StringBuilder();

        MessageBody.Where(s => s.MessageType == SegmentType.Text)
        .Select(s => s.Data as TextSegment)
        .ToList()
        .ForEach(t => text.Append(t?.Content ?? string.Empty));
        return(text.ToString());
    }
예제 #2
0
    /// <summary>
    /// 获取所有At的UID
    /// Notice:at全体不会被转换
    /// </summary>
    /// <returns>
    /// <para>At的uid列表</para>
    /// <para><see cref="List{T}"/>(T=<see cref="long"/>)</para>
    /// </returns>
    public IEnumerable <long> GetAllAtList()
    {
        List <long> uidList = MessageBody.Where(s => s.MessageType == SegmentType.At)
                              .Select(s => long.TryParse((s.Data as AtSegment)?.Target ?? "0",
                                                         out long uid)
                                             ? uid
                                             : -1)
                              .ToList();

        //去除无法转换的值,如at全体
        uidList.RemoveAll(uid => uid == -1);
        return(uidList);
    }
예제 #3
0
 /// <summary>
 /// 获取所有图片信息
 /// </summary>
 /// <returns>
 /// <para>图片信息结构体列表</para>
 /// <para><see cref="List{T}"/>(T=<see cref="ImageSegment"/>)</para>
 /// </returns>
 public IEnumerable <ImageSegment> GetAllImage()
 {
     return(MessageBody.Where(s => s.MessageType == SegmentType.Image)
            .Select(s => s.Data as ImageSegment)
            .ToList());
 }