Forwarded from Goddy BJS
Command- /ban
Command- /collectUserId
Wait for answer- on
Command- /banUser
Command- Place ontop any command
function startBanProcess() {
var adminId = 1399031414; // Only allow this user ID to execute the command
if (user.telegramid != adminId) {
Bot.sendMessage("You are not authorized to use this command.");
return; // Stop further execution
}
Bot.sendMessage("Please provide the User ID of the person you want to ban.");
Bot.runCommand("/collectUserId"); // Move to the next step to collect the user ID
}
startBanProcess();
Command- /collectUserId
Wait for answer- on
function collectUserId() {
var adminId = 1399031414; // Only allow this user ID to execute the command
if (user.telegramid != adminId) {
Bot.sendMessage("You are not authorized to use this command.");
return; // Stop further execution
}
var userId = message; // The entered user ID from the admin
// Save the user ID for the next step
User.setProperty("ban_user_id", userId, "integer");
// Show inline keyboard with ban durations
Bot.sendInlineKeyboard(
[
[{ title: "1 minute", command: "/banUser 60" }, { title: "15 minutes", command: "/banUser 900" }],
[{ title: "30 minutes", command: "/banUser 1800" }, { title: "1 hour", command: "/banUser 3600" }],
[{ title: "6 hours", command: "/banUser 21600" }, { title: "12 hours", command: "/banUser 43200" }]
],
"Choose the ban duration for user: " + userId
);
}
collectUserId();
Command- /banUser
function banUser() {
var adminId = 1399031414; // Only allow this user ID to execute the command
if (user.telegramid != adminId) {
Bot.sendMessage("You are not authorized to use this command.");
return; // Stop further execution
}
var duration = params; // The duration in seconds passed by the inline button
var userId = User.getProperty("ban_user_id"); // Get the stored user ID
var currentTime = Date.now(); // Current time in milliseconds
// Store the ban information with the end time
var banEndTime = currentTime + (duration * 1000); // Convert duration to milliseconds
Bot.setProperty("ban_" + userId, banEndTime, "integer");
Bot.sendMessage("User [" + userId + "](tg://user?id=" + userId + ") has been banned for " + (duration / 60) + " minutes.");
}
banUser();
Command- Place ontop any command
// Function to check if the user is banned
function checkIfBanned() {
var banEndTime = Bot.getProperty("ban_" + user.telegramid);
if (banEndTime) {
var currentTime = Date.now(); // Get the current time in milliseconds
// Check if the current time is less than the ban end time (i.e., user is still banned)
if (currentTime < banEndTime) {
var remainingTime = Math.round((banEndTime - currentTime) / 1000 / 60); // Calculate remaining ban time in minutes
Bot.sendMessage("You are banned from using this bot for another " + remainingTime + " minutes.");
return true; // User is banned
} else {
// The ban has expired, remove the ban entry
Bot.setProperty("ban_" + user.telegramid, null);
}
}
return false; // User is not banned
}
// Main function that handles content upload
function handleUpload() {
// Check if the user is banned before proceeding
if (checkIfBanned()) {
return; // Stop further execution if the user is banned
}
Forwarded from Goddy BJS
Link Detect on Group Chat
Command- *
Command- *
// Function to check if a message contains a link
function containsLink(message) {
// Simple regex to detect URLs in the message
var urlPattern = /https?:\/\/[^\s]+/gi;
return urlPattern.test(message);
}
// Check if the incoming message contains a link
if (containsLink(message)) {
// Delete the message if it contains a link
Api.deleteMessage({
chat_id: chat.chatid, // the chat ID (group ID)
message_id: request.message_id // the message ID to delete
});
// Optionally, send a warning message to the group or user
Bot.sendMessage("Links are not allowed in this group. Your message has been deleted.");
}
Forwarded from Goddy BJS
User Name Change Notifier
Command- *
Command- *
// Get the current name of the user
var currentName = user.first_name;
// Retrieve the stored name from the user properties
var storedName = User.getProperty("storedName");
// If the stored name exists and it's different from the current name, notify the group
if (storedName && storedName !== currentName) {
// Send a message to the group notifying about the name change
Bot.sendMessage("User " + user.telegramid + " changed their name from '" + storedName + "' to '" + currentName + "'.");
// Update the stored name with the new name
User.setProperty("storedName", currentName, "string");
} else if (!storedName) {
// If there's no stored name yet, store the current name for future comparisons
User.setProperty("storedName", currentName, "string");
}
// The rest of the bot functionality (e.g., sending a normal message)
Bot.sendMessage("Hello, " + currentName + "! Welcome to the group.");
Forwarded from Goddy BJS
Link Masking BJS
Command- /get
Command- /mask
Command- /get
// Command to trigger the masking process
Bot.sendMessage("Send me the URL and the anchor text like this: \n\n /mask http://example.com YourAnchorText");
Command- /mask
var input = params;
if (!input || input.split(' ').length < 2) {
Bot.sendMessage("Please provide a valid URL and anchor text. Example: \n\n /mask http://example.com YourAnchorText");
return;
}
// Extract URL and anchor text from the input
var url = input.split(' ')[0];
var anchorText = input.split(' ').slice(1).join(' ');
// Create a masked link using Markdown
var maskedLink = "[" + anchorText + "](" + url + ")";
// Send the masked link
Bot.sendMessage("Here is your masked link: \n" + maskedLink);
Forwarded from Goddy BJS
Subscription Control BJS
Command- /activatepremium
Command- /checkpremium
Command- /activatepremium
var subscriptionDuration = 7 * 24 * 60 * 60 * 1000; // 7 days
var premiumStatus = User.getProperty("premiumStatus");
var premiumExpire = User.getProperty("premiumExpire");
if (premiumStatus && premiumExpire > Date.now()) {
Bot.sendMessage("You already have a premium subscription active until: " + new Date(premiumExpire).toLocaleString());
return;
}
User.setProperty("premiumStatus", true, "boolean");
var expireTime = Date.now() + subscriptionDuration;
User.setProperty("premiumExpire", expireTime, "integer");
Bot.sendMessage("Premium service activated! It will expire on: " + new Date(expireTime).toLocaleString());
Command- /checkpremium
var premiumExpire = User.getProperty("premiumExpire");
if (!premiumExpire || premiumExpire <= Date.now()) {
Bot.sendMessage("You do not have an active premium subscription.");
return;
}
var remainingTime = premiumExpire - Date.now();
var daysLeft = Math.floor(remainingTime / (24 * 60 * 60 * 1000));
var hoursLeft = Math.floor((remainingTime % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000));
Bot.sendMessage("Your premium subscription is active. Remaining time: " + daysLeft + " days, " + hoursLeft + " hours.");
Forwarded from Goddy BJS
🏳️🌈 Advanced Language Setting Code!
🐶 Command :
➡️ BJS :
🐶 Command :
➡️ BJS :
🪤 Command : Anything
Example :
------------------------------------------------------
🪽 Example :
🐶 Command :
🇺🇸 Language ➡️ BJS :
const inlkey = [
[
{ text: "🇺🇸 English", callback_data: "/Set_lang EN" },
{ text: "🇪🇸 Español", callback_data: "/Set_lang ES" }
]
]
const text =
"*🇺🇸 Select The Language Of Your Preference.\n🇪🇸 Seleccione El Idioma De Su Preferencia.*"
Api.sendMessage({
text,
parse_mode: "Markdown",
reply_markup: { inline_keyboard: inlkey }
})🐶 Command :
/Set_lang➡️ BJS :
let msg_id = User.getProperty("Settings_Msg_ID")
let Data = params.split(" ")
let Set_Lenguage = Data[0]
if (Set_Lenguage.includes("EN")) {
User.setProperty("Lenguage", "EN", "string")
var Text = "*🇺🇸 Language Set To English.*"
}
if (Set_Lenguage.includes("ES")) {
User.setProperty("Lenguage", "ES", "string")
var Text = "*🇪🇸 Idioma Configurado En Español.*"
}
Api.sendMessage({ text: Text, parse_mode: "Markdown" })🪤 Command : Anything
Example :
Your current code is Api.sendMessage({ text: "❤️ Private", parse_mode: "Markdown" })------------------------------------------------------
//Add This On First Every Code
if(User.getProperty("Lenguage")=="EN"){ //if language is EN
// Your Code
}
if(User.getProperty("Lenguage")=="ES"){ //if language is ES
//Your Translated Code
}🪽 Example :
if(User.getProperty("Lenguage")=="ES"){
Api.sendMessage({ text: "❤️ te amo", parse_mode: "Markdown" })
}
if(User.getProperty("Lenguage")=="EN"){
Api.sendMessage({ text: "❤️ I Love You", parse_mode: "Markdown" })
}
©️Copyright By @Private_BotsForwarded from Goddy BJS
Unrecognized command Handler
Command- *
Command- *
let userInput = message;
let commands = ["/start", "/help", "/info"];//Add other commands your bot support
function isCommand(input) {
return commands.includes(input);
}
if (!isCommand(userInput)) {
Bot.sendMessage("Sorry, I didn't understand that. Please use a valid command.");
}
Forwarded from Goddy BJS
Secured Balance adder
Command - /add
Answer- Enter User id
Wait for answer- on
Command- /bb
Answer- How much do you want to add
Wait for answer- on
Command - /add
Answer- Enter User id
Wait for answer- on
var key = "1399031414"//Edit your id
if (user.telegramid == key){
let msg = message;
User.setProperty("id", msg, "integer");
Bot.runCommand ("/bb");
}else{
return
}
Command- /bb
Answer- How much do you want to add
Wait for answer- on
var key = "1399031414"//Edit your id
if (user.telegramid == key){
let amount = parseFloat(message);
let tgid = User.getProperty("id");
let res = Libs.ResourcesLib.anotherUserRes("balance", tgid);
res.add(parseFloat(amount));
Bot.sendMessage("*Succesfully Added Balance* \n*👤 User = "+tgid+"\n💰 Amount= "+amount+"*");
}else{
return
}
Forwarded from Goddy BJS
Text To Image( Captcha ) BJs With Api
Command- /text
Answer- Send me your text
Wait for answer- on
BJS-
Command- /text
Answer- Send me your text
Wait for answer- on
BJS-
var userText = encodeURIComponent(message);
var captchaUrl = "https://dummyimage.com/600x200/000/fff.png&text=" + userText;
Api.sendPhoto({
photo: captchaUrl,
chat_id: user.telegramid,
caption: "Here is your CAPTCHA!",
on_result: "onPhotoSent",
error: "onError"
});
Forwarded from Goddy BJS
Goddy BJS
Who need this code? 5 reactions and I would drop it❤️
Don’t forget this✍️
Forwarded from Goddy BJS
Goddy BJS
Who need this code? 5 reactions and I would drop it❤️
Command- /add
Bjs-
Command- /addbal2
Wait for answer- on
Command- /bb
Wait for answer- on
Bjs-
Bot.sendMessage("Enter User IDs (comma separated)");
var key = "1399031414"; // Edit your id
if (user.telegramid == key) {
Bot.runCommand("/addbal2");
} else {
return;
}
Command- /addbal2
Wait for answer- on
let input = message;
let userIds = input.split(",").map(id => id.trim());
User.setProperty("userIds", userIds, "json");
Bot.sendMessage("How much do you want to add?");
Bot.runCommand("/bb");
Command- /bb
Wait for answer- on
var key = "1399031414"; // Edit your id
if (user.telegramid == key) {
let amount = parseFloat(message);
if (isNaN(amount)) {
Bot.sendMessage("Please enter a valid number for the amount.");
return;
}
let userIds = User.getProperty("userIds");
if (!userIds || userIds.length === 0) {
Bot.sendMessage("No user IDs found. Please run /add again.");
return;
}
userIds.forEach(function(tgid) {
let res = Libs.ResourcesLib.anotherUserRes("balance", tgid);
res.add(amount);
Bot.sendMessage("*Succesfully Added Balance* \n*👤 User = " + tgid + "\n💰 Amount= " + amount + "*");
});
User.setProperty("userIds", null);
} else {
return;
}
Forwarded from Goddy BJS
Goddy BJS
Command- /add Bjs- Bot.sendMessage("Enter User IDs (comma separated)"); var key = "1399031414"; // Edit your id if (user.telegramid == key) { Bot.runCommand("/addbal2"); } else { return; } Command- /addbal2 Wait for answer- on let input = message;…
Drop reactions✍️
Forwarded from Goddy BJS
Command - /age
Bjs-
Bjs-
var birthdate = new Date(params); // Birthdate provided by the user
if (isNaN(birthdate)) {
Bot.sendMessage("Please provide a valid birthdate in the format YYYY-MM-DD.");
return;
}
var today = new Date();
var age = today.getFullYear() - birthdate.getFullYear();
var monthDiff = today.getMonth() - birthdate.getMonth();
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthdate.getDate())) {
age--;
}
Bot.sendMessage("You are " + age + " years old.");
Forwarded from Goddy BJS
Command - Any Command
var commands = [
{ command: "/start", description: "Restart Bot" },
{
command: "/mainmenu",
description: "Redirect to Menu"
}
]
HTTP.post({
url: "https://api.telegram.org/bot" + bot.token + "/setMyCommands",
body: {
commands: commands,
scope: { 'type': "default" }
},
headers: { "Content-type": "application/json" }
})
Bot.sendMessage("Done")Forwarded from Goddy BJS
Details- This code lists the group admins in a particular group
Bjs-
Command- /list
Command- /onAdminsReceived
Bjs-
Command- /list
Api.getChatAdministrators({
chat_id: chat.chatid,
on_result: "/onAdminsReceived"
});
Command- /onAdminsReceived
var admins = options.result;
var adminList = "Group Administrators:\n";
for (var i = 0; i < admins.length; i++) {
var admin = admins[i].user;
adminList += "• " + admin.first_name;
if (admin.username) {
adminList += " (@" + admin.username + ")";
}
adminList += "\n";
}
Bot.sendMessage(adminList);