forked from Nexus/nexus
add dynamic hinting and latching for PMPs
This commit is contained in:
parent
225497030e
commit
c786344bf2
1 changed files with 120 additions and 37 deletions
20
lib/models/room_subprofiles.dart
Normal file
20
lib/models/room_subprofiles.dart
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import "package:collection/collection.dart";
|
||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/per_message_profiles.dart";
|
||||
|
||||
part "room_subprofiles.freezed.dart";
|
||||
|
||||
@freezed
|
||||
class const RoomSubprofiles({
|
||||
required final IList<StoredProfile> profiles,
|
||||
// Each trigger is tried in this order, as gomuks does when sending
|
||||
required final IList<StoredProfile> triggerOrder,
|
||||
final StoredProfile? current,
|
||||
}) with _$RoomSubprofiles {
|
||||
StoredProfile? triggeredBy(String text) => triggerOrder.firstWhereOrNull(
|
||||
(profile) =>
|
||||
profile.id.isNotEmpty &&
|
||||
profile.triggers.any((trigger) => trigger.matches(text)),
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue