add total time fronting'
This commit is contained in:
parent
54e7ae097f
commit
52ae992fac
|
@ -27,7 +27,7 @@ namespace PluralRichPresence
|
|||
client.Initialize();
|
||||
}
|
||||
|
||||
public void SetFronter(string user, string pronouns, string profile)
|
||||
public void SetFronter(string user, string pronouns, string profile, ulong? timeStamp)
|
||||
{
|
||||
client.SetPresence(new RichPresence()
|
||||
{
|
||||
|
@ -36,8 +36,12 @@ namespace PluralRichPresence
|
|||
Assets = new Assets()
|
||||
{
|
||||
LargeImageKey = profile,
|
||||
LargeImageText = user + " - " +pronouns,
|
||||
LargeImageText = user + " - " + pronouns,
|
||||
SmallImageKey = "plural"
|
||||
},
|
||||
Timestamps = new Timestamps()
|
||||
{
|
||||
StartUnixMilliseconds = timeStamp
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,11 +25,11 @@ namespace PluralRichPresence
|
|||
if (frontingMembers.Length > 0)
|
||||
{
|
||||
Member fronter = frontingMembers.First();
|
||||
discordRpc.SetFronter(fronter.Name, fronter.Pronouns, (fronter.AvatarURL is null) ? "plural" : fronter.AvatarURL);
|
||||
discordRpc.SetFronter(fronter.Name, fronter.Pronouns, (fronter.AvatarURL is null) ? "plural" : fronter.AvatarURL, fronter.FrontStartTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
discordRpc.SetFronter("No one is fronting.", "This doesn't make much sense?", "plural");
|
||||
discordRpc.SetFronter("No one is fronting.", "This doesn't make much sense?", "plural", null);
|
||||
}
|
||||
}
|
||||
public static void Main(string[] args)
|
||||
|
|
|
@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<History>True|2023-11-05T06:18:40.8205304Z;True|2023-11-05T19:17:01.7660736+13:00;True|2023-11-05T19:11:32.6382930+13:00;True|2023-11-05T19:11:09.6820258+13:00;False|2023-11-05T19:10:42.2427675+13:00;True|2023-10-18T14:13:41.8203499+13:00;True|2023-10-18T14:05:36.8381808+13:00;True|2023-10-17T21:30:38.9682339+13:00;</History>
|
||||
<History>True|2023-11-19T04:13:26.6652642Z;True|2023-11-05T19:18:40.8205304+13:00;True|2023-11-05T19:17:01.7660736+13:00;True|2023-11-05T19:11:32.6382930+13:00;True|2023-11-05T19:11:09.6820258+13:00;False|2023-11-05T19:10:42.2427675+13:00;True|2023-10-18T14:13:41.8203499+13:00;True|2023-10-18T14:05:36.8381808+13:00;True|2023-10-17T21:30:38.9682339+13:00;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
20
PluralRichPresnce/SimplyPlural/Fronter.cs
Normal file
20
PluralRichPresnce/SimplyPlural/Fronter.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluralRichPresence.SimplyPlural
|
||||
{
|
||||
public class Fronter
|
||||
{
|
||||
public string Id;
|
||||
public ulong Timestamp;
|
||||
|
||||
public Fronter(string id, ulong timestamp)
|
||||
{
|
||||
this.Id = id;
|
||||
this.Timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,6 +15,19 @@ namespace PluralRichPresence.SimplyPlural
|
|||
public string Id;
|
||||
public string SystemId;
|
||||
|
||||
public bool IsFronting
|
||||
{
|
||||
get
|
||||
{
|
||||
return FrontStartTime is not null;
|
||||
}
|
||||
set
|
||||
{
|
||||
FrontStartTime = 0;
|
||||
}
|
||||
}
|
||||
public ulong? FrontStartTime = null;
|
||||
|
||||
public Member(string systemId,
|
||||
string name,
|
||||
string pronouns,
|
||||
|
|
|
@ -28,10 +28,10 @@ namespace PluralRichPresence.SimplyPlural
|
|||
return system.id;
|
||||
}
|
||||
|
||||
public async Task<string[]> GetCurrentFronters()
|
||||
public async Task<Fronter[]> GetCurrentFronters()
|
||||
{
|
||||
dynamic fronters = await get("/v1/fronters");
|
||||
List<string> userIdList = new List<string>();
|
||||
List<Fronter> fronterList = new List<Fronter>();
|
||||
|
||||
for (int i = 0; i < fronters.Count; i++)
|
||||
{
|
||||
|
@ -39,10 +39,12 @@ namespace PluralRichPresence.SimplyPlural
|
|||
if (!fronterExist) continue;
|
||||
|
||||
string fronterMemberId = fronters[i].content.member;
|
||||
userIdList.Add(fronterMemberId);
|
||||
ulong fronterStartTime = fronters[i].content.startTime;
|
||||
|
||||
fronterList.Add(new Fronter(fronterMemberId, fronterStartTime));
|
||||
}
|
||||
|
||||
return userIdList.ToArray();
|
||||
return fronterList.ToArray();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,14 +32,18 @@ namespace PluralRichPresence
|
|||
|
||||
public async Task<Member[]> GetCurrentFronterInfo()
|
||||
{
|
||||
string[] fronters = await rest.GetCurrentFronters();
|
||||
Fronter[] fronters = await rest.GetCurrentFronters();
|
||||
|
||||
List<Member> members = new List<Member>();
|
||||
|
||||
foreach (string fronter in fronters)
|
||||
foreach (Fronter fronter in fronters)
|
||||
{
|
||||
Member? frontingMember = LookupMember(fronter);
|
||||
if (frontingMember is not null) members.Add(frontingMember);
|
||||
Member? frontingMember = LookupMember(fronter.Id);
|
||||
if (frontingMember is not null)
|
||||
{
|
||||
frontingMember.FrontStartTime = fronter.Timestamp;
|
||||
members.Add(frontingMember);
|
||||
}
|
||||
}
|
||||
|
||||
return members.ToArray();
|
||||
|
|
Loading…
Reference in New Issue
Block a user