🎉 Welcome to BJSkillBuilder! 🎉
Hey there, Skill Builders! 👋✨
We’re SUPER excited to kick off our journey with you on this channel! 🚀 Are you ready to unlock your potential and level up your skills? Whether you want to master a new hobby, boost your career, or just learn something fun, you’ve come to the right place! 🌟
🌈 What’s Coming Your Way:
• 📚 Skill Tutorials: Easy-to-follow guides on everything from coding 💻 to creative arts 🎨!
• 🗣️ Expert Interviews: Get insider tips from industry pros who are ready to share their secrets! 🤫
• 🏆 Fun Challenges: Participate in exciting activities to put your new skills to the test and show off your progress! 🎉
• 🤝 Community Support: Connect with fellow learners, share your journey, and ask all the questions you have! 💬
💡 We Want to Hear from YOU!
What skills are you eager to learn? Drop a comment below and let us know! We can’t wait to create content that YOU want to see! 🎯
Stay tuned for our very first tutorial coming soon! Let’s embark on this amazing learning adventure together! 🌍✨
Happy Learning,
The BJSkillBuilder Team 💖
❓ Want to donate us
https://t.me/DonatePB_Bot?start=donate
Hey there, Skill Builders! 👋✨
We’re SUPER excited to kick off our journey with you on this channel! 🚀 Are you ready to unlock your potential and level up your skills? Whether you want to master a new hobby, boost your career, or just learn something fun, you’ve come to the right place! 🌟
🌈 What’s Coming Your Way:
• 📚 Skill Tutorials: Easy-to-follow guides on everything from coding 💻 to creative arts 🎨!
• 🗣️ Expert Interviews: Get insider tips from industry pros who are ready to share their secrets! 🤫
• 🏆 Fun Challenges: Participate in exciting activities to put your new skills to the test and show off your progress! 🎉
• 🤝 Community Support: Connect with fellow learners, share your journey, and ask all the questions you have! 💬
💡 We Want to Hear from YOU!
What skills are you eager to learn? Drop a comment below and let us know! We can’t wait to create content that YOU want to see! 🎯
Stay tuned for our very first tutorial coming soon! Let’s embark on this amazing learning adventure together! 🌍✨
Happy Learning,
The BJSkillBuilder Team 💖
❓ Want to donate us
https://t.me/DonatePB_Bot?start=donate
👍7🔥3❤2
🌟 Day 1: Welcome to Bots.Business and JavaScript Basics! 🌟
Hi everyone! 👋 Welcome to Day 1 of our 30-Day Bots.Business JavaScript (BJS) Learning Session! 🎉 Today, we’re starting our exciting journey into the world of bots. 🤖✨ We’ll learn the basics of Bots.Business and a little bit about JavaScript. 💻
---
▎What is Bots.Business? 🤔
Bots.Business is a cool platform that helps you create and manage bots easily. You’ll use a special version of JavaScript called Bots.Business JavaScript (BJS). Don’t worry if you’ve never coded before—this is made for beginners! 🌱
▎Why Use Bots.Business? 🌈
• Easy to Use: You can start making bots quickly. ⚡
• Great Features: Use helpful tools to make your bots even better. 🛠️
• Many Uses: Create bots for Telegram, automate responses, and more! 📲
---
▎What is JavaScript? 📜
JavaScript is a popular programming language that makes websites interactive. It’s also used to create bots! In our learning session, we’ll work with a simpler version called BJS (Bots.Business JavaScript). 🎈
---
▎Let’s Get Started! 🚀
1. Create Your First Bot 🤖
• Log in to the Bots.Business platform. 🔑
• Give your bot a fun name! 🎊
2. Set Up a Command 💬
• Bots respond to commands. You’ll set one up today!
• Example: Create a command called
• "Welcome to my first bot! Let’s get started!" 🎉
3. Test Your Bot 🧪
• Connect your bot to Telegram using the BotFather token. 🔗
• Try out the
---
▎Example: Your First Script 📝
Let’s make your bot send a welcome message when someone starts it. Here’s how:
• Go to your bot’s Command Editor. 🛠️
• Create a command (like
Now, when you type
"Hello! This is my first Bots.Business bot." 🎊🤖
---
▎Your Assignment for Day 1 📚
1. Create your first bot and give it a fun name. 🎉
2. Set up a
3. Test your bot by sending the
Bonus: Try adding a
---
▎What’s Next? 🔮
Join us tomorrow for Day 2, where we’ll learn more about how bots work and how they handle commands. Keep experimenting, have fun, and let your creativity shine! ✨
Happy bot building! 🚀🎉
Hi everyone! 👋 Welcome to Day 1 of our 30-Day Bots.Business JavaScript (BJS) Learning Session! 🎉 Today, we’re starting our exciting journey into the world of bots. 🤖✨ We’ll learn the basics of Bots.Business and a little bit about JavaScript. 💻
---
▎What is Bots.Business? 🤔
Bots.Business is a cool platform that helps you create and manage bots easily. You’ll use a special version of JavaScript called Bots.Business JavaScript (BJS). Don’t worry if you’ve never coded before—this is made for beginners! 🌱
▎Why Use Bots.Business? 🌈
• Easy to Use: You can start making bots quickly. ⚡
• Great Features: Use helpful tools to make your bots even better. 🛠️
• Many Uses: Create bots for Telegram, automate responses, and more! 📲
---
▎What is JavaScript? 📜
JavaScript is a popular programming language that makes websites interactive. It’s also used to create bots! In our learning session, we’ll work with a simpler version called BJS (Bots.Business JavaScript). 🎈
---
▎Let’s Get Started! 🚀
1. Create Your First Bot 🤖
• Log in to the Bots.Business platform. 🔑
• Give your bot a fun name! 🎊
2. Set Up a Command 💬
• Bots respond to commands. You’ll set one up today!
• Example: Create a command called
/start and make it say:• "Welcome to my first bot! Let’s get started!" 🎉
3. Test Your Bot 🧪
• Connect your bot to Telegram using the BotFather token. 🔗
• Try out the
/start command and see your bot in action! 🎈---
▎Example: Your First Script 📝
Let’s make your bot send a welcome message when someone starts it. Here’s how:
Bot.sendMessage("Hello! This is my first Bots.Business bot.");• Go to your bot’s Command Editor. 🛠️
• Create a command (like
/hello) and paste that code there.Now, when you type
/hello in Telegram, your bot will reply with:"Hello! This is my first Bots.Business bot." 🎊🤖
---
▎Your Assignment for Day 1 📚
1. Create your first bot and give it a fun name. 🎉
2. Set up a
/start command with your welcome message. 💬3. Test your bot by sending the
/start command in Telegram. 📲Bonus: Try adding a
/hello command using the example code! 🌟---
▎What’s Next? 🔮
Join us tomorrow for Day 2, where we’ll learn more about how bots work and how they handle commands. Keep experimenting, have fun, and let your creativity shine! ✨
Happy bot building! 🚀🎉
1👍7❤5🔥1
What is the correct way to make your bot send a "Hello!" message when the user types /hello?
Final Results
81%
Bot.sendMessage("Hello!");
2%
console.log("Hello!");
5%
Add "Hello!" in the bot's description.
12%
Bots can't respond to /hello commands.
👍3
▎Day 2: Bot Commands and Responses 🎉
Welcome to Day 2 of the 30-Day Bots.Business JavaScript (BJS) Learning Session! 🚀 Yesterday, we covered the basics of Bots.Business and created a simple bot with a /start command. Today, we’ll dive deeper into commands and learn how to make your bot respond to user input dynamically. 💬
---
▎What Are Commands? ❓
In Bots.Business, commands are the backbone of your bot. Each command is a specific trigger that tells your bot how to respond when a user sends a particular message. Commands can have predefined text responses or JavaScript code for more dynamic actions. ⚙️
---
▎How to Create Commands 🛠️
1. Step 1: Open the Command Editor
Go to your bot’s Commands section in the Bots.Business dashboard. 📊
2. Step 2: Add a New Command
Create a new command by typing its name (e.g., /info, /help). ✏️
Add the response or JavaScript code you want the bot to execute when the command is triggered. 🔄
3. Step 3: Save and Test
Save the command and test it in Telegram by typing the command in your bot's chat. 📱
---
▎Static Response Example 📜
Let’s create a simple command called
• Command Name:
• Response: "Welcome to the help section! Use /start to begin or /info to learn more about me." 🆘
When a user types
---
▎Dynamic Response Example Using JavaScript 💻
You can use JavaScript to make responses more dynamic. For example, let’s create a
• Create a command
• Add the above script to the command.
• Save and test it by typing
If the user’s first name is John, the bot will reply:
"Hello, John! How can I assist you today?" 👋
---
▎Handling Custom Inputs 🎨
You can also create commands to handle inputs from users. For instance, let’s create a
To handle the user’s reply, you can create another command to capture their response. For example:
---
▎Assignment for Day 2 📚
1. Create a command
"This is a demo bot created with Bots.Business JavaScript. Stay tuned for more!" 🎊
2. Create a dynamic command
3. Optional Challenge:
Create a command
---
▎What’s Next? 🔮
Tomorrow, in Day 3, we’ll explore Variables in Bots.Business JavaScript. Variables will allow us to store and manipulate user data to create more personalized and interactive bots. Keep practicing and experimenting! 💪
Welcome to Day 2 of the 30-Day Bots.Business JavaScript (BJS) Learning Session! 🚀 Yesterday, we covered the basics of Bots.Business and created a simple bot with a /start command. Today, we’ll dive deeper into commands and learn how to make your bot respond to user input dynamically. 💬
---
▎What Are Commands? ❓
In Bots.Business, commands are the backbone of your bot. Each command is a specific trigger that tells your bot how to respond when a user sends a particular message. Commands can have predefined text responses or JavaScript code for more dynamic actions. ⚙️
---
▎How to Create Commands 🛠️
1. Step 1: Open the Command Editor
Go to your bot’s Commands section in the Bots.Business dashboard. 📊
2. Step 2: Add a New Command
Create a new command by typing its name (e.g., /info, /help). ✏️
Add the response or JavaScript code you want the bot to execute when the command is triggered. 🔄
3. Step 3: Save and Test
Save the command and test it in Telegram by typing the command in your bot's chat. 📱
---
▎Static Response Example 📜
Let’s create a simple command called
/help that responds with a static message:• Command Name:
/help • Response: "Welcome to the help section! Use /start to begin or /info to learn more about me." 🆘
When a user types
/help, the bot will reply with this predefined text.---
▎Dynamic Response Example Using JavaScript 💻
You can use JavaScript to make responses more dynamic. For example, let’s create a
/greet command that uses the user’s name to greet them:Bot.sendMessage("Hello, " + user.first_name + "! How can I assist you today?");
• Create a command
/greet in the Command Editor. ✨ • Add the above script to the command.
• Save and test it by typing
/greet in your bot’s chat. ✅If the user’s first name is John, the bot will reply:
"Hello, John! How can I assist you today?" 👋
---
▎Handling Custom Inputs 🎨
You can also create commands to handle inputs from users. For instance, let’s create a
/ask command that prompts the user for their favorite color:Bot.sendMessage("What’s your favorite color?");
To handle the user’s reply, you can create another command to capture their response. For example:
Bot.sendMessage("Nice choice! I love that color too.");
---
▎Assignment for Day 2 📚
1. Create a command
/about with the static response: "This is a demo bot created with Bots.Business JavaScript. Stay tuned for more!" 🎊
2. Create a dynamic command
/myname that replies with the user’s name. Use this script: Bot.sendMessage("Hi, " + user.first_name + "! Nice to meet you.");
3. Optional Challenge:
Create a command
/askcolor that asks the user their favorite color and responds dynamically to their input. (Hint: Use a callback command to handle the input.) 🎯---
▎What’s Next? 🔮
Tomorrow, in Day 3, we’ll explore Variables in Bots.Business JavaScript. Variables will allow us to store and manipulate user data to create more personalized and interactive bots. Keep practicing and experimenting! 💪
👍7❤2🔥1
Coding Skill Builder 💪📚(Full AI Based)
Bot.sendMessage("Hi, " + user.first_name + "! Nice to meet you.");
To add both the first name and last name in the message, you can modify the code as follows:
By adding
Bot.sendMessage("Hi, " + user.first_name + " " + user.last_name + "! Nice to meet you.");
By adding
user.last_name next to user.first_name with a space in between, you will include both the first name and last name in the greeting message. This code will now address the user by their first name and last name, making the message more personalized.1❤3👍3
▎Day 3: Using Variables in Bots.Business JavaScript (BJS)
Welcome to Day 3! Today, we’ll dive deeper into using variables in your bot to enhance its interactivity and personalization.
---
▎What Are Variables?
Variables are essential components in programming that allow you to store and manage data. In the context of Bots.Business JavaScript, variables can help you:
• Remember user-specific information: such as names, ages, and preferences.
• Track statistics: like the number of interactions or scores.
• Pass data between commands.
You can store various types of data in variables, including strings (text), numbers, and more.
---
▎How to Use Variables in BJS
1. Declaring a Variable
To create a variable and assign it a value:
2. Using a Variable
You can use the variable to send messages or perform actions:
3. Modifying a Variable
To change the value of a variable:
---
▎Working with User-Specific Variables
In Bots.Business, user-specific data is often managed using
▎Storing Data: User.setProperty()
To store user-specific data:
• key: Unique identifier (e.g., "name", "age").
• value: The data to store (e.g., "John", 25).
• type: The type of data (e.g., "string", "number", "boolean").
Example:
▎Retrieving Data: User.getProperty()
To retrieve stored data:
---
▎Example: Storing and Using a Name
Let’s create two commands:
1. Command: /setname
2. Command: /getname
---
▎Example: Counting User Interactions
You can track how many times a user interacts with your bot using variables.
1. Command: /interact
---
▎Assignment for Day 3
1. Create a command
• Hint: Use
2. Create a command
• Hint: Use
3. Bonus Challenge:
• Create a command
• Hint: Use
---
▎What’s Next?
In Day 4, we will explore conditions (if/else statements) and how to make your bot respond differently based on user input or stored variables. Keep practicing what you’ve learned today, and feel free to share your progress! Happy coding!
Welcome to Day 3! Today, we’ll dive deeper into using variables in your bot to enhance its interactivity and personalization.
---
▎What Are Variables?
Variables are essential components in programming that allow you to store and manage data. In the context of Bots.Business JavaScript, variables can help you:
• Remember user-specific information: such as names, ages, and preferences.
• Track statistics: like the number of interactions or scores.
• Pass data between commands.
You can store various types of data in variables, including strings (text), numbers, and more.
---
▎How to Use Variables in BJS
1. Declaring a Variable
To create a variable and assign it a value:
let myVariable = "Hello, World!";
2. Using a Variable
You can use the variable to send messages or perform actions:
Bot.sendMessage(myVariable);
3. Modifying a Variable
To change the value of a variable:
let myVariable = "Goodbye, World!";
---
▎Working with User-Specific Variables
In Bots.Business, user-specific data is often managed using
User.setProperty and User.getProperty methods.▎Storing Data: User.setProperty()
To store user-specific data:
User.setProperty("key", value, "string");
• key: Unique identifier (e.g., "name", "age").
• value: The data to store (e.g., "John", 25).
• type: The type of data (e.g., "string", "number", "boolean").
Example:
User.setProperty("name", "John", "string");
▎Retrieving Data: User.getProperty()
To retrieve stored data:
let name = User.getProperty("name");
Bot.sendMessage("Your name is: " + name);
---
▎Example: Storing and Using a Name
Let’s create two commands:
/setname to store the user’s name and /getname to retrieve it.1. Command: /setname
// Assume user input is captured in userInput
User.setProperty("name", userInput, "string"); // Replace userInput with actual input
Bot.sendMessage("Your name has been saved!");
2. Command: /getname
let name = User.getProperty("name");
Bot.sendMessage("Your saved name is: " + name);
---
▎Example: Counting User Interactions
You can track how many times a user interacts with your bot using variables.
1. Command: /interact
let count = User.getProperty("interaction_count") || 0; // Default to 0 if not set
count += 1;
User.setProperty("interaction_count", count, "number");
Bot.sendMessage("You have interacted with this bot " + count + " times!");
---
▎Assignment for Day 3
1. Create a command
/saveage that asks the user for their age and stores it in a variable.• Hint: Use
User.setProperty("age", userInput, "number");.2. Create a command
/getage that retrieves and displays the saved age.• Hint: Use
User.getProperty("age");.3. Bonus Challenge:
• Create a command
/reset that clears the saved age and interaction count.• Hint: Use
User.setProperty("key", null); to reset a variable.---
▎What’s Next?
In Day 4, we will explore conditions (if/else statements) and how to make your bot respond differently based on user input or stored variables. Keep practicing what you’ve learned today, and feel free to share your progress! Happy coding!
👍5🔥3
Hey learners! 👋
You've completed 3 days of the Bots.Business learning session. It's time to put your knowledge to the test! 💪
You've completed 3 days of the Bots.Business learning session. It's time to put your knowledge to the test! 💪
1️⃣ What will this script do?
Bot.sendMessage("Hello, " + user.first_name + "!");👍4
3️⃣ What will this code do?
let count = User.getProperty("interaction_count") || 0;
count += 1;
User.setProperty("interaction_count", count, "number");
Bot.sendMessage("You’ve interacted " + count + " times!");👍1
Day 4: Leveraging Conditions (if/else) in Bots.Business JavaScript
Welcome to Day 4 of the 30-Day Bots.Business JavaScript (BJS) Learning Session! So far, we’ve explored commands, variables, and how to store user data. Today, we’re excited to elevate your bot-building skills by introducing conditions. With conditions, your bot can make informed decisions and respond differently based on user input or stored data.
---
▎What Are Conditions?
Conditions enable your bot to evaluate specific scenarios and take appropriate actions. The most common way to implement conditions in BJS is through if/else statements.
---
▎Basic Syntax
---
▎Example 1: Greeting Based on User’s Name
Let’s create a command
---
▎Example 2: Check User's Age
We can utilize conditions to assess a user’s age and provide tailored responses:
Command:
---
▎Example 3: Using Inputs Dynamically
Let’s implement a command that verifies if the user sends a specific input (e.g., a password):
Command:
---
▎Nested Conditions
You can also nest if statements within one another for more complex logic. Here’s an example:
---
▎Assignment for Day 4
1️⃣ Create a command
Utilize a stored variable (e.g.,
• If the user is an admin, send:
"Welcome, Admin! You have full access."
• Otherwise, send:
"Access denied! You are not an admin."
2️⃣ Create a command
Prompt the user for a test score and respond based on the value:
• If the score is 80 or above, reply:
"Great job! You passed!"
• If the score is below 80, reply:
"Keep trying! You can do better!"
3️⃣ Bonus Challenge:
Develop a bot that asks for a user’s favorite number.
• If the number is divisible by 2, respond:
"That’s an even number!"
• If it’s not, respond:
"That’s an odd number!"
---
▎What’s Next?
In Day 5, we’ll delve into Bots.Business Libraries and discover how to enhance your bot’s functionality with pre-built tools such as ResourcesLib, Guard, and more. Keep practicing, and don’t forget to test your bot commands! 🚀
Welcome to Day 4 of the 30-Day Bots.Business JavaScript (BJS) Learning Session! So far, we’ve explored commands, variables, and how to store user data. Today, we’re excited to elevate your bot-building skills by introducing conditions. With conditions, your bot can make informed decisions and respond differently based on user input or stored data.
---
▎What Are Conditions?
Conditions enable your bot to evaluate specific scenarios and take appropriate actions. The most common way to implement conditions in BJS is through if/else statements.
---
▎Basic Syntax
if (condition) {
// Code to execute if the condition is true
} else {
// Code to execute if the condition is false
}
---
▎Example 1: Greeting Based on User’s Name
Let’s create a command
/checkname that checks whether the user’s name is stored and responds accordingly:let name = User.getProperty("name");
if (name) {
Bot.sendMessage("Hello, " + name + "! Welcome back!");
} else {
Bot.sendMessage("I don’t know your name yet. Please set it using /setname.");
}
---
▎Example 2: Check User's Age
We can utilize conditions to assess a user’s age and provide tailored responses:
Command:
/checkagelet age = User.getProperty("age");
if (!age) {
Bot.sendMessage("I don't know your age yet. Use /saveage to set it.");
} else if (age < 18) {
Bot.sendMessage("You’re under 18! Some features might not be available.");
} else {
Bot.sendMessage("You’re 18 or older! Enjoy all the features of this bot.");
}
---
▎Example 3: Using Inputs Dynamically
Let’s implement a command that verifies if the user sends a specific input (e.g., a password):
Command:
/checkpasswordlet userPassword = "secret123"; // Define a password
if (message == userPassword) {
Bot.sendMessage("Access granted! ✅");
} else {
Bot.sendMessage("Access denied! ❌ Incorrect password.");
}
---
▎Nested Conditions
You can also nest if statements within one another for more complex logic. Here’s an example:
let age = User.getProperty("age");
if (age) {
if (age < 18) {
Bot.sendMessage("You’re under 18!");
} else {
Bot.sendMessage("You’re 18 or older!");
}
} else {
Bot.sendMessage("I don’t know your age yet. Use /saveage to set it.");
}
---
▎Assignment for Day 4
1️⃣ Create a command
/checkaccess:Utilize a stored variable (e.g.,
User.getProperty("isAdmin")) to determine if a user is an admin or not.• If the user is an admin, send:
"Welcome, Admin! You have full access."
• Otherwise, send:
"Access denied! You are not an admin."
2️⃣ Create a command
/testscore:Prompt the user for a test score and respond based on the value:
• If the score is 80 or above, reply:
"Great job! You passed!"
• If the score is below 80, reply:
"Keep trying! You can do better!"
3️⃣ Bonus Challenge:
Develop a bot that asks for a user’s favorite number.
• If the number is divisible by 2, respond:
"That’s an even number!"
• If it’s not, respond:
"That’s an odd number!"
---
▎What’s Next?
In Day 5, we’ll delve into Bots.Business Libraries and discover how to enhance your bot’s functionality with pre-built tools such as ResourcesLib, Guard, and more. Keep practicing, and don’t forget to test your bot commands! 🚀
👍5❤1
Day 5: Introduction to Bots.Business Libraries
Welcome to Day 5 of the 30-Day Bots.Business JavaScript (BJS) Learning Session! Today, we’re diving into one of the most powerful features of Bots.Business: Libraries. These pre-built tools simplify the process of extending your bot’s functionality and incorporating advanced features without the need to code everything from scratch.
---
What Are Bots.Business Libraries?
Libraries in Bots.Business consist of pre-designed scripts that offer specific features or tools for your bots. Rather than manually coding complex functionalities, you can leverage libraries to efficiently manage tasks such as user resource management, bot protection, or data synchronization with external applications.
---
Popular Libraries in Bots.Business
Here are some commonly utilized libraries you’ll be working with:
1. ResourcesLib
This library assists in managing user resources like coins, points, energy, etc.
Example: Track how many virtual coins a user possesses.
2. Guard
This library safeguards your bot from spammers and abusive behaviors.
Example: Limit the frequency with which a command can be executed within a specified timeframe.
3. CooldownLib
This library establishes cooldown periods for commands.
Example: Prevent users from executing a command too frequently.
4. DatetimeFormatLib
This library formats and handles dates and times.
Example: Display the current date in a user-friendly format.
5. TopBoardLib
This library tracks leaderboards for competitive features.
Example: Showcase the top 10 users based on their points.
---
How to Use Libraries
Libraries come pre-installed in Bots.Business. To utilize one:
1. Include the library in your bot by adding its script at the top of your command.
2. Employ the library’s methods within your bot’s code.
For instance, to utilize the ResourcesLib, you would write:
This code creates a resource called "coins" for each user.
---
Example 1: ResourcesLib (User Resources)
Let’s develop a system to manage virtual coins for users.
Command 1: /addcoins
Add coins to the user’s account:
Command 2: /checkcoins
Check the user’s current coin balance:
Command 3: /spendcoins
Spend coins if the user has enough:
---
Example 2: CooldownLib
Cooldowns ensure that users can’t spam a command repeatedly.
Command: /claimreward
Allow users to claim a reward only once every 24 hours:
---
Example 3: TopBoardLib (Leaderboard)
Create a leaderboard to track user scores.
Command 1: /addscore
Add a user’s score to the leaderboard:
Command 2: /leaderboard
Show the top 5 users:
Welcome to Day 5 of the 30-Day Bots.Business JavaScript (BJS) Learning Session! Today, we’re diving into one of the most powerful features of Bots.Business: Libraries. These pre-built tools simplify the process of extending your bot’s functionality and incorporating advanced features without the need to code everything from scratch.
---
What Are Bots.Business Libraries?
Libraries in Bots.Business consist of pre-designed scripts that offer specific features or tools for your bots. Rather than manually coding complex functionalities, you can leverage libraries to efficiently manage tasks such as user resource management, bot protection, or data synchronization with external applications.
---
Popular Libraries in Bots.Business
Here are some commonly utilized libraries you’ll be working with:
1. ResourcesLib
This library assists in managing user resources like coins, points, energy, etc.
Example: Track how many virtual coins a user possesses.
2. Guard
This library safeguards your bot from spammers and abusive behaviors.
Example: Limit the frequency with which a command can be executed within a specified timeframe.
3. CooldownLib
This library establishes cooldown periods for commands.
Example: Prevent users from executing a command too frequently.
4. DatetimeFormatLib
This library formats and handles dates and times.
Example: Display the current date in a user-friendly format.
5. TopBoardLib
This library tracks leaderboards for competitive features.
Example: Showcase the top 10 users based on their points.
---
How to Use Libraries
Libraries come pre-installed in Bots.Business. To utilize one:
1. Include the library in your bot by adding its script at the top of your command.
2. Employ the library’s methods within your bot’s code.
For instance, to utilize the ResourcesLib, you would write:
let resource = Libs.ResourcesLib.userRes("coins");
This code creates a resource called "coins" for each user.
---
Example 1: ResourcesLib (User Resources)
Let’s develop a system to manage virtual coins for users.
Command 1: /addcoins
Add coins to the user’s account:
let coins = Libs.ResourcesLib.userRes("coins");
coins.add(10); // Adds 10 coins
Bot.sendMessage("You have been given 10 coins! Total coins: " + coins.value());
Command 2: /checkcoins
Check the user’s current coin balance:
let coins = Libs.ResourcesLib.userRes("coins");
Bot.sendMessage("Your total coins: " + coins.value());
Command 3: /spendcoins
Spend coins if the user has enough:
let coins = Libs.ResourcesLib.userRes("coins");
if (coins.have(5)) {
coins.remove(5);
Bot.sendMessage("You spent 5 coins! Remaining coins: " + coins.value());
} else {
Bot.sendMessage("You don’t have enough coins!");
}
---
Example 2: CooldownLib
Cooldowns ensure that users can’t spam a command repeatedly.
Command: /claimreward
Allow users to claim a reward only once every 24 hours:
let cooldown = Libs.CooldownLib;
if (!cooldown.checkCooldown("daily_reward")) {
Bot.sendMessage("You’ve already claimed your reward today. Try again later.");
return;
}
cooldown.setCooldown("daily_reward", 24 * 60 * 60); // 24 hours in seconds
Bot.sendMessage("You’ve claimed your daily reward!");
---
Example 3: TopBoardLib (Leaderboard)
Create a leaderboard to track user scores.
Command 1: /addscore
Add a user’s score to the leaderboard:
let leaderboard = Libs.TopBoardLib;
leaderboard.addUser("game_scores", user.telegramid, 100); // Adds 100 points
Bot.sendMessage("You’ve been awarded 100 points!");
Command 2: /leaderboard
Show the top 5 users:
let leaderboard = Libs.TopBoardLib;
let top = leaderboard.getTop("game_scores", 5);
Bot.sendMessage("Top 5 Users:\n" + top);
👍4
Coding Skill Builder 💪📚(Full AI Based)
Day 5: Introduction to Bots.Business Libraries Welcome to Day 5 of the 30-Day Bots.Business JavaScript (BJS) Learning Session! Today, we’re diving into one of the most powerful features of Bots.Business: Libraries. These pre-built tools simplify the process…
▎Assignment for Day 5 🎉
1. Create a Coin System: 💰
Implement commands /addcoins, /checkcoins, and /spendcoins using ResourcesLib.
Bonus: Introduce a feature allowing users to gift coins to other users. 🎁
2. Set Up a Cooldown Command: ⏳
Create a command /dailybonus that grants users 50 coins but only once every 24 hours. 🌟
3. Create a Leaderboard: 📊
Utilize TopBoardLib to track and display a leaderboard of user points. 🏆
1. Create a Coin System: 💰
Implement commands /addcoins, /checkcoins, and /spendcoins using ResourcesLib.
Bonus: Introduce a feature allowing users to gift coins to other users. 🎁
2. Set Up a Cooldown Command: ⏳
Create a command /dailybonus that grants users 50 coins but only once every 24 hours. 🌟
3. Create a Leaderboard: 📊
Utilize TopBoardLib to track and display a leaderboard of user points. 🏆
❤1👍1