标签: telegraf.js

Telegraf.js 在 sendPhoto 上添加带有标记的按钮

我有bot.telegram.sendPhoto()这个代码:

bot.telegram.sendPhoto(
  channel_id,
  {source: filepath},
  { 
    caption: description.join("\n"), 
    parse_mode: 'MarkdownV2'
  }
)
Run Code Online (Sandbox Code Playgroud)

(描述是一个带有一些文本的数组。

所以我想添加一些按钮,然后执行一个操作,但我该怎么办?我已经尝试过这样的方式:

const buttons = Markup.keyboard([
            ["Test", "Test2"]
        ]).oneTime().resize().extra()
Run Code Online (Sandbox Code Playgroud)

然后将其添加到 parse_mode 之后的 {...} 中:

{ 
  caption: description.join("\n"), 
  parse_mode: 'MarkdownV2',
  buttons
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用。我也在 {...} 之后尝试过

{ 
  caption: description.join("\n"), 
  parse_mode: 'MarkdownV2'
},
buttons
Run Code Online (Sandbox Code Playgroud)

但它仍然不起作用。那我该怎么办呢?谢谢

node.js telegraf telegraf.js telegram-api

2
推荐指数
1
解决办法
1万
查看次数

如何使用电报网络钩子?

我想在 Telegraf 中使用 webHook,但我不知道如何正确使用它。

这是我的简单代码。但它仍然使用轮询。

    const Telegraf = require('telegraf');
    const bot = new Telegraf('123:ABC');

    bot.telegram.setWebhook('https://myaddress.com');
    bot.startWebhook(`/`, null, 4000);



    bot.use(function(ctx, next){
        try{
            if(ctx.chat == undefined) return;
            console.log("Hello World");
        }catch (e){
            console.log("Error");
        }
    });


    bot.launch();
Run Code Online (Sandbox Code Playgroud)

node.js telegraf.js

0
推荐指数
1
解决办法
1081
查看次数

标签 统计

node.js ×2

telegraf.js ×2

telegraf ×1

telegram-api ×1