How can I do inline button, that can share message to another chat?
You can use switch_inline_query:
var iKeys = [];
iKeys.push([{
text: "Share",
switch_inline_query: "Shared message"
}]);
bot.sendMessage(message.chat.id, "Question", {parse_mode: 'HTML', reply_markup: {inline_keyboard: iKeys}});
Hello.
How is it possible to get the switch_inline_id so that when you press the share button, leave @alias of the bot plus the message ID?
Through CallbackData?
Thanks in advance.
I can't understand clearly your question, but try to take a loot at _switch_inline_query_current_chat_, if is something can help you.
a clear example is to share with a button, a button with different links and publish it on a channel. I hope to have explained to me the best possible. Thanks in advance
Hello, I have several questions: I have tried to create a button that is responsible for sending a post to another chat. I have tried to modify the example code that is above this section without getting results. I would like if it were possible that they would explain to me quickly the operation of the online keyboards or guide me in the creation of a similar button.
Many thanks in advance
I think you need that:
var code = "test";
var iKeys = [];
iKeys.push([{
text: "Share query",
switch_inline_query: code
}]);
bot.sendMessage(message.chat.id, "Click below to share your code", {
parse_mode: 'Markdown',
reply_markup: {
inline_keyboard: iKeys
}
});
@sidelux I continue with the same doubt. And that example I still can not make it work. You could explain it a little more if it's not too much trouble. We've been trying to make it work for a week and it's impossible for me.
Check many tutorials by Google, but it was not helpful. So if you can explain it a little more I would appreciate it
Exactly how Daniel explained it, I have a database with which to work but I do not show results
I don't know which part are not clear to you, anyway i provide you an example related to my workflow.
@botname <code>So:
bot.onText(/^\/create/, function (message, match) {
var code = Math.random()*1000;
// save code to database
var iKeys = [];
iKeys.push([{
text: "Share query",
switch_inline_query: code
}]);
bot.sendMessage(message.chat.id, "Click below to share your code", {
parse_mode: 'Markdown',
reply_markup: {
inline_keyboard: iKeys
}
});
});
Then:
bot.on("inline_query", function (query) {
var code = parseInt(query.query);
// check if the code is in database and user can use it (valid var)
if (valid == true){
bot.answerInlineQuery(query.id, [{
id: '0',
type: 'article',
title: 'New item',
description: "Publish item",
message_text: "Details of your item base on code..."
}]);
}else{
bot.answerInlineQuery(query.id, [{
id: '0',
type: 'article',
title: 'New item',
description: "Publish item",
message_text: "Code not found"
}]);
}
});

Then, after user selected chat

Now, if you not understand yet, please give me a valid example so i can explain you in a more detailed way.
@sidelux In the third line of code, it says to save the code in the database ... the buttons? send Message?
The var variable that would be referenced in the database?
Thanks in advance
Thanks Sidelux for your time, mate.
I was using the inline keyboards, but I was wrong. I was missing the bot.on. That's why he did not finish answering
and I have another question that database you use because I see that you put "save code to database".
If I understand well what you keep is the message and the id of it, right?
@DestroyerIV For me is the random generated code:
...
var code = Math.random()*1000;
connection.query("INSERT INTO list VALUES (" + code + ")", function (err, rows, fields) {
if (err) throw err;
var iKeys = [];
...
});
...
var code = parseInt(query.query);
var valid = false;
connection.query("SELECT 1 FROM list WHERE code = " + code, function (err, rows, fields) {
if (err) throw err;
var cnt = Object.keys(rows).length;
if (cnt > 0)
valid = true;
if (valid == true){
...
});
@danielperez9430 Nope, is the data i want to use in inline mode (number, string, etc).
Okey Thanks for the information mate, 馃槏馃槏 and thanks for your time
Most helpful comment
I don't know which part are not clear to you, anyway i provide you an example related to my workflow.
@botname <code>So:
Then:
Then, after user selected chat
Now, if you not understand yet, please give me a valid example so i can explain you in a more detailed way.