@@ -64,8 +64,9 @@ private static MattermostAttachment CloneAttachment(MattermostAttachment inAtt)
6464 /// Post Message to Mattermost server. Messages will be automatically split if total text length > 4000
6565 /// </summary>
6666 /// <param name="inMessage">The messsage you wish to send</param>
67+ /// <param name="maxMessageLength">(Optional) Defaulted to 3800, but can be set to any value (Check with your Mattermost server admin!)</param>
6768 /// <returns></returns>
68- public async Task < HttpResponseMessage > PostAsync ( MattermostMessage inMessage )
69+ public async Task < HttpResponseMessage > PostAsync ( MattermostMessage inMessage , int maxMessageLength = 3800 )
6970 {
7071
7172 try
@@ -84,11 +85,11 @@ public async Task<HttpResponseMessage> PostAsync(MattermostMessage inMessage)
8485 //start with one cloned inMessage in the list
8586 outMessages . Add ( CloneMessage ( inMessage ) ) ;
8687
87- //add text from original. If we go over 3800, we'll split it to a new inMessage.
88+ //add text from original. If we go over 3800 (or whatever user chooses) , we'll split it to a new inMessage.
8889 foreach ( var line in lines )
8990 {
9091
91- if ( line . Length + outMessages [ msgCount ] . Text . Length > 3800 )
92+ if ( line . Length + outMessages [ msgCount ] . Text . Length > maxMessageLength )
9293 {
9394
9495 msgCount += 1 ;
@@ -122,7 +123,7 @@ public async Task<HttpResponseMessage> PostAsync(MattermostMessage inMessage)
122123 //Get the total length of all attachments on the current outgoing message
123124 var lenAllAttsText = outMessages [ msgCount ] . Attachments . Sum ( a => a . Text . Length ) ;
124125
125- if ( lenMessageText + lenAllAttsText + line . Length > 3800 )
126+ if ( lenMessageText + lenAllAttsText + line . Length > maxMessageLength )
126127 {
127128 msgCount += 1 ;
128129 attIndex = 0 ;
0 commit comments