Merge pull request #82 from RedWizardsLab/dev_os_notifications

Dev os notifications
This commit is contained in:
Stone_Red
2026-08-01 17:46:25 +02:00
committed by GitHub
6 changed files with 43 additions and 1 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ Release history for EchoHub.
## Releases
- [v0.2.18](v0.2.18.md) - IRCv3 Capabilities
- [v0.2.18](v0.2.18.md) - IRCv3 Capabilities & Native OS Notifications
- [v0.2.17](v0.2.17.md) - Server Version Reporting & IRC Multi-Line Fix
- [v0.2.16](v0.2.16.md) - Periodic Server-Stats Report, Upload & Moderation Logging & Quieter Connection Logs
- [v0.2.15](v0.2.15.md) - Invite Codes, Data Export & Deletion, /me, /banner, Replies, Open Images In Browser & IRC Image Links
+1
View File
@@ -3,3 +3,4 @@
## New Features
- **IRCv3 capabilities** — `server-time`, `message-tags`, `echo-message`, `batch` and `draft/multiline` are now advertised and fully supported in the IRC gateway. CAP LS 302 requests receive capability values. Clients can enable caps via CAP REQ and disable them with CAP REQ -cap.
- **Native OS notifications** — EchoHub now supports native notifications on Windows, macOS and Linux. Notifications are sent for mentions or replies.
+1
View File
@@ -23,3 +23,4 @@
- [x] Send to EchohubSpace only state changes, currently we send user count periodically, instead of updating it on update
- [x] space between mod|admin "icon" and username
- [ ] Embeds still incorrectly display colors
- [ ] Find a better solution for Native OS notifications, currently uses the [OsNotifications](https://github.com/DemonExposer/OsNotifications) library, maintained by a single person.
+5
View File
@@ -27,6 +27,7 @@ public sealed class AppOrchestrator : IDisposable
private readonly ChatMessageManager _messageManager;
private readonly CommandHandler _commandHandler;
private readonly NotificationSoundService _notificationSound;
private readonly OsNotificationService _osNotification;
private readonly AudioPlaybackService _audioPlayback = new();
private readonly UpdateChecker _updateService;
private readonly ConnectionManager _conn = new();
@@ -65,6 +66,7 @@ public sealed class AppOrchestrator : IDisposable
_mainWindow = new MainWindow(app, _messageManager);
_commandHandler = new CommandHandler();
_notificationSound = new NotificationSoundService(config.Notifications);
_osNotification = new OsNotificationService();
_updateService = new UpdateChecker(app);
WireMainWindowEvents();
@@ -1105,6 +1107,9 @@ public sealed class AppOrchestrator : IDisposable
&& message.Content.Contains($"@{_session.Username}", StringComparison.OrdinalIgnoreCase))
{
_ = _notificationSound.PlayAsync();
string title = $"Mentioned by {message.SenderDisplayName ?? message.SenderUsername} in #{message.ChannelName}";
string body = message.Content.Length > 200 ? message.Content[..200] + "..." : message.Content;
_osNotification.Show(title, body);
}
};
+1
View File
@@ -9,6 +9,7 @@
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.3" />
<PackageReference Include="NetCoreAudio" Version="2.0.1" />
<PackageReference Include="OsNotifications" Version="1.1.5" />
<PackageReference Include="Serilog" Version="4.3.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
@@ -0,0 +1,34 @@
using OsNotifications;
using Serilog;
namespace EchoHub.Client.Services;
public sealed class OsNotificationService
{
static OsNotificationService()
{
Notifications.SetGuiApplication(true);
}
/// <summary>
/// Shows an OS notification with the given title and optional body.
/// </summary>
/// <param name="title"></param>
/// <param name="body"></param>
public void Show(string title, string? body = null)
{
try
{
Notifications.ShowNotification(title, body ?? string.Empty);
}
catch (PlatformNotSupportedException ex)
{
Log.Warning(ex, "OS notifications not supported on this platform");
}
catch (Exception ex)
{
Log.Warning(ex, "Failed to show OS notification");
}
}
}