create links to bot_commands and pass parameters - node.js

When using the telegram API (in my case using telebot:https://github.com/kosmodrey/telebot)
How can link to a bot_command with a parameter ?
For example i want a bot that shows information about some fruits and i have
['apples','pears','bananas']
i can do /show [fruit] to show details about each fruit and /list to
show a list of all fruits.
When i do /list i want to show it like this:
You currently have 3 fruit:
APPLES PEARS BANANAS
However i want these to be clickable and once the user clicks a fruitname, he
will be directed to /show [clicked fruit].
i tried with a normal a href in { parse_mode : HTML } but that doesn't
seem to work.

Use inline buttons. They work the way you described. For example:
var options = {
reply_markup: JSON.stringify({
inline_keyboard: [
[
{text: 'button 1', callback_data: '1'},
{text: 'button 2', callback_data: '2'},
{text: 'button 3', callback_data: '3'},
],
]
})
};
bot.sendMessage(chatId, 'Pick action:', options);
You can think of them as anchor tags. They appear along with the text in chat window, and scroll with the text, but you can click on them. Non-inline buttons are more like a permanent menu.
Example above is using this library.

Related

how to create a chat menu button in telegrafjs

im creating a telegram bot using nodejs and telegrafjs
i want to know how to create this menu button i cant find anywhere in documents.
it opens up a menu like this one
Check this examples
bot.command('your command', async (ctx) => {
return await ctx.reply('this is text', Markup
.keyboard([
['button 1', 'button 2'], // Row1 with 2 buttons
['button 3', 'button 4'], // Row2 with 2 buttons
['button 5', 'button 6', 'button 7'] // Row3 with 3 buttons
])
.oneTime()
.resize()
)
})

Why does the button not work in Google Assistant?

I attempt to add a button onto my action on Google assistant, but the code only works for the first one. Here is where I add in the button for the ones that don't work:
'Biology': {
title: 'Biology',
text:'Press the button to visit our site for more info. Biology is an important subject for those who are willing to take it, and this website will provide you' +
'with the necessary skill for this subject.',
image: new Image({
url: 'https://www.edzuki.com/biology/Biology+Edzuki.jpg',
alt: 'Biology as a subject',
}),
button: new Button({
title:'Click for the Biology Page',
url: 'https://www.edzuki.com/biology/',
}),
and, for some reason, this one works
'Art': {
title: 'Art',
text:'Press the button to visit our site for more info. Art is an important subject for those who are willing to take it, and this website will provide you' +
'with the necessary skill for this subject.',
image: new Image({
url: 'https://www.edzuki.com/art/Art.jpg',
alt: 'Art as a subject',
}),
buttons: new Button({
title: 'Click for Art',
url: `https://www.edzuki.com/art/`,
}),
display: 'WHITE',
},
for const subjectCard (a basic card).
No errors are thrown by the assistant, just no button is visible. Why is this?
Thanks in advance.
In your first example you use the key button for your button, but in the second example you use buttons with an 's'. The docs also suggest you should be using the plural version buttons and your own code should show you this works based on your second working example
https://developers.google.com/actions/assistant/responses#basic_card
e.g
'Biology': {
title: 'Biology',
text:'Press the button to visit our site for more info. Biology is an important subject for those who are willing to take it, and this website will provide you' +
'with the necessary skill for this subject.',
image: new Image({
url: 'https://www.edzuki.com/biology/Biology+Edzuki.jpg',
alt: 'Biology as a subject',
}),
buttons: new Button({
title:'Click for the Biology Page',
url: 'https://www.edzuki.com/biology/',
}),

Adding a colorbutton in tinymce dialog with api 4.x doesn't work

I'm trying to add a colorbutton in a TinyMCE dialog box to replace my old color selector which was initially created with a select input.
See : ColorButton : API 4.X
This class creates a color button control. This is a split button in which the main button has a visual representation of the currently selected color. When clicked the caret button displays a color picker, allowing the user to select a new color.
I can add and see the new colorbutton in the dialog box but it doesn't show the colorpicker when clicked.
Here is my code:
editor.windowManager.open( {
title: 'Choose color',
body: [
{
type: 'listbox',
name: 'bg-color',
label: 'Color (select)',
'values': [
{text: 'White', value: '#FFF'},
{text: 'Black', value: '#000'},
{text: 'Silver', value: 'silver'},
]
},
{
type: 'ColorButton',
name: 'bg-color2',
label: 'Color (colorpicker)',
},
],
onsubmit: function(e) {
// Do something here
}
});
And you will find a tinymce fiddle here to illustrate this issue:http://fiddle.tinymce.com/sfeaab
Since my debugger doesn't show any JS error, is there something wrong in this code or is there another way to add a colorpicker in a dialogbox?
Thanks!
#MavBzh I think you've a wrong perception on how the color button works. The ColorButton UI is only help with rendering a button which not much difference with PanelButton UI. you can see this example http://fiddle.tinymce.com/sfeaab/3 in this fiddle I use textcolor plugin example.
So, in order to use color button you're required to specify the Panel to hold the color picker.
{
type: 'colorbutton',
name: 'color',
text: 'Color',
selectcmd: 'ForeColor',
panel: {
role: 'application',
ariaRemember: true,
html: renderColorPicker,
onclick: onPanelClick
},
onclick: onButtonClick
}
then later set onclick callback action and render the color picker HTML output yourself, the renderColorPicker function is used as the panel content, then assigned onPanelClick callback to put the color to the text placeholder in the ColorButton.
PS: in the fiddle I used v4.0.21

Creating 2 buttons on Same Screen Sencha Architect 2

I'm following this tutorial to create a Sencha Touch Application,
I want to create 2 buttons on the same screen and each button redirect to another page when clicked, on the tutorial it use Form panel and only one button to redirect to another page, but if I link 2 Form Panels to the Navigator View, it only appear one form panel, I want to know a way to add 2 buttons on the same screen and call one userAlias for each button to redirect to the another page.
What I do ? Add 2 buttons on the same FormPanel ? If yes, how I call one diferent page for each button, because I use only one userAlias on the form panel with this function:
button.up('navigationview').push({
xtype: 'step3',
title: 'Step 3'
});
Thanks for the help
use two different handlers for the buttons.
Example :: Button 1 ::
{
xtype : 'button',
text : 'button 1',
handler : function(){
alert('do something');
this.up('navigationview').push({ . . . . });
}
}
Example :: Button 2 ::
{
xtype : 'button',
text : 'button 2',
handler : function(){
alert('do something else');
this.up('navigationview').push({ . . . . });
}
}

Card layout - Active Item - sencha touch

I am having one view which is in card layout.
Card is having 2 sub views.
Now I want to get the activeitem.
In extjs I am using this code:
activeItem = layout.getActiveItem().itemId;
but in sencha touch , for card layout , there is no such method named getActiveItem() for card layout.
I have referred sencha touch docs and I found that.
Anybody knows the alternative for this?
var panel = Ext.create('Ext.Panel', {
layout: 'card',
items: [
{
html: "First Item"
},
{
html: "Second Item"
},
{
html: "Third Item"
},
{
html: "Fourth Item"
}
]
});
panel.setActiveItem(1);
It also have getActiveItem() method to work with.
Refer http://docs.sencha.com/touch/2-1/#!/api/Ext.layout.Card

Resources