RefferalLib
Use this Lib for referral tracking.
Demo bot: https://telegram.me/DemoReferalTrackingBot
RefferalLib is core Lib now - installation is not needed!
Getting started
Basic function is track. Prefer to call it on /start:
RefLib.track(trackOptions);
params trackOptions - it is object with callback functions for:
Attribute
Description
onTouchOwnLink()
user touch own ref link
onAlreadyAttracted()
user already attracted
onAttracted(byUser)
user was attracted by other user byUser - it is common user data (fields: nickname, first_name and etc)
linkPrefix
Prefix for link. By default it is "user": https://t.me/botName?start=userID You can change linkPrefix in any time but all old links will be broken! Please check all your deep link params!
See @DemoReferalTrackingBot for details (Available in the Store)
Example
Command /start
Functions
Get Referral link for current user
RefLib.getLink();
will generate link kind http://t.me/botname?start=userUSER_ID
Also you can pass other bot name. For example - it is link for current bot:
RefLib.getLink(bot.name);
will generate link kind http://t.me/botname?start=userUSER_ID
It is possible to change link prefix:
RefLib.getLink(bot.name, "r");
will generate link kind http://t.me/botname?start=rUSER_ID
Get attractor for current user
RefLib.getAttractedBy()
return attractor user data
Remove ref data for (not worked - known bug)
It is not working now. We will fix it.
It is test method. You can run it and check ref link again like new user.
RefLib.clearRef()
Get refList
RefLib.getRefList();
return list with attracted users.
Or get for Ref List for another user:
RefLib.getRefList(another_user_id);
then code for /reflist can be:
Get refferals count
RefLib.getRefCount()
or for another user:
RefLib.getRefCount(another_user_id)
Get Top Refferal List
RefLib.getTopList()
How to
Q: How to give bonus to user for attracted friend?
Answer:
We can use ResourcesLib for this.
on /start
Q: how to give to referrer 5% of referral user deposit?
Answer:
In this example we use userRes. Also it is possible use chatRes. See ResourcesLib for details
Last updated