BB Point Bot πŸ’Ž
BB Point bot helps develop the community. User can echange BB Points to Extra Iterations.
Also it is possible:
  • Accept BB Points πŸ’Ž in your bot from users
  • Transfer BB Points πŸ’Ž from your bot to users
This functionality is built with WebhookLib. You can do some pretty cool stuff in your bots to share data too.

Accept BB Points in your bot

We can accept BB Points πŸ’Ž in any bot now.
See example in @BBWebhookBot​

How to make?

See example for /sample3 in @BBWebhookBot​

Step 1

Install Webhook Lib in your bot and make webhook url:
1
// Generate webhook link for BB Point Bot
2
let url = Libs.Webhooks.getUrlFor({
3
command: "onBBPointIncome"
4
})
5
​
6
Bot.sendMessage(
7
"Set this url in [@BBPointBot](https://t.me/BBPointBot?start=link) " +
8
"bot for notification." +
9
"\n\nCommand [@BBPointBot > /link](https://t.me/BBPointBot?start=link) "
10
)
11
​
12
// send url without markup
13
Api.sendMessage({ text: url });
Copied!
​

Step 2

Go to @BBPointBot - /link and paste link from step1
You will get such link for request:
https://t.me/BBPointBot?start=req15-1-points-to-519829299
You can change bb point amount in url part: -XXX-points
You can change user.id after part: -to-user-XXX
​

Transfer BB Points πŸ’Ž from your bot to users

Step 1

Generate your personal secret webhook url in @BBPointBot by command: /getTransferUrl
Set Secret (any words or symbols - whatever you want) in @BBPointBot by command: /setTransferSecret
Personal secret webhook url with Secret - is safe information.
You can reset the Secret at any time via command /setTransferSecret
​

Step 2

In your bot command create new command /makeTransfer:
1
// Danger! User can run this command
2
// You need add logic for secure
3
// if(your logic){ return }
4
​
5
// Just generate webhook url for current user
6
let webhookUrl = Libs.Webhooks.getUrlFor({
7
command: "onTransfer",
8
user_id: user.id
9
})
10
​
11
Bot.sendMessage("Transfer in progress")
12
​
13
// make transfer request to BB Point bot
14
HTTP.post( {
15
url: "http://Your Personal secret webhook url from step 1",
16
17
body: {
18
// BB Points amount
19
amount: 3,
20
// transfer BB Points for current user
21
to_tg_id: user.telegramid,
22
// note for @bbpoints channel
23
note: "#testTransfer by " + bot.name,
24
webhookUrl: webhookUrl,
25
secret: "your Secret" // from step 1
26
}
27
} )
28
​
Copied!
This command transfer BB Points without any conditions.
You must add some conditions. You are not going to send BB Points without any reason?
Step 3
In your bot command create new command onTransfer:
1
var json = JSON.parse(content);
2
​
3
// You can inspect all passed data:
4
// Bot.inspect(json)
5
​
6
if(json.error){
7
Bot.sendMessage("Error: " + json.error.title);
8
Bot.sendMessage("Code: " + json.error.code);
9
// error codes:
10
// 1 - You do not have BB Points for transfer
11
return
12
}
13
​
14
// BB Points transferred to current user
15
let admin_bb_points = json.owner.bb_points - json.amount;
16
​
17
Bot.sendMessage(
18
"BB Points transferred:\n" +
19
json.amount + "πŸ’Ž BB Points to tg id: " + user.telegramid +
20
​
21
"\n\nAdmin: @" + json.owner.username +
22
"\n have now: " + String(admin_bb_points) + "πŸ’Ž BB Points"
23
)
24
​
25
​
Copied!
​
Last modified 5mo ago