45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace wakka
|
|
{
|
|
public class FeelsPost
|
|
{
|
|
[JsonPropertyName("user")]
|
|
public string? User { get; set; }
|
|
[JsonPropertyName("path")]
|
|
public string? Path { get; set; }
|
|
[JsonPropertyName("m_time")]
|
|
public long M_Time { get; set; }
|
|
public string TimeString { get; set; } = string.Empty;
|
|
public string Body { get; set; } = string.Empty;
|
|
public int WordCount { get; set; } = 0;
|
|
}
|
|
|
|
internal class Feels
|
|
{
|
|
private static SshConnection Ssh { get; set; } = new SshConnection();
|
|
|
|
public List<FeelsPost>? AllFeels()
|
|
{
|
|
return JsonSerializer.Deserialize<List<FeelsPost>>(Ssh.RunCommand("~nebula/bin/dumpfeels"));
|
|
}
|
|
|
|
public List<FeelsPost>? FeelsAfter(long TimeStamp)
|
|
{
|
|
return JsonSerializer.Deserialize<List<FeelsPost>>(Ssh.RunCommand($"~nebula/bin/dumpfeels --after {TimeStamp}"));
|
|
}
|
|
|
|
public List<FeelsPost>? FeelsFromUser(string User, List<FeelsPost> Feels)
|
|
{
|
|
return Feels.FindAll(i => i.User == User);
|
|
}
|
|
|
|
public string GetFeelsBody(FeelsPost Post)
|
|
{
|
|
return Ssh.RunCommand($"cat {Post.Path}");
|
|
}
|
|
}
|
|
}
|