Bot Features and Functionalities
6. Bot Features and Functionalities
This section dives into the various features and functionalities available in Telebot Creator, showing how to apply them effectively in real-world scenarios. From handling user interactions to automating tasks and broadcasting messages, these features enable you to build bots that are both powerful and versatile.
6.1 Wildcard Master Command (*
)
*
)The *
command, also known as the Wildcard Master Command, is triggered when a bot receives a message that does not match any predefined command. This is useful for handling fallback responses or processing unexpected user inputs.
Use Cases:
Providing default responses.
Logging unknown commands for debugging.
Example:
6.2 At Handler Command (@
)
@
)The @
command runs before any other command is executed. It’s primarily used for preprocessing messages, logging user activity, or setting up global conditions.
Use Cases:
Validating messages before they are processed by other commands.
Logging user activities.
Example:
6.3 Broadcasting Messages
The broadcasting feature allows you to send a message or execute a command for multiple users simultaneously.
Key Functions:
broadcast
: Sends a message or runs a command for a group of users.clearBroadcast
: Clears records of completed broadcasts.
Example:
Advanced Example with Commands:
6.4 Captcha Generation and Validation
Telebot Creator supports automatic and manual CAPTCHA generation to ensure security during user interactions.
Key Functions:
genCaptcha
: Generates a CAPTCHA.validateCaptcha
: Validates user responses to the CAPTCHA.
Example:
6.5 Error Handling and Debugging
Telebot Creator includes robust error-handling tools to debug and track issues in your bot.
Features:
Error Logs: Access error logs from the dashboard under the Errors menu.
Try-Catch Blocks: Use exception handling in TPY to manage errors gracefully.
Example:
6.6 Persistent Data Storage
Use saveData
and getData
to store and retrieve global data for your bot.
Use Cases:
Tracking user progress.
Storing settings or configurations.
Example:
6.7 Scheduled Commands
Schedule commands to run after a specified delay using runCommandAfter
.
Use Cases:
Sending reminders.
Automating periodic tasks.
Example:
In the send_reminder
command:
6.8 Webhook Integration
Webhooks allow your bot to receive real-time updates or trigger commands based on external events.
Key Functions:
getUrlFor
: Generates a webhook URL for a specific command.
Example:
6.9 CSV File Management
Use the libs.CSV
library to manage data in CSV files, such as tracking user activity or creating leaderboards.
Example:
6.10 Real-Time User Points
The left_points
global variable tracks the remaining points for executing commands.
Example:
6.11 Multi-Step User Interactions
Telebot Creator enables seamless multi-step user interactions using commands like handleNextCommand
. This feature allows you to guide users through a sequence of questions or tasks.
Use Cases:
Collecting user information step-by-step.
Creating interactive forms or surveys.
Example: Collecting User Details Step 1: Ask for the user's name.
Step 2: Process the name and ask for the email.
Step 3: Process the email and confirm.
6.12 Dynamic Message Replies
Telebot Creator allows bots to provide dynamic responses using variables and user-specific data.
Use Cases:
Greeting users by their name.
Sending personalized notifications.
Example:
6.13 Inline Keyboard and Buttons
You can create interactive inline keyboards and buttons for your bot using TPY.
Use Cases:
Providing quick action buttons.
Navigating through menus.
Example: Inline Keyboard
Handling Button Clicks:
6.14 Using the Random Library
The libs.Random
library allows you to generate random outputs for lotteries, giveaways, or dynamic bot interactions.
Use Cases:
Picking random winners.
Generating unique codes.
Example: Generating a Random Number
Example: Generating a Random String
6.15 User Resource Management
Manage user-specific resources such as points, credits, balance or quotas using the libs.Resources
library.
Use Cases:
Awarding points for user actions.
Tracking balances for memberships or services.
Example:
6.16 Advanced Broadcasting Options
Broadcasting messages to users can be fine-tuned with custom commands or targeting specific groups.
Use Cases:
Sending promotions to active users.
Notifying specific users about updates.
Advanced Example: Custom Command Broadcast
Targeted Broadcasts:
6.17 Debugging Features
Debugging is essential for ensuring your bot functions as expected. Telebot Creator provides multiple tools for error handling and tracking.
Tools Available:
Errors Menu:
Access error logs directly from the dashboard.
Try-Except Handling:
Use Python-style error handling to catch and manage exceptions.
Example:
6.18 Automation with Webhooks
Webhooks enable your bot to react to external events in real-time, such as receiving payments or triggering commands based on third-party API updates.
Use Cases:
Automating responses to external triggers.
Integrating with payment gateways or external systems.
Example: Generating a Webhook URL
6.19 Managing Scheduled Tasks
With runCommandAfter
, you can schedule tasks to execute at a later time.
Use Cases:
Sending periodic reminders.
Automating recurring updates.
Example:
In the reminder_task
command:
6.20 Combining Features for Complex Bots
By combining these features, you can create highly interactive and functional bots.
Example: Multi-Feature Use Case
A bot that collects user information, awards points, and broadcasts updates:
In the get_name
command:
In the send_update
command:
6.21 Example Scenarios for Real-World Use Cases
1. Referral System
Track and reward users for referring others to your bot.
Workflow:
User Shares Referral Link:
Generate a unique referral link using
params
in the/start
command.
Track Referrals:
When a new user joins using the link, log the referrer.
Reward Top Referrers:
Use
libs.Resources.userRes
to fetch the top contributors.
2. Event Reminder Bot
Let users set reminders for specific dates and times.
Workflow:
Collect Event Details:
Ask for the Date and Time:
Schedule the Reminder:
Send the Reminder:
6.22 Integration Highlights
Fetching External Data with libs.customHTTP
Integrate your bot with external APIs to provide dynamic content.
Example: Fetching Weather Data
6.24 Feature Customization Options
Custom Inline Keyboards
Create dynamic options for users.
6.25 Common Mistakes and Solutions
Mistake
Solution
Incorrectly scheduling commands.
Ensure the time delay for runCommandAfter
is accurate and positive.
Resource mismanagement (e.g., points).
Use libs.Resources
consistently to avoid overwriting or losing data.
Webhook not triggering.
Verify the webhook URL and ensure the command exists in your bot.
6.26 Debugging with Logs
Access Logs via the Dashboard:
Use the Errors menu to view logs for failed commands or system issues.
Inline Logging:
Last updated