Skip to content

Commit

Permalink
feat(message): remove username if replies are enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Nov 14, 2021
1 parent 5468ae5 commit 2d7d1a2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/helpers/tmi/message.ts
Expand Up @@ -20,6 +20,10 @@ export async function message(type: 'say' | 'whisper' | 'me', username: string |
tmiEmitter.emit('say', username, `/me ${messageToSend}`);
} else {
if (twitch.sendAsReply) {
if (messageToSend.startsWith(username) || messageToSend.startsWith('@' + username)) {
const regexp = new RegExp(`^@?${username}\\s?\\W?`);
messageToSend = messageToSend.replace(regexp, '').trim();
}
tmiEmitter.emit('say', username, `${messageToSend}`, { replyTo: messageId });
} else {
tmiEmitter.emit(type as any, username, `${messageToSend}`);
Expand Down

0 comments on commit 2d7d1a2

Please sign in to comment.