feat: begin adding filtering support
This commit is contained in:
parent
8e5099ea9b
commit
2c3fe180ef
|
@ -936,6 +936,7 @@ internal class Client : IDisposable {
|
|||
}
|
||||
|
||||
this.Plugin.Commands.ReregisterAll();
|
||||
this.Plugin.Ipc.BroadcastChannelNames();
|
||||
}
|
||||
|
||||
private void HandleMessage(MessageResponse resp) {
|
||||
|
@ -948,6 +949,9 @@ internal class Client : IDisposable {
|
|||
var message = SeString.Parse(SecretBox.Decrypt(info.SharedSecret, resp.Message));
|
||||
|
||||
var output = new SeStringBuilder();
|
||||
// add a tag payload for filtering
|
||||
output.Add(PayloadUtil.CreateTagPayload(resp.Channel));
|
||||
output.Add(RawPayload.LinkTerminator);
|
||||
|
||||
var colour = config.GetUiColour(resp.Channel);
|
||||
output.AddUiForeground(colour);
|
||||
|
|
|
@ -14,17 +14,21 @@ internal class Ipc : IDisposable {
|
|||
private Plugin Plugin { get; }
|
||||
private ICallGateProvider<OverrideInfo, object> OverrideChannelColour { get; }
|
||||
private ICallGateProvider<Dictionary<string, uint>, Dictionary<string, uint>> ChannelCommandColours { get; }
|
||||
private ICallGateProvider<Dictionary<Guid, string>, Dictionary<Guid, string>> ChannelNames { get; }
|
||||
|
||||
internal Ipc(Plugin plugin) {
|
||||
this.Plugin = plugin;
|
||||
|
||||
this.OverrideChannelColour = this.Plugin.Interface.GetIpcProvider<OverrideInfo, object>("ExtraChat.OverrideChannelColour");
|
||||
this.ChannelCommandColours = this.Plugin.Interface.GetIpcProvider<Dictionary<string, uint>, Dictionary<string, uint>>("ExtraChat.ChannelCommandColours");
|
||||
this.ChannelNames = this.Plugin.Interface.GetIpcProvider<Dictionary<Guid, string>, Dictionary<Guid, string>>("ExtraChat.ChannelNames");
|
||||
|
||||
this.ChannelCommandColours.RegisterFunc(_ => this.GetChannelColours());
|
||||
this.ChannelNames.RegisterFunc(_ => this.GetChannelNames());
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.ChannelNames.UnregisterFunc();
|
||||
this.ChannelCommandColours.UnregisterFunc();
|
||||
}
|
||||
|
||||
|
@ -41,10 +45,23 @@ internal class Ipc : IDisposable {
|
|||
return dict;
|
||||
}
|
||||
|
||||
private Dictionary<Guid, string> GetChannelNames() {
|
||||
return this.Plugin.Client.Channels
|
||||
.Values
|
||||
.ToDictionary(
|
||||
channel => channel.Id,
|
||||
channel => this.Plugin.ConfigInfo.Channels.TryGetValue(channel.Id, out var info) ? info.Name : "???"
|
||||
);
|
||||
}
|
||||
|
||||
internal void BroadcastChannelCommandColours() {
|
||||
this.ChannelCommandColours.SendMessage(this.GetChannelColours());
|
||||
}
|
||||
|
||||
internal void BroadcastChannelNames() {
|
||||
this.ChannelNames.SendMessage(this.GetChannelNames());
|
||||
}
|
||||
|
||||
internal void BroadcastOverride() {
|
||||
var over = this.Plugin.GameFunctions.OverrideChannel;
|
||||
if (over == Guid.Empty) {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
|
||||
namespace ExtraChat.Util;
|
||||
|
||||
internal static class PayloadUtil {
|
||||
internal static RawPayload CreateTagPayload(Guid id) {
|
||||
var bytes = new List<byte> {
|
||||
2, // start byte
|
||||
0x27, // interactable
|
||||
3 + 16, // chunk length (3 bytes plus data length)
|
||||
0x20, // embedded info type (custom)
|
||||
};
|
||||
|
||||
// now add data, we always know it's 16 bytes
|
||||
bytes.AddRange(id.ToByteArray());
|
||||
|
||||
// end byte
|
||||
bytes.Add(3);
|
||||
|
||||
return new RawPayload(bytes.ToArray());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue