43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace wakka
|
|
{
|
|
public class BinkPost
|
|
{
|
|
[JsonPropertyName("user")]
|
|
public string? User { get; set; }
|
|
[JsonPropertyName("body")]
|
|
public string? Body { get; set; }
|
|
[JsonPropertyName("time")]
|
|
public long Time { get; set; }
|
|
public string TimeString { get; set; } = string.Empty;
|
|
}
|
|
|
|
public class Bink
|
|
{
|
|
private static SshConnection Ssh { get; set; } = new SshConnection();
|
|
|
|
public void PostBink(string message)
|
|
{
|
|
Ssh.RunCommandWithInput("town bink --pipe", message);
|
|
}
|
|
|
|
public List<BinkPost>? AllBinks()
|
|
{
|
|
return JsonSerializer.Deserialize<List<BinkPost>>(Ssh.RunCommand("town bink --dump"));
|
|
}
|
|
|
|
public List<BinkPost>? BinksBefore(long TimeStamp)
|
|
{
|
|
return JsonSerializer.Deserialize<List<BinkPost>>(Ssh.RunCommand($"town bink --dump-before {TimeStamp}"));
|
|
}
|
|
|
|
public List<BinkPost>? BinksAfter(long TimeStamp)
|
|
{
|
|
return JsonSerializer.Deserialize<List<BinkPost>>(Ssh.RunCommand($"town bink --dump-after {TimeStamp}"));
|
|
}
|
|
}
|
|
}
|