fix(entities): replace user mentions with input user mentions after parsing
This commit is contained in:
parent
dea02c9c39
commit
1657090e33
1 changed files with 22 additions and 22 deletions
|
@ -15,31 +15,31 @@ export async function _parseEntities(
|
||||||
return empty
|
return empty
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entities) {
|
if (!entities) {
|
||||||
// replace mentionName entities with input ones
|
if (mode === undefined) {
|
||||||
for (const ent of entities) {
|
mode = this._defaultParseMode
|
||||||
if (ent._ === 'messageEntityMentionName') {
|
|
||||||
try {
|
|
||||||
const inputPeer = normalizeToInputUser(
|
|
||||||
await this.resolvePeer(ent.userId)
|
|
||||||
)
|
|
||||||
|
|
||||||
// not a user
|
|
||||||
if (!inputPeer) continue
|
|
||||||
;(ent as any)._ = 'inputMessageEntityMentionName'
|
|
||||||
;(ent as any).userId = inputPeer
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// either explicitly disabled or no available parser
|
||||||
|
if (!mode) return [text, []]
|
||||||
|
|
||||||
return [text, entities]
|
;([text, entities] = await this._parseModes[mode].parse(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === undefined) {
|
// replace mentionName entities with input ones
|
||||||
mode = this._defaultParseMode
|
for (const ent of entities) {
|
||||||
}
|
if (ent._ === 'messageEntityMentionName') {
|
||||||
// either explicitly disabled or no available parser
|
try {
|
||||||
if (!mode) return [text, []]
|
const inputPeer = normalizeToInputUser(
|
||||||
|
await this.resolvePeer(ent.userId)
|
||||||
|
)
|
||||||
|
|
||||||
return this._parseModes[mode].parse(text)
|
// not a user
|
||||||
|
if (!inputPeer) continue
|
||||||
|
;(ent as any)._ = 'inputMessageEntityMentionName'
|
||||||
|
;(ent as any).userId = inputPeer
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [text, entities]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue