(
msg: Api.Message,
text: string,
parseMode: "html" | "markdown" = "html",
replyToId?: number,
linkPreview: boolean = false
)
| 139 | } |
| 140 | |
| 141 | static async sendNew( |
| 142 | msg: Api.Message, |
| 143 | text: string, |
| 144 | parseMode: "html" | "markdown" = "html", |
| 145 | replyToId?: number, |
| 146 | linkPreview: boolean = false |
| 147 | ): Promise<Api.Message | undefined> { |
| 148 | const topicRootId = getTopicRootId(msg); |
| 149 | const replyTo = |
| 150 | replyToId && topicRootId && replyToId !== topicRootId |
| 151 | ? new Api.InputReplyToMessage({ |
| 152 | replyToMsgId: replyToId, |
| 153 | topMsgId: topicRootId, |
| 154 | }) |
| 155 | : replyToId ?? topicRootId; |
| 156 | |
| 157 | return await (msg.client as any).sendMessage(msg.chatId || msg.peerId, { |
| 158 | message: text, |
| 159 | parseMode, |
| 160 | ...(replyTo ? { replyTo } : {}), |
| 161 | linkPreview, |
| 162 | }); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | const getTopicRootId = (msg: Api.Message): number | undefined => { |
no test coverage detected