TBC LIBS

1. Resources Lib

Description: Handles user and global resources for managing data values associated with users or global settings.

Classes:

  • userRes(name, user=None): Manages resources associated with individual users.

    • Arguments:

      • name (required, str): Name of the resource.

      • user (optional, str): Unique identifier for the user.

    • Methods:

      • value(): Retrieves the value of the resource.

        val = libs.Resources.userRes("points", "user123").value()
      • add(value): Adds a specified value to the resource.

        libs.Resources.userRes("points", "user123").add(10)
      • cut(value): Deducts a specified value from the resource.

        libs.Resources.userRes("points", "user123").cut(5)
      • set(value): Sets the resource to a specific value.

        libs.Resources.userRes("points", "user123").set(100)
      • reset(): Resets the resource value to zero.

        libs.Resources.userRes("points", "user123").reset()
  • globalRes(name): Manages global resources that apply across all users.

    • Arguments:

      • name (required, str): Name of the resource.

    • Methods:

      • value(): Retrieves the global resource value.

        val = libs.Resources.globalRes("app_points").value()
      • add(value): Adds a specified value to the global resource.

        libs.Resources.globalRes("app_points").add(100)
      • cut(value): Deducts a specified value from the global resource.

        libs.Resources.globalRes("app_points").cut(50)
      • reset(): Resets the global resource to zero.

        libs.Resources.globalRes("app_points").reset()

2. Webhook Lib

Description: Generates unique URLs for webhook integrations.

Functions:

  • genRandomId(): Generates an 8-character random ID.

    • Usage:

      random_id = libs.Webhook.genRandomId()
  • **getUrlFor(command, user_id=None, chat_id=None, options): Generates a webhook URL based on the command and optional parameters.

    • Arguments:

      • command (required, str): Command to be executed.

      • user_id (optional, str): User ID.

      • chat_id (optional, str): Chat ID.

    • Usage:

      url = libs.Webhook.getUrlFor("start", user_id="12345", redirect_to="https://example.com")

3. Coinbase Lib

Description: Handles Coinbase API interactions for managing keys and generating API clients.

Functions:

  • setKeys(ApiKey, Secret): Sets API key and secret for Coinbase.

    • Arguments:

      • ApiKey (required, str): Coinbase API key.

      • Secret (required, str): Coinbase API secret.

    • Usage:

      libs.Coinbase.setKeys("api_key", "api_secret")
  • post(ApiKey=None, Secret=None): Returns a Coinbase client instance.

    • Arguments:

      • ApiKey (optional, str): Coinbase API key (optional if previously set).

      • Secret (optional, str): Coinbase API secret (optional if previously set).

    • Usage:

      client = libs.Coinbase.post()

4. CSV Lib

Description: Manages CSV file creation, row manipulation, and retrieval.

Class:

  • CSVHandler(filename): Initializes a handler for a specific CSV file.

    • Arguments:

      • filename (required, str): Name of the CSV file.

    • Methods:

      • create_csv(headers): Creates a CSV file with specified headers.

        libs.CSV.CSVHandler("data").create_csv(["Name", "Score"])
      • add_row(row): Adds a row to the CSV file.

        libs.CSV.CSVHandler("data").add_row({"Name": "Alice", "Score": 95})
      • delete(): Deletes the CSV file.

        libs.CSV.CSVHandler("data").delete()

5. DateAndTime Lib

Description: Retrieves the current date and time in various formats.

Functions:

  • utcnow(): Returns the current UTC date and time.

    • Usage:

      utc_time = libs.DateAndTime.utcnow()
  • now(timezone_str): Returns the current date and time for a specified timezone.

    • Arguments:

      • timezone_str (required, str): Timezone to retrieve the time for.

    • Usage:

      time_in_timezone = libs.DateAndTime.now("Asia/Kolkata")

6. Crypto Lib

Description: Provides crypto conversion and price retrieval functions.

Functions:

  • convert(_from, _to, _amo): Converts an amount from one currency to another.

    • Arguments:

      • _from (required, str): Source currency.

      • _to (required, str): Target currency.

      • _amo (required, float): Amount to convert.

    • Usage:

      result = libs.Crypto.convert("BTC", "ETH", 0.01)
  • get_price(_currency, _pricein): Retrieves the price of a currency in terms of another currency.

    • Arguments:

      • _currency (required, str): Currency to get the price for.

      • _pricein (required, str): Currency to display the price in.

    • Usage:

      price = libs.Crypto.get_price("BTC", "USDT")

7. Paytm Lib

Description: Handles Paytm transactions and key management.

Functions:

  • setKeys(key, mid, token): Sets Paytm keys.

    • Arguments:

      • key (required, str): Paytm key.

      • mid (required, str): Merchant ID.

      • token (required, str): Authentication token.

    • Usage:

      libs.Paytm.setKeys("paytm_key", "merchant_id", "auth_token")
  • send(amount, number, description=None): Sends a payment to a Paytm user.

    • Arguments:

      • amount (required, float): Amount to send.

      • number (required, str): Recipient’s Paytm number.

      • description (optional, str): Description for the transaction.

    • Usage:

      libs.Paytm.send(100.0, "9876543210", "Payment for services")

8. Oxapay Lib

Description: Integrates with the Oxapay API to create merchant payment clients.

Functions:

  • post(merchant_api_key): Initializes a client for the Oxapay API.

    • Arguments:

      • merchant_api_key (required, str): API key for merchant account.

    • Usage:

      client = libs.Oxapay.post("merchant_api_key")

9. ARB Lib

