Skip to content

Commit

Permalink
fix: try fix entity offset after multiple forwards
Browse files Browse the repository at this point in the history
  • Loading branch information
rikumi committed Oct 22, 2024
1 parent b4dbaa6 commit 58b1b60
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/clients/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { EventEmitter } from 'events';
export const prependMessageText = (message: Pick<GenericMessage, 'text' | 'entities'>, prefix: string) => {
const prefixLength = Buffer.from(prefix, 'utf16le').length / 2;
message.text = prefix + message.text;
if (!message.entities) return;
for (const entity of message.entities) {
entity.offset += prefixLength;
}
message.entities = message.entities?.map(entity => ({
...entity,
offset: entity.offset + prefixLength,
}));
};

export class DefaultClientSet extends EventEmitter {
Expand Down

0 comments on commit 58b1b60

Please sign in to comment.