ค้นหาเว็บไซต์

typescript - วิธีเพิ่ม disable_web_page_preview ในบอท Telegram ด้วย Node.js


สวัสดีตอนเย็นเพื่อน ๆ ก่อนอื่นต้องขอโทษสำหรับภาษาอังกฤษของฉัน

ฉันกำลังเขียนโค้ดใน Node.js และฉันต้องการเพิ่ม disable_web_page_preview ในโค้ด แต่ฉันไม่สามารถทำได้และฉันไม่รู้ว่าจะเพิ่มมันตรงไหน

Telegram.prototype.sendIn=async function(color, clientId, protection=false, gale=false){ if(!color || !clientId) return { status: "error", message: "สีและรหัสลูกค้าของแชทเป็นอาร์กิวเมนต์ที่จำเป็น" }

let message = [];

if(gale)
    message.push(`⚠️ <b>Aviso de Gale ${gale}:</b>\n`);
else
    message.push(`🤖<b>Sinal Confirmado</b>🤖\n`);
    
    message.push(`⏩ Entre no: ${this._getColorNameOrEmoticon(color, true)} ${this._getColorNameOrEmoticon(color, false, true)}`);
    if(typeof protection === "number")
        message.push(`Proteção no ${this._getColorNameOrEmoticon(protection, true)} ${this._getColorNameOrEmoticon(protection, false, true)}\n`);
        message.push(`⏩ Com proteção no: ⚪`);
        message.push(`<a href="https://blaze.com/pt/games/double" title="https://blaze.com/pt/games/double" target="_blank" rel="noopener noreferrer" class="text-entity-link" dir="auto">⏩ Aposte aqui</a>`);
        
    return await this.send(message.join('\n'), clientId, { parse_mode: "HTML"} );

}

คำตอบ #1

คุณกำลังดูตัวเลือกสำหรับเมทอด sendMessage() คุณสามารถอ่านตัวเลือกทั้งหมดที่มีอยู่ในเอกสาร Telegram Bot API ได้ ซึ่งสามารถทำได้โดยการเพิ่ม disable_web_page_preview: true

return await this.send(message.join('\n'), clientId, { parse_mode: "HTML", disable_web_page_preview: true } );

คำตอบ #2

เกิดข้อผิดพลาดนี้ขณะใช้ Grammy.js จากเอกสาร Bot API ผมเข้าใจว่า disable_web_page_preview: true ตอนนี้ต้องเปลี่ยนเป็น :

link_preview_options:{is_disabled:true}