{
"platform": {
"name": "Bots.Business",
"owner": "Kaiiddo",
"contact": "@kaiiddo (Telegram)",
"purpose": "Create and manage Telegram bots with tools for automation, user interaction, and integrations.",
"features": {
"core_features": [
"Simplified bot creation with BJS (Bots.Business JavaScript)",
"Message broadcasting and editing",
"Always-running commands (e.g., * for Master Command, @ for BeforeAll)",
"API integration (e.g., send photos, audio, fetch user data)",
"Admin panel for bot management"
],
{
"BJS_Global_Variables": [
{
"variable": "request",
"description": "Collection containing extensive data. Use `Bot.inspect(request)` to view all fields. Tracks all updates.",
"fields": "All fields are nested under `request`."
},
{
"variable": "message",
"description": "Current message from the user (string)."
},
{
"variable": "user",
"description": "User who sent a command or text.",
"fields": [
"id (Bots.Business ID)",
"telegramid (Telegram ID)",
"first_name (can be blank)",
"last_name (can be blank)",
"username (can be blank)",
"created_at",
"updated_at",
"just_created (true for new users never seen in Bots.Business; false otherwise)"
]
},
{
"variable": "chat",
"description": "Data for the current chat.",
"fields": [
"id (Bots.Business ID)",
"chatid (Telegram chat ID)",
"bot_id",
"title",
"chat_type (values: 'private', 'group', 'supergroup')",
"user_id",
"created_at",
"updated_at",
"just_created (true for new chats; resets if a blocked chat is reused after 6 months)"
]
},
{
"variable": "bot",
"description": "Data for the bot.",
"fields": [
"id",
"name",
"token",
"created_at",
"updated_at",
"csv_url",
"last_run_at",
"store_bot_id",
"status"
]
},
{
"variable": "command",
"description": "Data for the executed command.",
"fields": [
"id",
"name",
"folder",
"need_reply",
"auto_retry_time",
"last_auto_retry_at",
"created_via_csv_import",
"last_csv_import_at",
"created_at",
"updated_at"
]
},
{
"variable": "params",
"description": "Command parameters (plain text)."
},
{
"variable": "owner",
"description": "Bot owner information (e.g., email, ID)."
},
{
"variable": "completed_commands_count",
"description": "Number of previously completed commands via `Bot.runCommand`. Used for security checks."
},
{
"variable": "iteration_quota",
"description": "Current quota details (limit, progress, etc.). Example: `Bot.sendMessage(inspect(iteration_quota))`."
},
{
"variable": "payment_plan",
"description": "Bot owner's payment plan information."
},
{
"variable": "BB_API_URL",
"description": "API URL (e.g., `api.bots.business`). Varies by cloud environment."
}
]
},
{
"functions": {
"bot_functions": [
{
"name": "Bot.sendMessage",
"syntax": "Bot.sendMessage('Hello, user!')",
"purpose": "Send a message to the current chat using markdown formatting by default. See more for advanced usage."
},
{
"name": "Api.sendMessage",
"syntax": "Api.sendMessage({ text: 'Hello, <b>World!</b>', parse_mode: 'HTML' })",
"purpose": "Use the Telegram Bot API to send messages with customizable parameters like text, reply_markup, and parse_mode. Chat ID defaults to the current chat (chat.chatid)."
},
{
"name": "Bot.runCommand",
"syntax": "Bot.runCommand('command_name', { param1: 'value', param2: 'value' })",
"purpose": "Trigger another command with parameters."
},
{
"name": "Bot.run",
"syntax": "Bot.run({ command: '/balance', run_after: 3600, options: { ... } })",
"purpose": "Run another command with parameters and optional scheduling/background execution."
},
{
"name": "Bot.clearRunAfter",
"syntax": "Bot.clearRunAfter({ label: 'myLabel' })",
"purpose": "Clear future executions of commands scheduled with Bot.run, optionally by label."
},
{
"name": "Bot.runAll",
"syntax": "Bot.runAll({ command: '/broadcast', for_chats: 'private-chats' })",
"purpose": "Execute a command across all chats (private, groups, etc.) for mass communication."
},
{
"name": "Bot.sendKeyboard",
"syntax": "Bot.sendKeyboard('button1, button2', 'Message text')",
"purpose": "Send a keyboard with buttons and a message to the current chat."
},
{
"name": "Bot.sendInlineKeyboard",
"syntax": "Bot.sendInlineKeyboard([ {title: 'Google', url: '...'}, ... ], 'Choose an option')",
"purpose": "Send an inline keyboard with clickable buttons to the current chat."
},
{
"name": "Bot.editInlineKeyboard",
"syntax": "Bot.editInlineKeyboard([ {title: 'New Button', command: '/cmd'} ])",
"purpose": "Edit an existing inline keyboard after a command is triggered by a button."
},
{
"name": "Bot.editMessage",
"syntax": "Bot.editMessage('new text', 20)",
"purpose": "Edit a message in the current chat using its message ID. Use `request.message_id` for incoming messages."
},
{
"name": "Api.editMessageText",
"syntax": "Api.editMessageText({ text: 'Updated!', message_id: 20 })",
"purpose": "Advanced method to edit message text via the Telegram API. Supports parameters like `parse_mode` and `reply_markup`."
},
{
"name": "Api.deleteMessage",
"syntax": "Api.deleteMessage({ message_id: 20 })",
"purpose": "Delete a message by its unique message ID. Use with `Bot.run` to schedule deletions."
},
{
"name": "Bot.setProp",
"syntax": "Bot.setProp('name', value, 'type')",
"purpose": "Store a property for the bot with optional type specification (e.g., integer, string)."
},
{
"name": "Bot.getProp",
"syntax": "Bot.getProp('name', defaultValue)",
"purpose": "Retrieve a bot property, with optional default value or access to another bot's properties."
},
{
"name": "Bot.deleteProp",
"syntax": "Bot.deleteProp('name')",
"purpose": "Remove a stored bot property by name."
},
{
"name": "Bot.importCSV",
"syntax": "Bot.importCSV()",
"purpose": "Import data from a CSV file. See documentation for details."
},
{
"name": "Bot.blockChat",
"syntax": "Bot.blockChat(chat.id)",
"purpose": "Block a specific chat by ID."
},
{
"name": "Bot.unblockChat",
"syntax": "Bot.unblockChat(chat.id)",
"purpose": "Unblock a previously blocked chat by ID."
},
{
"name": "Bot.inspect",
"syntax": "Bot.inspect(value)",
"purpose": "Send a debug message with the inspected value to the chat for troubleshooting."
}
],
{
},
{
"name": "Bot.runAll",
"syntax": "Bot.runAll({ command: '/broadcast', for_chats: 'private-chats' })",
"purpose": "Execute a command across all chats (private, groups, etc.) for mass communication."
},
{
"name": "Bot.sendKeyboard",
"syntax": "Bot.sendKeyboard('button1, button2', 'Message text')",
"purpose": "Send a keyboard with buttons and a message to the current chat."
},
{
"name": "Bot.sendInlineKeyboard",
"syntax": "Bot.sendInlineKeyboard([ {title: 'Google', url: '...'}, ... ], 'Choose an option')",
"purpose": "Send an inline keyboard with clickable buttons to the current chat."
},
{
"name": "Bot.editInlineKeyboard",
"syntax": "Bot.editInlineKeyboard([ {title: 'New Button', command: '/cmd'} ])",
"purpose": "Edit an existing inline keyboard after a command is triggered by a button."
},
{
"name": "Bot.editMessage",
"syntax": "Bot.editMessage('new text', 20)",
"purpose": "Edit a message in the current chat using its message ID. Use `request.message_id` for incoming messages."
},
{
"name": "Api.editMessageText",
"syntax": "Api.editMessageText({ text: 'Updated!', message_id: 20 })",
"purpose": "Advanced method to edit message text via the Telegram API. Supports parameters like `parse_mode` and `reply_markup`."
},
{
"name": "Api.deleteMessage",
"syntax": "Api.deleteMessage({ message_id: 20 })",
"purpose": "Delete a message by its unique message ID. Use with `Bot.run` to schedule deletions."
},
{
"name": "Bot.importCSV",
"syntax": "Bot.importCSV()",
"purpose": "Import data from a CSV file. See documentation for details."
},
{
"name": "Bot.blockChat",
"syntax": "Bot.blockChat(chat.id)",
"purpose": "Block a specific chat by ID."
},
{
"name": "Bot.unblockChat",
"syntax": "Bot.unblockChat(chat.id)",
"purpose": "Unblock a previously blocked chat by ID."
},
{
"name": "Bot.inspect",
"syntax": "Bot.inspect(value)",
"purpose": "Send a debug message with the inspected value to the chat for troubleshooting."
},
{
"name": "HTTP.get",
"syntax": "HTTP.get({ url: 'http://example.com', success: '/onLoading', error: '/onError', headers: { ... }, follow_redirects: true, background: true })",
"purpose": "Send an HTTP GET request. Specify `success` and `error` commands to handle responses. Use `background: true` for slow requests. Default `Content-Type` is `application/json`; set `headers: { 'content-type': null }` if needed."
},
{
"name": "HTTP.post",
"syntax": "HTTP.post({ url: 'http://example.com', success: '/onLoading', error: '/onError', body: { ... }, headers: { ... }, follow_redirects: true })",
"purpose": "Send an HTTP POST request with a body payload. Specify `success` and `error` commands to handle responses. Adjust headers as needed."
},
{
"name": "HTTP.put",
"syntax": "HTTP.put({ url: 'http://example.com', success: '/onLoading', error: '/onError', body: { ... }, headers: { ... } })",
"purpose": "Send an HTTP PUT request with a body payload. Specify `success` and `error` commands to handle responses."
},
{
"name": "HTTP.delete",
"syntax": "HTTP.delete({ url: 'http://example.com', success: '/onLoading', error: '/onError', headers: { ... } })",
"purpose": "Send an HTTP DELETE request. Specify `success` and `error` commands to handle responses."
},
{
"name": "HTTP.options",
"syntax": "HTTP.options({ url: 'http://example.com', success: '/onLoading', error: '/onError', headers: { ... } })",
"purpose": "Send an HTTP OPTIONS request. Specify `success` and `error` commands to handle responses."
}
],
"user_functions": [
{
"name": "User.setProp",
"syntax": "User.setProp('city', 'London')",
"purpose": "Store a user-specific property with an optional type (e.g., integer, float, string, text, json, datetime). Example: `User.setProp('age', 25, 'integer')`."
},
{
"name": "User.getProp",
"syntax": "User.getProp('city', 'London')",
"purpose": "Retrieve a user property. Accepts a default value if the property doesn’t exist. Example: `User.getProp('city', 'New York')`."
},
{
"name": "User.deleteProp",
"syntax": "User.deleteProp('city')",
"purpose": "Delete a user property by name."
},
{
"name": "User.addToGroup",
"syntax": "User.addToGroup('guests')",
"purpose": "Add the user to a specified group (e.g., 'guests')."
},
{
"name": "User.getGroup",
"syntax": "User.getGroup()",
"purpose": "Get the current user’s group."
},
{
"name": "User.removeGroup",
"syntax": "User.removeGroup()",
"purpose": "Remove the user from their current group."
}
]
},
"security": {
"best_practices": [
"Restrict admin commands using User.getGroup() === 'admin'",
"Avoid exposing bot tokens or API keys",
"Use unique command names (e.g., /start_campaign instead of /start)"
],
"example_checks": [
"if (user.telegramid !== 12345) Bot.sendMessage('Access denied!');"
]
}
},
"libraries": {
"referral_lib": {
},
{
"name": "RefLib.getLink",
"syntax": "RefLib.getLink([botName], [linkPrefix])",
"purpose": "Generate a referral link for the current user.",
"example": {
"code": "const link = RefLib.getLink(bot.name, 'r'); // Example: t.me/bot?start=rUSER_ID",
"description": "Create a referral link with a custom prefix."
}
},
{
"name": "RefLib.getAttractedBy",
"syntax": "RefLib.getAttractedBy()",
"purpose": "Retrieve the user who referred the current user.",
"example": {
"code": "const referrer = RefLib.getAttractedBy();",
"description": "Get the referrer’s user data."
}
},
{
"name": "RefLib.clearRef",
"syntax": "RefLib.clearRef()",
"purpose": "Reset referral data for testing purposes.",
"example": {
"code": "RefLib.clearRef(); // Clear referral data for the current user",
"description": "Simulate a new user experience."
}
},
{
"name": "RefLib.getRefList",
"syntax": "RefLib.getRefList([userId])",
"purpose": "Get the list of users referred by the current user or another user.",
"example": {
"code": "const refList = RefLib.getRefList();\nconst users = refList.getUsers();",
"description": "Retrieve and display referred users."
}
},
{
"name": "RefLib.getRefCount",
"syntax": "RefLib.getRefCount([userId])",
"purpose": "Get the total number of referrals for the current user or another user.",
"example": {
"code": "const count = RefLib.getRefCount();",
"description": "Display the referral count."
}
},
{
"name": "RefLib.getTopList",
"syntax": "RefLib.getTopList()",
"purpose": "Get a list of top referrers, sortable and paginatable.",
"example": {
"code": "const topList = RefLib.getTopList();\ntopList.order_by = 'value';\nconst topUsers = topList.get();",
"description": "Sort and display top referrers."
}
}
],
"use_cases": [
"Airdrop campaigns: Reward users for inviting friends.",
"Affiliate programs: Share 5% of revenue with referrers.",
"Loyalty programs: Offer bonuses based on referral counts.",
"Leaderboards: Display top referrers in a public board."
]
},
"resources_lib": {
"name": "Resource.growth.add",
"syntax": "resource.growth.add({ value: number, interval: seconds, max?: number, min?: number, max_iterations_count?: number })",
"example": {
"code": "health.growth.add({ value: 5, interval: 10 }); // Add 5 every 10 seconds",
"purpose": "Configure resource growth with intervals and limits."
}
},
{
"name": "Resource.growth.addPercent",
"syntax": "resource.growth.addPercent({ value: percentage, interval: seconds })",
"example": {
"code": "usd.growth.addPercent({ value: 10, interval: 60 * 60 * 24 * 365 }); // 10% yearly growth",
"purpose": "Apply percentage-based growth to resources."
}
},
{
"name": "Resource.growth.addCompoundInterest",
"syntax": "resource.growth.addCompoundInterest({ value: percentage, interval: seconds })",
"example": {
"code": "btc.growth.addCompoundInterest({ value: 0.8, interval: 60 * 60 * 24 }); // 0.8% daily compound interest",
"purpose": "Implement compound interest for exponential growth."
}
},
{
"name": "Resource.transferTo",
"syntax": "resource.transferTo(targetResource, amount)",
"example": {
"code": "gold.transferTo(anotherUserGold, 10); // Transfer 10 gold to another user",
"purpose": "Transfer resources between users or chats safely."
}
},
{
"name": "Resource.takeFromAnother",
"syntax": "resource.takeFromAnother(sourceResource, amount)",
"example": {
"code": "gold.takeFromAnother(anotherUserGold, 10); // Take 10 gold from another user",
"purpose": "Withdraw resources from another user if sufficient funds exist."
}
}
],
"use_cases": [
"Daily Bonuses: Automatically add resources to users every 24 hours.",
"In-Game Economies: Track gold,木材, and stone for games.",
"Compound Interest: Simulate investment growth with percentage-based returns.",
"Cooldown Systems: Limit action frequency using negative growth (e.g., 5-hour cooldown).",
"Referral Bonuses: Transfer 5% of a referral’s deposit to the referrer.",
"Multi-User Balances: Manage unique balances for each chat and user."
]
},
"methods": [
"example": {
"code": "// Use in before-all command\nif (chat?.chat_type == 'private') {\n Libs.MembershipChecker.handle();\n}",
"purpose": "Check memberships with a delay (configurable via admin panel)."
}
},
{
"name": "Libs.MembershipChecker.isMember(chat_id)",
"syntax": "Libs.MembershipChecker.isMember([chat_id])",
"example": {
"code": "const isMember = Libs.MembershipChecker.isMember('@channel1');",
"purpose": "Check if the user is a member of specified or all required resources."
}
},
{
"name": "Libs.MembershipChecker.getChats()",
"syntax": "Libs.MembershipChecker.getChats()",
"example": {
"code": "const channels = Libs.MembershipChecker.getChats();",
"purpose": "Retrieve all configured membership resources (groups/channels)."
}
},
{
"name": "Libs.MembershipChecker.getNotJoinedChats()",
"syntax": "Libs.MembershipChecker.getNotJoinedChats()",
"example": {
"code": "const missing = Libs.MembershipChecker.getNotJoinedChats();",
"purpose": "List resources the user hasn’t joined yet."
}
}
],
"use_cases": [
"Require membership to use the bot (e.g., premium features).",
"Automate welcome messages when users join required channels.",
"Display remaining required channels in a `/check` command.",
"Limit bot access until all membership requirements are met."
],
"notes": [
"Background checks reduce user wait time but consume iterations.",
"Use `handle()` in before-all commands for automatic checks.",
"Avoid frequent manual checks (use `check()` with cooldowns)."
]
}
},
"templates": {
"admin_panel": {
"example": {
"code": "AdminPanel.setPanel({ panel_name: 'config', data: { fields: [{ name: 'welcome_message', type: 'text' }] } })",
"purpose": "Configure bot settings via an admin interface."
}
},
"always_running_commands": {
"master_command": {
"code": "function *masterCommand() { if (message === '/start') Bot.runCommand('welcome'); }"
}
}
},
"troubleshooting": {
"common_issues": [
{
"error": "Command not executing",
"solution": "Check Bot.runCommand syntax and ensure the command exists."
},
{
"error": "API timeout",
"solution": "Verify BB_API_URL and network connectivity."
}
]
},
"additional_resources": {
"documentation": "https://bots.business/docs",
"support": "Contact @kaiiddo for urgent issues."
}
}
Comments
Post a Comment