Put reaction and GIF helpers in charge of encoding

This commit is contained in:
Adam Novak
2026-04-06 02:09:40 -04:00
parent 75ec3b6116
commit c5ec60638c
4 changed files with 20 additions and 10 deletions
+6 -1
View File
@@ -9,7 +9,7 @@ class GifHelper {
/// include a trailing slash.
///
/// Returns null if text is not a valid GIF format
static String? parseGifId(String text) {
static String? parseGif(String text) {
final trimmed = text.trim();
final match = RegExp(r'^g:([A-Za-z0-9_-]+)$').firstMatch(trimmed);
if (match != null) {
@@ -30,4 +30,9 @@ class GifHelper {
).firstMatch(trimmed);
return pageMatch?.group(1);
}
/// Encode a GIF in a format that parseGif() can parse.
static String encodeGif(String gifId) {
return 'g:$gifId';
}
}
+5
View File
@@ -109,4 +109,9 @@ class ReactionHelper {
return ReactionInfo(targetHash: match.group(1)!, emoji: emoji);
}
/// Encode a reaction message that parseReaction() can parse.
static String encodeReaction(String hash, String emojiIndex) {
return 'r:$hash:$emojiIndex';
}
}