As per the description of this library, it can detect the inline keyboard in text :
hei this is tes keyboard (button1,https://butthx.glitch.me)
This library useful to make it easier for you to create a telegram bot and want the bot to be able to detect that message contains an inline keyboard.
text(text)
Params :
text : contains text with the template and will return String from the formating results.
Example :
var mt = new butthx.mt()
function getTextOnly(){
let text = `hei this is tes keyboard (button1,https://butthx.glitch.me)`
let res = mt.text(text)
Logger.log(res)
}
Result : hei this is tes keyboard
button(text)
Params :
text : contains text with the template and will return Array from the formating results.
Example :
var mt = new butthx.mt()
function getButtonOnly(){
let text = `hei this is tes keyboard (button1,https://butthx.glitch.me)`
let res = mt.button(text)
Logger.log(res)
}
Result : [[{text:'button1',url:'https://butthx.glitch.me'}]]
all(text)
Params :
text : contains text with the template and will return JSON from the formating results.
Example :
var mt = new butthx.mt()
function getAll(){
let text = `hei this is tes keyboard (button1,https://butthx.glitch.me)`
let res = mt.all(text)
Logger.log(res)
}
Result :
{
'text':'hei this is tes keyboard',
'keyboard':[[{'text':'button1','url':'https://butthx.glitch.me'}]]
}
Custom Regex
Okay I give this method so you can customize your own regex pattern. The default is:(text,url)
and (text,url):same
:same in here will make the keyboard in 1 line.
So if you want to customize your regex then pay attention to the following!
Groups Name
text,url,same all of this is needed so that the library doesn't crash when you customize the regex.
Flags
The flag of the regex must be gmi
How do I implement regex customization?
We give you 3 ways to customize regex.
method 1
You can do it on var mt = new butthx.mt(regex)
method 2
You can describe one by one in each process. like this let getAll = mt.all(textInput,{regex:regex})
This method has 2 capabilities if you want to use our default regex and you have customized the regex in the first step. you can do like: let getAll = mt.all(textInput,{regex:'default'})
method 3
You can use this method in every function (unlike method 1 which is global)mt.custRegex(regex)
Bonus! if you want to make your regex the default (in the sense when you use {regex:'default'}
) then this method mt.setDefault(regex)
Try Demo On Telegram!