Bota - the ultimate Telegram bot hosting built with PHP, powered by NovaGram Library!
Use this Lib for referral system and tracking.
Basic function is track. Prefer to call it on /start command, it will start the lib and track users referral:
<?php
// for /start command
$Libs->ReferralLib->track();
// you can add other code for the /start command from here
Get Referral link for current user or another user
<?php
// get referral link for the current user
$Libs->ReferralLib->getLink();
// get referral link for the another user
$user_telegramid = 0123456789;
$Libs->ReferralLib->getLink($user_telegramid); // the user must start your bot for this to work
// output eg: https://t.me/botname?start=ref01234567
Example:
<?php
$mylink = $Libs->ReferralLib->getLink();
$User->sendMessage("Your referral link is: $mylink");
Get Referred id for current user or another user
<?php
// get Referred id for the current user
$Libs->ReferralLib->getReferredBy();
// get Referred id for the another user
$user_telegramid = 0123456789;
$Libs->ReferralLib->getReferredBy($user_telegramid); // the user must start your bot for this to work
// output user_id eg: 0123456789 if the user is referred else return null
Example:
<?php
$referer = $Libs->ReferralLib->getReferredBy();
if ($referer) {
$User->sendMessage("You was referred by $referer");
} else {
$User->sendMessage("You was not referred by anyone");
}
Get referral count for current user or another user
<?php
// get referral count for the current user
$Libs->ReferralLib->getRefCount();
// get referral count for the another user
$user_telegramid = 0123456789;
$Libs->ReferralLib->getRefCount($user_telegramid); // the user must start your bot for this to work
// output eg: 2 if the user have referrals else return 0
Example:
<?php
$ref_count = $Libs->ReferralLib->getRefCount();
$User->sendMessage("Your referral count is $ref_count");
Get referral users list for current user or another user
<?php
// get referral users list for the current user
$Libs->ReferralLib->getRefList();
// get referral users list for the another user
$user_telegramid = 0123456789;
$Libs->ReferralLib->getRefList($user_telegramid); // the user must start your bot for this to work
// output eg: array of user referrals else return null
Get top referral list for the bot
<?php
// get top referral list with default limit of 10
$Libs->ReferralLib->getTopList();
// get top referral list with limit of 100
$Libs->ReferralLib->getTopList(100);
// output eg: array of top referrals else return null
Get the list of all user id for the bot, good for broadcast
<?php
// get list of all user id for the bot
$Libs->ReferralLib->getUsersList();
// output eg: array of all user id for the bot else return null
Use this function if only you want to reset or empty referral lib data for the current bot:
<?php
$Libs->ReferralLib->destroy();
// it will return true