Bots.Business - Help
  • Welcome
  • Getting started
  • Create bot from Google Table
  • App
    • Reset or Update Your Password
  • Commands
    • Answer
    • Aliases
    • Keyboard
    • Groups
    • Wait for answer
    • Auto Retry (AR)
  • Coding: BJS
    • Variables
    • Bot functions
    • Message broadcasting and editing
    • User functions
    • Properties
    • Always running commands
    • Error command: "!"
    • Lists
      • Migration from properties to list
    • Api functions
    • BB Admin functions
    • Admin Panel
    • Send HTTP request
    • Web App
    • Caching
    • Inline Bot
    • BJS Security
    • Good coding practices
    • Top errors
  • Git
    • Import bot from Git repository
    • Export bot to Git repository
    • Repository structure
    • File: bot.json
    • Automatic importing on Git push
  • Iterations. How to reduce theys?
  • Limitations
  • Cloud
  • Reports
  • Deep Linking - pass any params on Bot starting
  • How to link chat account with BB account?
  • BB Inspection
  • Protected bot
  • VS Code
  • How to...
  • Smart Bot
    • Overview
    • Lang File
    • SmartBot
    • SmartTasker
    • Amount Dialog
  • Libs
    • What it is - Libs?
    • Libs development
    • RefferalLib
    • ResourcesLib
    • Random
    • MembershipChecker (MCL)
    • Cooldown Lib
    • CurrencyConverter
    • Lang
    • TopBoardLib
    • QiwiPayments
    • Coinbase (CB)
    • CoinPayments (CP)
    • OxaPay
    • CryptoJS
    • CurrencyQuote
    • GoogleApp
    • GoogleTableSync
    • Guard
    • Webhooks lib
    • DateTimeFormat Lib
  • Store
    • BB Point Bot
    • Welcome bot
    • Help bot
    • SRB Demo Keyboard Tools
Powered by GitBook
On this page
  • Introducing
  • Types
  • Set property
  • Set prop for other user by id
  • Set prop for other user by telegramid
  • You can save prop in the List
  • Get property
  • Getting other user's prop:
  • Getting other bot prop for current user:
  • Getting other bot prop for other user:
  • Delete property

Was this helpful?

  1. Coding: BJS

Properties

Introducing

It is possible to save data in bot. Data can be numeric, text, datetime and etc.

For example:

  • Bot can have DailyBonus saved in bot prop (it is global for all bot)

  • User can have Balance saved in user prop (it is personall)

Properties can be belong for user or for bot.

Types

Properties can be:

  • integer, e.g.: 150

  • float, e.g.: 5.5

  • boolean: true, false

  • string, e.g.: "Hello world"

  • text, e.g.: "it is very big text ..... 1000 symbols here or more"

  • json, e.g.: { any: "data", here: "can", be: {used: true}, with: ["array", "too"] }

  • datetime, e.g: new Date()

Set property

// set global prop
Bot.setProp({ name: 'myProp', value: 15 });
 
// set JSON prop for user
User.setProp({
 name: 'BIO',
 value: { email: "test@example.com", age: 10 }
});
  • so for global prop use Bot.xxx method

  • for user's prop use User.xxx method

You can use short naming also: Bot.setProp, User.setProp

also you can use old style:

 // set global prop
Bot.setProperty("myProp", 15, "float");

Set prop for other user by id

 // set global prop
Bot.setProp({
  name: 'otherUserProp',
  value: "test Prop",
  // you can pass other user.id for saving user prop for other user
  user_id: other_user.id
});

Set prop for other user by telegramid

 // set global prop
Bot.setProp({
  name: 'otherUserProp',
  value: "test Prop",
  // you can pass other user.id for saving user prop for other user
  user_telegramid: other_user.telegramid
});

You can set (or read) property via bot_id and read (or set) it via telegramid. It doesn't matter and it will be the same value.

You can save prop in the List

Get property

// get global prop
var myProp = Bot.getProp('myProp');
Bot.sendMessage("prop: " + myProp);
 
// get prop for user
var bio = User.getProp('BIO');
Bot.sendMessage("Hello, " + bio);

or get prop with default value:

// prop by default will be 15
var myProp = Bot.getProp('myProp', 15);

You can use short naming also: Bot.getProp, User.getProp

Getting other user's prop:

Your bot must have this user

// get prop for other user
var bio = Bot.getProp({
  name: 'BIO',
  // you can pass other user.id for getting other user prop
  user_id: other_user_id
  // or by telegramid:
  // user_telegramid: other_user_telegramid
});

You can set (or read) property via bot_id and read (or set) it via telegramid. It doesn't matter and it will be the same value.

Getting other bot prop for current user:

Your account must have this bot

// get other bot prop for cur user
var bio = Bot.getProp({
  name: 'BIO',
  bot_id: other_bot_id  // available via bot.id
  // if needed:
  // user_id: userID // for user's prop
  // user_telegramid: tgID // for user by telegramid
});

Getting other bot prop for other user:

Your account must have this bot with this user

// get other bot prop for cur user
var bio = Bot.getProp({
  name: 'BIO',
  bot_id: other_bot_id  // available via bot.id
  // you can pass other user.id for getting other user prop
  user_id: other_user_id
});

Delete property

// prop "myProp" will be removed
Bot.deleteProp("myProp");

Then null passing to prop's value is delete property also:

// prop "myProp" with null value will be removed
Bot.setProp("myProp", null, "float");

PreviousUser functionsNextAlways running commands

Last updated 9 months ago

Was this helpful?

Please read this

article