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

Was this helpful?

  1. Libs

Cooldown Lib

Use this Lib to make cooldown.

Cooldown have name and can be for user or for chat.

Example

Command /bonus

function onEnding(time){
  // can give bonus now
  Bot.sendMessage("You have bonus now");
  // your other code here
  //..

  return true; // if false - cooldown is not restarted
}

function onStarting(){
  // cooldown just started
  Bot.sendMessage("You will have bonus later");
}

function onWaiting(waitTime){
  // we have active cooldown
  Bot.sendMessage("Please wait: " + waitTime + " secs" );
}

Libs.CooldownLib.user.watch({
  // you need name for cooldown
  name: "GemBonusCooldown",
  time: 120, // cooldown time, 120 secs - 2 minute
  onStarting: onStarting,
  onEnding: onEnding,
  onWaiting: onWaiting
})

or cool down for chat:

// or cooldown for chat:
Libs.CooldownLib.chat.watch({
  // you need name for cooldown
  name: "GemBonusCooldown",
  time: 120, // cooldown time, 120 secs - 2 minute
  onStarting: onStarting,
  onEnding: onEnding,
  onWaiting: onWaiting
})


// or global bot cooldown
// it can be used with Auto Retry (then chat or user are null)
/*
Libs.CooldownLib.watch({
  // you need name for cooldown
  name: "GemBonusCooldown",
  time: 120, // cooldown time, 120 secs - 2 minute
  onStarting: onStarting,
  onEnding: onEnding,
  onWaiting: onWaiting
})
*/

get cool down:

// get current cooldown res for chat
let cooldown = Libs.CooldownLib.chat.getCooldown("GemBonusCooldown");

// for user:
// let cooldown = Libs.CooldownLib.user.getCooldown("GemBonusCooldown");

// global
// let cooldown = Libs.CooldownLib.getCooldown("GemBonusCooldown");

cooldown.value(); // current cooldown in second
cooldown.set(60 + cooldown.value()) // add 60 sec to cooldown

Command /bust

// get current cooldown Res - see ResourcesLib
let cooldown = Libs.CooldownLib.chat.getCooldown("GemBonusCooldown");

// for user:
// let cooldown = Libs.CooldownLib.user.getCooldown("GemBonusCooldown");

// global
// let cooldown = Libs.CooldownLib.getCooldown("GemBonusCooldown");

var curValue = cooldown.value(); // current cooldown in second
cooldown.set(curValue - 40) // reduce 40 sec from cooldown

PreviousMembershipChecker (MCL)NextCurrencyConverter

Last updated 1 year ago

Was this helpful?