MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / editTextMessageToPlaceholder

Function editTextMessageToPlaceholder

dme/dme.ts:193–224  ·  view source on GitHub ↗
(
  client: TelegramClient,
  message: Api.Message,
  chatEntity: any
)

Source from the content-addressed store, hash-verified

191 if (message.media) {
192 return false;
193 }
194
195 const nowSec = Math.floor(Date.now() / 1000);
196 if (typeof (message as any).date === "number" && nowSec - (message as any).date > 172800) {
197 return false;
198 }
199
200 const currentText = typeof message.message === "string" ? message.message : "";
201 if (currentText === TEXT_PLACEHOLDER) {
202 return true;
203 }
204
205 try {
206 await client.invoke(
207 new Api.messages.EditMessage({
208 peer: chatEntity,
209 id: message.id,
210 message: TEXT_PLACEHOLDER,
211 })
212 );
213 return true;
214 } catch {
215 return false;
216 }
217}
218
219function isSavedMessagesPeer(chatEntity: any, myId: bigint): boolean {
220 return (
221 (chatEntity?.className === "User" && chatEntity?.id?.toString?.() === myId.toString()) ||
222 chatEntity?.className === "PeerSelf" ||
223 chatEntity?.className === "InputPeerSelf" ||
224 ((chatEntity?.className === "PeerUser" || chatEntity?.className === "InputPeerUser") &&
225 chatEntity?.userId?.toString?.() === myId.toString())
226 );
227}

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected