ResourcesLib
With lib we can manage any resources in bot.
It is bad practice to use Res for counting. Use simple Integer or Float types for it and setProp!
ResourcesLib is good for using it with growth. If you don't have growth it is possible you don't need use this lib.
Resource can be
balance (in USD, BTC or any other)
any game resources: gold, woods, stone, etc
etc, any float values
User's resource
Res name is case sensitive. The resources “money”, “Money” and “MONEY” do not match. These are 3 separate resources.
One user can have same chats with bot.
For example: private and group chat.
But anywhere he have simular resources
Chat's resource
One user can have same chats with bot.
For example: private and group chat.
But he have diffent resources for each chats.
Methots for user's and chat resources
All methods can be for user's or chat's resources.
res.name
- current res name. For example:
Basic functions
Current res amount
res.value()
Set amount for this res
res.set(amount)
for example: Libs.ResourcesLib.userRes("wood").set(10);
Add amount for this res
res.add(amount)
Res have such amount?
res.have(amount)
- if res value equal amount or more return true
Take away amount from resource
res.remove(amount)
- if have it res.removeAnyway(amount) - take away amount anyway.
Access to another resources
Access to another user's resources
Access to another chat's resources
Resource transfering
If have resource...
...or anyway, even resource is not enough
Can exchange different resources
For example "gold" for "wood":
res.exchangeTo(anotherRes, { remove_amount: 10, add_amount:23 } )
Growth for resource.
Resource can have growth.
For example simple growth:
add 5 every 10 secs to res
Interval - it is value in seconds. Value is added every interval
Add 5 every hour with max value 100.
Value can be negative. Remove 5 every 30 hours.
Can limit max iteration count
Can growh by percent.
For example add 15% every month for 100 USD
Can grow by compound interest.
For example add 0.8% every day for 0.5 BTC with reinvest
You can get initial res value by: res.baseValue()
Reset growth
Growth will be removed
Other methods for res.growth:
res.growth.info()
- get info for current growth
res.growth.title()
- get title. For example "add 5 once at 15 secs"
res.growth.isEnabled()
- return true if is enabled
res.growth.stop()
- stop growth
res.growth.resume()
- resume growth after stop
res.growth.remove()
- remove growth
res.growth.progress()
- current progress for next iteration
res.growth.willCompletedAfter()
- will completed iteration after this time in seconds
How to add growth to another resources?
For example we have:
bank deposit 100$ with yearly growth 10%
and simple wallet - 500$
Every year we add bank growth to wallet.
Init: on /start
command (or any other command)
/start
command (or any other command)On /wallet
command or etc
/wallet
command or etcWe can run this command every 1 year. It is possible for example, with Auto Retry
Or user can run it manually in anytime.
How to
Q: How to give to referrer 5% of referral user deposit?
Please see https://help.bots.business/libs/refferallib#how-to
Q: How to give a bonus to all users every day?
For example add 10 to user's balance every day
Command /start
Command /addBonus
Command /addBonus will be executed for each user. It spend 1 iteration every day for each user.
For example, for 100 user - it will be 100 iterations per day.
Q: How to make time limit bonus?
Use Cooldown Lib! It is more simple!
For example, user can get bonus once at 5 hours.
Command /bonus
Last updated