Tag: 电报机器人

电报bot嵌套的前一个button,node.js

如何从第三级节点返回到第一级节点之后的第三级节点? 我的问题是Back名称,因为这是相同,,, 这是我的代码: bot.onText(/\/start/, function onLoveText(msg) { const opts = { reply_to_message_id: msg.message_id, reply_markup: JSON.stringify({ keyboard: StartKeyboard, resize_keyboard:true, one_time_keyboard: true }) }; bot.sendMessage(msg.chat.id, 'Hello', opts); }); bot.onText(/\Back/, function onLoveText(msg) { const opts = { reply_to_message_id: msg.message_id, reply_markup: JSON.stringify({ keyboard: StartKeyboard, resize_keyboard:true, one_time_keyboard: true }) }; bot.sendMessage(msg.chat.id, 'Hello', opts); }); bot.onText(/\Back/, function onLoveText(msg) { // I […]

Telegram Bot通过Node.js查找videofile_id

Hellow,我正在使用node-telegram-bot-api模块 如何find或控制台日志,其他机器人的videofile_id?

将可点击的button添加到电报机器人

我正在用node.js电报机器人开发一个简单的电报机器人。 https://github.com/yagop/node-telegram-bot-api现在,我想让用户停止input消息(用字母),只需按几个button之一。 当他点击button时,他的电报客户端必须发回给我的机器人另一个信息(有点像“点击是”或“点击否”)。 我发现它可以做成 var options = { reply_markup: JSON.stringify({ inline_keyboard: [ [{ text: 'Some button text 1', callback_data: '1' }], [{ text: 'Some button text 2', callback_data: '2' }], [{ text: 'Some button text 3', callback_data: '3' }] ] }) }; bot.sendMessage(msg.chat.id, "answer.", option); 所以用户重新发送3种消息,当他点击他们时,他不会再给我任何回应。 我需要另一种types的button(这将在客户端的应用程序的底部)。

Telegram bot api,通过@username发送消息

我的电报机器人可以与用户沟通,我想发送他们的聊天结果给pipe理员电报帐户。 我使用node telegram bot api作为我的机器人后端。 如何通过电报将消息发送到特定的@username ?

如何在电报中使用内联键盘创build分页

我正在创build一个Telegram机器人Node.js,我正在使用node-telegram-bot-api模块。 我目前的问题是: 使用内联键盘创build分页。 在这里的文档中,有一个我需要的有趣的例子。 对于外观,我必须使用方法editMessageText但更新内联键盘我需要传递参数inline_message_id 。 不幸的是,我不明白该怎么做。 我将非常感谢任何示例更新内联键盘,以及如何在这个例子中释放。

如何从电报频道接收数据到webhook?

我使用node.js / express设置了一个电报webhook到mybot : app.get('/hook', function (req, res) { url='https://api.telegram.org/bot17xxxxx/setwebhook?url=https://example.com/hook' request(url, function (error, response, body) { if (!error && response.statusCode == 200) { console.log(body) } response.emit('close'); }); }); 当我GET https://example.com/hook我可以收到我的机器人控制台: {"ok":true,"result":true,"description":"Webhook was set"} 现在我想从机器人接收数据,以便当用户访问https://telegram.me/mybot?start=xyz并按/start ,机器人应该接收xyz在一个post/hook (至less这是我的缺乏的程序) 以下是我必须收到post的路线: app.post("/hook", function(req, res) { console.log(body); }); 但是当用户在她的浏览器中访问https://telegram.me/mybot?start=xyz并按下/start时,我看不到bot中没有任何事情发生。 这里有什么可能是错的,以及如何解决它?

电报 – 节点。 Js处理多个更新

我正在用电报创build一个游戏,目前我有一个关于同时处理多个更新的问题。 我正在使用node.js 例如,我有这个代码 var TelegramBot = require('node-telegram-bot-api'), bot = new TelegramBot("MY_TOKEN", {polling: true}); bot.onText(/^\/createroom/, function (res, match) { //Here i have some logic, to check whether if the room already created or not service.checkIfRoomExist(res) // this service here, will always return false, because of the simultaneously chat .then (function(isExist) { if (isExist === false) { […]

用户单击Telegram Bot API后如何隐藏ReplyKeyboardMarkup

我正在使用Node.js telegram-bot-api 。 理念: 用一个button显示自定义键盘 – “分享我的电话号码”。 当用户点击这个button时,应该发送联系人,并且应该从屏幕上移除button。 这里是我现在使用的代码: bot.sendMessage({ text: 'Please give us your phone number', reply_markup: JSON.stringify({ keyboard: [ [{ text: 'Share my phone number', request_contact: true }] ], resize_keyboard: true, one_time_keyboard: true }) }); 问题: 当用户点击“分享我的电话号码”button,它共享他的联系人,但即使在那之后,button仍然可见。 当我不使用request_contact标志时, one_time_keyboard可以正常工作(在button被使用后隐藏button),但是即使在这种情况下,它也只是隐藏了button,所以用户可以点击一个图标使其返回到屏幕上,这并不好。 请告诉我,如果我在这里做错了什么。 谢谢

firebase.intializeApp不是一个函数

所以我卡在这个错误。 我正在用电报bot api制作一个电报机器人,现在我试图build立一个firebae数据库来保存一个组员的分数 – 所以重新启动机器人后不重新设置分数。 有人可以告诉我这是什么问题吗? 我在这里阅读了许多类似的问题,但这些答案都没有解决我的问题。 bot.js var TelegramBot = require('node-telegram-bot-api'); var firebase = require('firebase'); var token = 'mytoken'; // Setup polling way var bot = new TelegramBot(token, {polling: true}); var app = firebase.intializeApp({ serviceAccount: "C:/Mayer/scorebot/telegramscorebot.json", databaseURL: "https://blazing-heat-2008.firebaseio.com/" }); /* function Person(name, score) { this.name = name; this.score = score; } var member = […]

Node Telegram bot api,在用户之间进行连锁对话

我已经开始使用这个模块来编写电报的bot逻辑 我可以创build这样简单的问题和回答逻辑: bot.onText(/\/start/, function(msg, match){ bot.sendMessage(msg.chat.id, "Hello this is great bot"); }); 当用户键入/start他将收到此消息。 我想创build类似bot和用户之间的链接对话。 就像当用户input/buy机器人会显示购买选项时,在用户input他想要购买的机器之后,机器人将显示所选产品的types等等。 如何创build用户和机器人之间的链接对话? 如何让机器人记住以前select的命令,并重新设置时间? 为了做到这一点,我需要保留在自己的数据库中吗?