Add support for /me when sending

This commit is contained in:
Tommy Chow 2022-01-01 02:00:33 -05:00
parent 6324d5554b
commit 89133e30dc
2 changed files with 12 additions and 9 deletions

View file

@ -350,9 +350,11 @@ class IRCMessage {
);
// Add the colon separator between the username and their message to the span.
span.add(
const TextSpan(text: ':'),
);
if (!action) {
span.add(
const TextSpan(text: ':'),
);
}
// Italicize the text it was called with an IRC Action i.e., "/me".
final textStyle = action == true ? const TextStyle(fontStyle: FontStyle.italic) : null;

View file

@ -237,16 +237,17 @@ abstract class _ChatStoreBase with Store {
_channel.sink.add('PRIVMSG #$channelName :$message');
// Obtain the logged-in user's appearance in chat with USERSTATE and create the full message to render.
final userStateString = _userState.raw;
var userStateString = _userState.raw;
if (userStateString != null) {
// TODO: Add support for /me when sending messages.
// if (message.substring(0, 3) == '/me') {
// message = '\x01' + 'ACTION' + message + '\x01';
// }
if (message.length > 3 && message.substring(0, 3) == '/me') {
userStateString += ' :\x01ACTION ${message.replaceRange(0, 3, '').trim()}\x01';
} else {
userStateString += ' :' + message.trim();
}
final userChatMessage = IRCMessage.fromString(userStateString);
userChatMessage.localEmotes.addAll(assetsStore.userEmoteToObject);
userChatMessage.message = message.trim();
toSend = userChatMessage;
}