Account

Posts of Flex Coder

newest first

#1669Photo
Views46−73%vs avg
Forwards—
Reactions3
Comments—
#1662Photo
Views308+82%vs avg
Forwards—
Reactions4
Comments—
#1658Text

🧑‍💻 Command: /flexreply Code: export const commandName = "__message__"; const esc = (s) =>   String(s ?? "")     .replace(/&/g, "&amp;")     .replace(/</g, "&lt;")     .replace(/>/g, "&gt;"); export default async function flexReply(flex) {   const adminId = Number(process.env.ADMIN_ID);   const msg = flex.request.body.message;   if (!msg || flex.isCallback || flex.isInlineQuery) return;   if (flex.chat.chat_type !== "private") return;   if (flex.user.id !== adminId) {     try {       const fwd = await API.forwardMessage({         chat_id: adminId,         from_chat_id: flex.chat.id,         message_id: flex.message_id,       });       const canReplyDirectly =         fwd?.forward_origin?.sender_user?.id ?? fwd?.forward_from?.id;       if (!canReplyDirectly) {         const name =           fwd?.forward_origin?.sender_user_name ?? fwd?.forward_sender_name;         await API.sendMessage({           chat_id: adminId,           parse_mode: "HTML",           reply_parameters: { message_id: fwd.message_id },           text: `<b>👤 ${esc(name)}</b>\n🆔 ID: <code>${flex.user.id}</code>\n\n<i>Reply to this message to answer the user</i>`,         });       }     } catch (err) {       console.log(`[relay] forward failed: ${err.message}`);     }     return;   }   const replied = msg.reply_to_message;   if (!replied) return;   let targetId =     replied.forward_origin?.sender_user?.id ?? replied.forward_from?.id;   if (!targetId && replied.from?.is_bot) {     const match = (replied.text ?? "").match(/ID:\s*(\d+)/);     if (match) targetId = Number(match[1]);   }   if (!targetId) {     const hidden =       replied.forward_origin?.type === "hidden_user" ||       replied.forward_sender_name;     if (hidden) {       return sendMessage(         "<b>⚠️ This user hides forwarding. Reply to the <b>ID message</b> which is below the forwarded message.</b>",       );     }     return;   }   try {     await API.copyMessage({       chat_id: targetId,       from_chat_id: flex.chat.id,       message_id: flex.message_id,     });   } catch (err) {     console.log(`[relay] copy failed: ${err.message}`);     await sendMessage("<b>❌ Could not deliver the reply to the user.</b>");   } }

Open in Telegram
Views221+31%vs avg
Forwards—
Reactions3
Comments—
#1657Text
Views144−15%vs avg
Forwards—
Reactions3
Comments—
#1656Photo
Views153−10%vs avg
Forwards—
Reactions3
Comments—
#1654Photo
Views257+52%vs avg
Forwards—
Reactions3
Comments—
#1653Photo
Views235+39%vs avg
Forwards—
Reactions3
Comments—
#1651Text
Views226+34%vs avg
Forwards—
Reactions3
Comments—
#1650Photo
Views222+31%vs avg
Forwards—
Reactions2
Comments—
#1648Photo
Views222+31%vs avg
Forwards—
Reactions2
Comments—