(msg: Api.Message)
| 67 | }; |
| 68 | |
| 69 | const getRepliedMessageText = async (msg: Api.Message): Promise<string> => { |
| 70 | try { |
| 71 | const getter = (msg as any).getReplyMessage; |
| 72 | if (typeof getter === "function") { |
| 73 | const replied = await getter.call(msg); |
| 74 | return getMessageText(replied).trim(); |
| 75 | } |
| 76 | } catch {} |
| 77 | |
| 78 | try { |
| 79 | const replyToMsgId = |
| 80 | (msg as any)?.replyTo?.replyToMsgId ?? |
| 81 | (msg as any)?.replyToMsgId ?? |
| 82 | (msg as any)?.replyTo?.replyToMsg?.id; |
| 83 | if (!replyToMsgId) return ""; |
| 84 | const peer = (msg.chatId || msg.peerId) as any; |
| 85 | const res = await safeGetMessages(msg.client as any, peer, { ids: [replyToMsgId] }); |
| 86 | const replied = Array.isArray(res) ? res[0] : res; |
| 87 | return getMessageText(replied).trim(); |
| 88 | } catch {} |
| 89 | |
| 90 | return ""; |
| 91 | }; |
| 92 | |
| 93 | const getRepliedMessageId = async (msg: Api.Message): Promise<number | undefined> => { |
| 94 | try { |
no test coverage detected