@@ -27,6 +27,16 @@ public struct FileAttachment : IDisposable
2727 /// </summary>
2828 public bool IsThumbnail { get ; set ; }
2929
30+ /// <summary>
31+ /// Gets or sets the duration of a voice message. <see langword="null"/> if the attachment is not a voice message.
32+ /// </summary>
33+ public double ? DurationSeconds { get ; set ; }
34+
35+ /// <summary>
36+ /// Gets or sets bytearray representing a sampled waveform. <see langword="null"/> if the attachment is not a voice message.
37+ /// </summary>
38+ public byte [ ] Waveform { get ; set ; }
39+
3040#pragma warning disable IDISP008
3141 /// <summary>
3242 /// Gets the stream containing the file content.
@@ -44,7 +54,7 @@ public struct FileAttachment : IDisposable
4454 /// <param name="description">The description of the attachment.</param>
4555 /// <param name="isSpoiler">Whether or not the attachment is a spoiler.</param>
4656 /// <param name="isThumbnail">Whether or not this attachment should be a thumbnail for a media channel post.</param>
47- public FileAttachment ( Stream stream , string fileName , string description = null , bool isSpoiler = false , bool isThumbnail = false )
57+ public FileAttachment ( Stream stream , string fileName , string description = null , bool isSpoiler = false , bool isThumbnail = false , double ? durationSeconds = null , byte [ ] waveform = null )
4858 {
4959 _isDisposed = false ;
5060 FileName = fileName ;
@@ -57,6 +67,8 @@ public FileAttachment(Stream stream, string fileName, string description = null,
5767 }
5868 catch { }
5969 IsSpoiler = isSpoiler ;
70+ DurationSeconds = durationSeconds ;
71+ Waveform = waveform ;
6072 }
6173
6274 /// <summary>
@@ -91,14 +103,16 @@ public FileAttachment(Stream stream, string fileName, string description = null,
91103 /// <exception cref="FileNotFoundException">The file specified in <paramref name="path" /> was not found.
92104 /// </exception>
93105 /// <exception cref="IOException">An I/O error occurred while opening the file. </exception>
94- public FileAttachment ( string path , string fileName = null , string description = null , bool isSpoiler = false , bool isThumbnail = false )
106+ public FileAttachment ( string path , string fileName = null , string description = null , bool isSpoiler = false , bool isThumbnail = false , double ? durationSeconds = null , byte [ ] waveform = null )
95107 {
96108 _isDisposed = false ;
97109 Stream = File . OpenRead ( path ) ;
98110 FileName = fileName ?? Path . GetFileName ( path ) ;
99111 Description = description ;
100112 IsSpoiler = isSpoiler ;
101113 IsThumbnail = isThumbnail ;
114+ DurationSeconds = durationSeconds ;
115+ Waveform = waveform ;
102116 }
103117
104118 public void Dispose ( )
0 commit comments