Changed the message format

This commit is contained in:
ION606
2023-03-11 09:53:18 -05:00
parent 848cd840b6
commit 60912c9a0b
3 changed files with 38 additions and 16 deletions
+1
View File
@@ -159,6 +159,7 @@ namespace Discord_Client_Custom.Channels
Label txt = new Label(); Label txt = new Label();
txt.Text = msg.getContent(); txt.Text = msg.getContent();
txt.Tag = msg.getId(); txt.Tag = msg.getId();
txt.Padding = new Padding(0, 0, 0, 10);
txt.MaximumSize = new Size(dmFlowContent.Width - 70, 100000000); txt.MaximumSize = new Size(dmFlowContent.Width - 70, 100000000);
txt.AutoSize = true; txt.AutoSize = true;
+35 -15
View File
@@ -89,7 +89,7 @@ namespace Discord_Client_Custom.Channels
//There's gonna be a faster way //There's gonna be a faster way
var arr = contents.AsArray().ToArray().Reverse().ToArray(); var arr = contents.AsArray().ToArray().Reverse().ToArray();
string id_current = (string)arr.Last()["id"]; string id_current = (string)arr[0]["author"]["id"];
int startInd = 0; int startInd = 0;
//Make sure the first column is consitant //Make sure the first column is consitant
@@ -98,43 +98,62 @@ namespace Discord_Client_Custom.Channels
dmFlowContent.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); dmFlowContent.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
//dmFlowContent.ColumnStyles[1].Width = 500; //dmFlowContent.ColumnStyles[1].Width = 500;
//Add all content into one "message"
string msgContent = ""; //(string)arr[0]["content"];
int i; int i;
int skipCounter = 0;
for (i = 0; i < arr.Length; i++) for (i = 0; i < arr.Length; i++)
{ {
if ((string)arr[i]["content"] == "") continue; if ((string)arr[i]["content"] == "")
{
skipCounter++;
continue;
}
//Remove when attatcmenent integration is added
if (msgContent.Length == 0 && skipCounter == i) id_current = (string)arr[i]["author"]["id"];
string authorName = (string)arr[i]["author"]["id"]; string authorName = (string)arr[i]["author"]["id"];
//Removed for spacing reasons
//if (authorName != id_current) if (authorName != id_current)
//{ {
Debug.WriteLine(arr[i]["content"]); var msgObjTemp = (JsonNode)arr[startInd];
if (authorName == uMainId) msgObjTemp["content"] = msgContent;
if (authorName != uMainId)
{ {
groupedMsgs.Add(new ChannelMsgGroup(arr[i], dmFlowContent, uMainIcon, i)); groupedMsgs.Add(new ChannelMsgGroup(msgObjTemp, dmFlowContent, uMainIcon, i));
} }
else else
{ {
groupedMsgs.Add(new ChannelMsgGroup(arr[i], dmFlowContent, uicon, i)); groupedMsgs.Add(new ChannelMsgGroup(msgObjTemp, dmFlowContent, uicon, i));
} }
startInd = i; startInd = i;
id_current = authorName; id_current = authorName;
//} msgContent = "";
}
msgContent += arr[i]["content"] + "\n";
} }
/*
if (i != startInd) if (i != startInd)
{ {
var msgObjTemp = (JsonNode)arr[startInd];
msgObjTemp["content"] = msgContent;
if ((string)arr[startInd]["author"]["id"] == uMainId) if ((string)arr[startInd]["author"]["id"] == uMainId)
{ {
groupedMsgs[groupedMsgs.Count - 1] = new ChannelMsgGroup(arr[startInd..i], dmFlowContent, uMainIcon, i); groupedMsgs[groupedMsgs.Count - 1] = new ChannelMsgGroup(msgObjTemp, dmFlowContent, uMainIcon, i);
} }
else else
{ {
groupedMsgs[groupedMsgs.Count - 1] = new ChannelMsgGroup(arr[startInd..i], dmFlowContent, uicon, i); groupedMsgs[groupedMsgs.Count - 1] = new ChannelMsgGroup(msgObjTemp, dmFlowContent, uicon, i);
} }
}*/ }
lastSent = id_current; lastSent = id_current;
@@ -158,7 +177,7 @@ namespace Discord_Client_Custom.Channels
} }
var response = await MsgRequests.sendMessage(txtbx.Text, ep); var response = await MsgRequests.sendMessage(txtbx.Text, ep);
JsonNode[] arr = new JsonNode[1]; //JsonNode[] arr = new JsonNode[1];
//arr[0] = response; //arr[0] = response;
//Add the message to chat in the app //Add the message to chat in the app
@@ -178,6 +197,7 @@ namespace Discord_Client_Custom.Channels
dmFlowContent.Controls.Add(txtbx, 0, i+1); dmFlowContent.Controls.Add(txtbx, 0, i+1);
dmFlowContent.SetColumnSpan(txtbx, 2); dmFlowContent.SetColumnSpan(txtbx, 2);
dmFlowContent.ScrollControlIntoView(txtbx);
} }
+2 -1
View File
@@ -9,8 +9,9 @@ namespace Discord_Client_Custom.Connections
{ {
internal class MsgRequests internal class MsgRequests
{ {
private static int msgFetchLimit = 50;
private static string dmMePath = "https://discord.com/api/users/@me/channels"; private static string dmMePath = "https://discord.com/api/users/@me/channels";
private static string dmGetMsgsBasepath = "https://discord.com/api/channels/{{id}}/messages?limit=10"; private static string dmGetMsgsBasepath = "https://discord.com/api/channels/{{id}}/messages?limit=" + msgFetchLimit.ToString();
public static string userToken = System.Environment.GetEnvironmentVariable("userToken"); public static string userToken = System.Environment.GetEnvironmentVariable("userToken");
public MsgRequests(string url, string reqType) public MsgRequests(string url, string reqType)