This tag enables bots to specify the particular channel context the
message is related to.
See: https://todo.sr.ht/~emersion/goguma/80
See: https://github.com/ircv3/ircv3-specifications/issues/497
---
lib/client_controller.dart | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/client_controller.dart b/lib/client_controller.dart
index 417f72b..0092af0 100644
--- a/lib/client_controller.dart
+++ b/lib/client_controller.dart
@@ -492,6 +492,12 @@ class ClientController {
// messages, "$xxx" for server-wide broadcasts
if (!client.isChannel(target) && !client.isMyNick(msg.source.name)) {
target = msg.source.name;
+ if(msg.cmd == 'NOTICE') {
+ var channel = msg.tags['+soju.im/channel'];
+ if(channel != null && client.isChannel(channel)) {
+ target = channel;
+ }
+ }
}
return _handleChatMessages(target, [msg]);
case 'INVITE':
@@ -669,38 +675,39 @@ class ClientController {
if (buffer.muted) {
return;
}
+ var isChannel = client.isChannel(buffer.name);
var needsNotification = entries.any((entry) {
if (buffer.lastDeliveredTime != null && buffer.lastDeliveredTime!.compareTo(entry.time) >= 0) {
return false;
}
- return _shouldNotifyMessage(entry);
+ return _shouldNotifyMessage(isChannel, entry);
});
if (!needsNotification) {
return;
}
var unread = await _db.listUnreadMessages(buffer.id);
- var notifyEntries = unread.where(_shouldNotifyMessage).toList();
+ var notifyEntries = unread.where((entry) => _shouldNotifyMessage(isChannel, entry)).toList();
if (notifyEntries.isEmpty) {
return;
}
- if (client.isChannel(buffer.name)) {
+ if (isChannel) {
await _notifController.showHighlight(notifyEntries, buffer);
} else {
await _notifController.showDirectMessage(notifyEntries, buffer);
}
}
- bool _shouldNotifyMessage(MessageEntry entry) {
+ bool _shouldNotifyMessage(bool isChannel, MessageEntry entry) {
if (entry.msg.cmd != 'PRIVMSG' && entry.msg.cmd != 'NOTICE') {
return false;
}
if (client.isMyNick(entry.msg.source!.name)) {
return false;
}
- if (client.isChannel(entry.msg.params[0]) && !findTextHighlight(entry.msg.params[1], client.nick)) {
+ if (isChannel && !findTextHighlight(entry.msg.params[1], client.nick)) {
return false;
}
return true;
base-commit: 10a2a3232f0dbb959d17500cc75830f8b60b8257
--
2.17.1