How to...
Q: What it is "BJS"?
It is Bot JavaScript. It's an ordinary Java with some inserts.
Q: I do not know the JavaScript. What should I do?
Usually do not need something complicated for developing bots. You can read a couple of articles about JS: https://www.w3schools.com/js/js_syntax.asp or https://en.wikipedia.org/wiki/JavaScript_syntax
Q: How can I get two answers from one command?
You can use bot answer and Bot.sendMessage("ANY message").
or use two functions: BJS code:
Q: I have Markdown warning for message in Errors. What it is?
Telegram have markdown for text formating.
samples:
So if you have incorrect markdown - you have this warning. Sample text with incorrect markdown:
Q: How I can use inline keyboard?
Please see demo bot. It avaible in the Store.
BJS code:
buttons
- it is array. It contains buttons. Each button is object with title
(required), url
or command
.
Button must have url
or command
. url
- any link.
command
- this command will be executed after button pressing. Can contain parameters through a space. Command
can not be more then 64 bytes.
Q: How to bot can send reply for users message
You need pass options parameter with is_reply
For any message in chat use: reply_to_message_id
Also you can retry with keyboard or inline keyboard too
You can retry for any message from chat.
Q: I do not undestand variables: request
, user
, chat
, and etc.
request
, user
, chat
, and etc.You can see it with inspect
function:
Q: I would like to create bjs for time limit! Example in a bot you can use the command only every 24hrs!
BJS code:
Q: How i can create bjs that if you click button it directs to open a link in web?
Unfortunately, this is not supported by the Telegram API. But you can send link to chat: answer:
Q: How i can create password access to bot?
You can use a group for commands. Then such commands can be started only by those users who are in this group. You can assign users to a group through BJS with password verification.
Example Bot:
password?
User:
12345
Bot:
Welcome, member!
In this example, the user must enter the correct password. After that, the group Members
is setted and user can execute all commands of this group. If the password is not correct, a error message is displayed.
Bot: answer: password?
need_reply: true
BJS code:
Q: Do you know BJS code that bot will automatically message user if they don't do any activity in the bot in a given time?
1. You can store Last Active time for user in bot's property:
command tracking
this is an invisible command for users. It is run from other commands only
BJS code:
2. In others commands you need call tracking
command Bjs code:
Please note. This code is needed in all commands of your bot.
3. Automatically message command. Set auto retry time for it: 24 hours
BJS:
Q: Is it possible to put some BJS code in our bot that notify user for cryptocurrency price?
You can use CurrencyQuote Lib
Q: Is it posible that bot button can have value? How to create like on the screenshot below:
You must update the keyboard every time the value changes. To do this, send the keyboard with the command. Most likely, this should be done in several commands.
BJS:
Use ResLib for any resources
Command ⚡Balance:
⚡Balance:
You need create command "⚡Balance:" (without space) or "⚡"
if you have space beetween "⚡" and "Balance"
So after button pressing:
text "⚡Balance: X BTC⚡" will be sended to chat
command "Balance:" will be executed
params "X BTC⚡" will be passed to BJS
Q: How to set the bot which it result to, when one of the telegram group members click the bot command in telegram bot, the message from the bot only seen by the clickers it self & unseen by another members.
Bot can send message to this user in private. So user need to start this bot in private chat in first.
Then on group chat:
Also it is possible show alert message for user in group chat with answerCallbackQuery after inline button pressing.
Q: How to get location from user?
User must attach his location to chat.
Need command with "Wait for answer" option (or you can use Master command and catch location)
BJS:
Q: I have command with wait fo reply. How to cancel Wait for reply?
Example - command /askName
have wait for reply. Need to cancel it.
Add keyboard to this command: keyboard "Cancel" (also can be "Back")
BJS:
Q: How to show alert on Inline button pressing?
BJS:
Q: How to check if a user joins a channel?
Strongly recommended use MembershipChecker Lib for this
Command: /isJoined
Command /onCheckJoin
Last updated
Was this helpful?