Description: Interacts with the Arbitrum blockchain for sending tokens and managing transactions.

Functions:

  • setKeys(private_Key): Sets the private key for ARB transactions.

    • Arguments:

      • private_Key (required, str): The private key for transactions.

    • Usage:

      libs.ARB.setKeys("your_private_key")
  • send(value, to, contract, private_key=None): Sends tokens on Arbitrum to a specific address.

    • Arguments:

      • value (required, float): Amount to send.

      • to (required, str): Recipient’s address.

      • contract (required, str): Contract address.

      • private_key (optional, str): Private key for signing the transaction.

    • Usage:

      txn_hash = libs.ARB.send(1.0, "recipient_address", "contract_address")
  • sendARB(value, to, private_key=None): Sends native ARB tokens directly.

    • Arguments:

      • value (required, float): Amount of ARB to send.

      • to (required, str): Recipient’s address.

      • private_key (optional, str): Private key for signing the transaction.

    • Usage:

      txn_hash = libs.ARB.sendARB(1.0, "recipient_address")

10. Coinpayments Lib

Description: Facilitates interactions with the CoinPayments API for payment processing.

Functions:

  • setKeys(public_key, private_key): Sets public and private keys for CoinPayments.

    • Arguments:

      • public_key (required, str): Public key for API.

      • private_key (required, str): Private key for API.

    • Usage:

      libs.Coinpayments.setKeys("public_key", "private_key")
  • post(public_key=None, private_key=None): Returns a CoinPayments API client.

    • Arguments:

      • public_key (optional, str): Public key (optional if already set).

      • private_key (optional, str): Private key (optional if already set).

    • Usage:

      client = libs.Coinpayments.post()

11. Polygon Lib

Description: This library enables interaction with the Polygon blockchain for sending tokens.

Functions:

  • setKeys(private_Key): Stores the private key for Polygon transactions in the database.

    • Arguments:

      • private_Key (required, str): The private key for signing transactions.

    • Usage:

      libs.Polygon.setKeys("your_private_key")
  • send(value, to, contract, private_key=None): Sends tokens to a specified address on the Polygon network using a smart contract.

    • Arguments:

      • value (required, float): Amount to send.

      • to (required, str): Recipient address.

      • contract (required, str): Contract address for the token.

      • private_key (optional, str): Private key for signing the transaction.

    • Usage:

      txn_hash = libs.Polygon.send(1.0, "recipient_address", "contract_address")
  • sendPolygon(value, to, private_key=None): Sends MATIC directly to a specified address.

    • Arguments:

      • value (required, float): Amount of MATIC to send.

      • to (required, str): Recipient address.

      • private_key (optional, str): Private key for signing the transaction.

    • Usage:

      txn_hash = libs.Polygon.sendPolygon(1.0, "recipient_address")

12. Random Lib

Description: Generates random values, including integers, strings, and floats.

Functions:

  • randomInt(val, val2): Generates a random integer between the specified range.

    • Arguments:

      • val (required, int): Start of the range.

      • val2 (required, int): End of the range.

    • Usage:

      rand_int = libs.Random.randomInt(1, 10)
  • randomStr(length, charSet=None): Generates a random string of a specified length.

    • Arguments:

      • length (required, int): Length of the generated string.

      • charSet (optional, str): Character set to use.

    • Usage:

      rand_str = libs.Random.randomStr(8)
  • randomFloat(val, val2): Generates a random float between the specified range.

    • Arguments:

      • val (required, float): Start of the range.

      • val2 (required, float): End of the range.

    • Usage:

      rand_float = libs.Random.randomFloat(1.0, 5.0)
  • randomAscii(val): Generates a random ASCII string of five characters.

    • Usage:

      rand_ascii = libs.Random.randomAscii(5)

13. Tomochain Lib

Description: Interacts with the TomoChain network for sending tokens and managing transactions.

Functions:

  • setKeys(private_Key): Stores the private key for TomoChain transactions.

    • Arguments:

      • private_Key (required, str): The private key for signing transactions.

    • Usage:

      libs.Tomochain.setKeys("your_private_key")
  • sendTRC20(value, to, contract, private_key=None): Sends TRC20 tokens to a specified address on TomoChain.

    • Arguments:

      • value (required, float): Amount to send.

      • to (required, str): Recipient address.

      • contract (required, str): Contract address for the token.

      • private_key (optional, str): Private key for signing the transaction.

    • Usage:

      txn_hash = libs.Tomochain.sendTRC20(1.0, "recipient_address", "contract_address")
  • sendTomochain(value, to, private_key=None): Sends TOMO directly to a specified address.

    • Arguments:

      • value (required, float): Amount of TOMO to send.

      • to (required, str): Recipient address.

      • private_key (optional, str): Private key for signing the transaction.

    • Usage:

      txn_hash = libs.Tomochain.sendTomochain(1.0, "recipient_address")

14. TTcoin Lib

Description: Facilitates interactions with the ThunderCore blockchain, specifically for handling TTcoin transactions.

Functions:

  • setKeys(private_Key): Stores the private key for ThunderCore transactions.

    • Arguments:

      • private_Key (required, str): The private key for signing transactions.

    • Usage:

      libs.TTcoin.setKeys("your_private_key")
  • sendTT(value, to, private_key=None): Sends TT tokens directly to a specified address.

    • Arguments:

      • value (required, float): Amount of TT to send.

      • to (required, str): Recipient address.

      • private_key (optional, str): Private key for signing the transaction.

    • Usage:

      txn_hash = libs.TTcoin.sendTT(1.0, "recipient_address")

Last updated