- π Features
- π Getting Started
- π Usage
- π‘ Deployment
- π Update
- π Author
- π Support groups
- Integration with various APIs.
- Automated responses to user queries.
- Easy customization and commands.
- Built using Node.js and Express.
- Uses MongoDB for data storage.
- Custom message handling functions.
- usePrefix features for commands.
- whitelist id and threads features.
- ignore list id features.
- premium mode features.
- bot operators and main admin features.
- Open Telegram and search for BotFather.
- Start a chat with BotFather and type
/newbot
to create a new bot. - Follow the prompts to name your bot and create a unique username.
- Once created, BotFather will provide you with a bot token. This token is crucial for connecting your bot to Telegram.
Clone the repository to your local machine:
git clone https://github.com/your-username/telegram-bot.git
cd telegram-bot
Create a config.json
file in the root directory and add the following configuration:
{
"token": "YOUR_BOT_TOKEN_HERE",
"prefix": "/",
"mongoURI": "YOUR_MONGODB_URI",
"ignore_list_ID": {
"enable": false,
"IDS": []
},
"white_list_group": {
"enable": false,
"groups": []
},
"white_list_ID": {
"enable": false,
"IDS": []
},
"adminBot": [
"ADMIN_UID_HERE"
],
"botOperator": []
}
Install the required dependencies:
npm install
Start your bot using the following command:
npm start
or
node index
Use this function to send a reply to a specific message in the chat. It provides a more contextual response to user queries.
Example:
module.exports = {
config: {
name: "echo",
version: "1.0",
aliases:["eco"],
author: "dipto",
countDown: 3,
role: 3,
description: "Echoes back the message sent by the user",
commandCategory: "fun test",
guide: "{pn} <message>",
},
run: async function ({ message, args }) {
const echoMessage = args.join(" ");
if (!echoMessage) {
return await message.reply("Please provide a message to echo.");
}
//usages of message reply
await message.reply(echoMessage);
},
};
This function is used to stream data to the chat. It can be useful for sending large amounts of data or files.
Example:
module.exports = {
config: {
name: "echo",
version: "1.0",
aliases:["eco"],
author: "dipto",
countDown: 3,
role: 3,
description: "Echoes back the message sent by the user",
commandCategory: "fun test",
guide: "{pn} <message>",
},
run: async function ({ message, args }) {
const echoMessage = args.join(" ");
if (!echoMessage) {
return await message.reply("Please provide a message to echo.");
}
//usages of message stream (remember attachment should be first)
await message.stream({
attachment:"https://telegra.ph/file/4b46589e723817e575717.jpg",
body:"caption message "
});
},
};
Use this function to format a message as code, which helps in presenting code snippets or structured data clearly.
Example:
module.exports = {
config: {
name: "echo",
version: "1.0",
aliases:["eco"],
author: "dipto",
countDown: 3,
role: 3,
description: "Echoes back the message sent by the user",
commandCategory: "fun test",
guide: "{pn} <message>",
},
run: async function ({ message, args }) {
const echoMessage = args.join(" ");
if (!echoMessage) {
return await message.reply("Please provide a message to echo.");
}
//usages of code box(js)
await message.code("console.log()");
},
};
Use this function to format a message as code, which helps in presenting code snippets or structured data clearly. And it need a mimeType for recognize is it a video or photo or audio.
Example:
await message.download({
attachment:"https://telegra.ph/file/4b46589e723817e575717.jpg",
body:"caption message ",
mimeType: "image/png"//it's important for download
});
Is used to unsend message
Example:
await message.unsend(event.message_id)
Is used to show error
Example:
await message.err(error)
Aliases allow commands to be triggered with alternative names. Define them in your command configuration.It's a nickname or short name of real command
Example:
module.exports = {
config: {
name: "echo",
version: "1.0",
//usages of aliases (it should be an Array [])
aliases:["eco"],
author: "dipto",
countDown: 3,
role: 3,
description: "Echoes back the message sent by the user",
commandCategory: "fun test",
guide: "{pn} <message>",
},
run: async function ({ message, args }) {
};
This setting determines whether a command requires a prefix to be recognized.If usePrefix false then that command will work without prefix.
Example:
module.exports = {
config: {
name: "echo",
version: "1.0",
//usages of usePrefix (it should be true or false)
usePrefix: true,//or false
aliases:["eco"],
author: "dipto",
countDown: 3,
role: 3,
description: "Echoes back the message sent by the user",
commandCategory: "fun test",
guide: "{pn} <message>",
},
run: async function ({ message, args }) {
};
This function handles replies to bot messages and executes the associated commands.
Example Usage:
const axios = require('axios');
module.exports.config = {
name: "bby",
version: "1.0",
credits: "Dipto",
role: 0,
usePrefix: false,
description: "Talk to baby bot",
commandCategory: "fun",
guide: "baby [message]",
coolDowns: 5,
premium: false
};
module.exports.run = async ({ event, message, args }) =>{
const userMessage = args.join(' ');
try {
const apiUrl = `https://www.noobs-api.000.pe/dipto/baby?text=${encodeURIComponent(userMessage)}`;
const response = await axios.get(apiUrl);
const data = response.data.reply;
const info = await message.reply(data)
const infoID = info.message_id;
const author = event.from.id
//Store the command name and data ( in reply or onReply,handleReply any
global.functions.reply.set(infoID, {
commandName: this.config.name,
type: "reply",
messageID: infoID,
author,
data: reply
});
} catch (error) {
console.error('Error:', error);
message.reply('Sorry, something went wrong!');
}
};
module.exports.reply = async function ({ event, message ,args, Reply }) {
//import the data from reply function which one we add in run function.
const { data } = Reply;
try {
const apiUrl = `https://www.noobs-api.000.pe/dipto/baby?text=${encodeURIComponent(args.join(' '))}`;
const response = await axios.get(apiUrl);
const reply = response.data.reply;
const info = await message.reply(reply);
const infoID = info.message_id;
const author = event.from.id
//again store it for conventional (continuous process)
//if you want only reply then you can ignore it.
global.functions.reply.set(infoID, {
commandName: this.config.name,
type: "reply",
messageID: infoID,
author,
mesg: reply
});
} catch (error) {
console.error('Error:', error);
message.reply("error π¦")
}
};
This function handles replies to bot messages and executes the associated commands.
Example Usage:
const axios = require('axios');
module.exports.config = {
name: "bby",
version: "1.0",
credits: "Dipto",
role: 0,
usePrefix: false,
description: "Talk to baby bot",
commandCategory: "fun",
guide: "baby [message]",
coolDowns: 5,
premium: false
};
module.exports.run = async ({ event, message, args }) =>{
const userMessage = args.join(' ');
try {
const apiUrl = `https://www.noobs-api.000.pe/dipto/baby?text=${encodeURIComponent(userMessage)}`;
const response = await axios.get(apiUrl);
const data = response.data.reply;
const info = await message.reply(data)
const infoID = info.message_id;
const author = event.from.id
//Store the command name and data ( in reply or onReply,handleReply any
global.functions.onReply.set(infoID, {
commandName: this.config.name,
type: "reply",
messageID: infoID,
author,
data: reply
});
} catch (error) {
console.error('Error:', error);
message.reply('Sorry, something went wrong!');
}
};
module.exports.onReply = async function ({ event, message ,args, Reply }) {
//import the data from reply function which one we add in run function.
const { data } = Reply;
try {
const apiUrl = `https://www.noobs-api.000.pe/dipto/baby?text=${encodeURIComponent(args.join(' '))}`;
const response = await axios.get(apiUrl);
const reply = response.data.reply;
const info = await message.reply(reply);
const infoID = info.message_id;
const author = event.from.id
//again store it for conventional (continuous process)
//if you want only reply then you can ignore it.
global.functions.onReply.set(infoID, {
commandName: this.config.name,
type: "reply",
messageID: infoID,
author,
mesg: reply
});
} catch (error) {
console.error('Error:', error);
message.reply("error π¦")
}
};
Your can use handleReply also.it will work in same way
global.functions.handleEvent.set(infoID, {
commandName: this.config.name,
type: "reply",
messageID: infoID,
author,
mesg: reply
});
module.exports.handleEvent = async ({ event, message ,args, Reply }) => {}
start
,onStart
,run
,prefix
Define these functions will work when they are called.
Example Usage:
module.exports.config={
name:""
}
module.exports.run = async({api,event}) =>{
try {
} catch (error) {
}
}
//usages of onStart
module.exports.config={
name:""
}
module.exports.onStart = async({api,event}) =>{
try {
} catch (error) {
}
}
//usages of start same as onStart run
module.exports.config={
name:""
}
module.exports.start = async({api,event}) =>{
try {
} catch (error) {
}
}
//also you can use function in different way
//this also same as others
module.exports ={
config:{
name:""
},
prefix: async({api,event}) =>{
try {
//this also works in same way
} catch (error) {
}
}
}
chat
,onChat
,handleEvent
,noPrefix
Define these functions will work for all time no need to call.
Example Usage:
module.exports.config={
name:""
}
module.exports.onChat= async({api,event}) =>{
try {
} catch (error) {
}
}
//all system are same just onChat to chat,handleEvent, noPrefix.
Your can use database from mongo
//get user and thread Data
usersData.get(event.from.id);
threadsData.get(event.chat.id);
//update user and thread
usersData.set(event.from.id,{
updateDataHere
});
threadsData.set(event.chat.id,{
updateDataHere
});
//get all data
usersData.getAll();
threadsData.getAll();
-
Install Vercel CLI:
npm install -g vercel
-
Create a
vercel.json
File:Add a
vercel.json
file to the root directory with the following content:{ "version": 2, "builds": [ { "src": "index.js", "use": "@vercel/node" } ], "routes": [ { "src": "/(.*)", "dest": "/index.js" } ] }
-
Deploy Your Bot:
Run the following command to deploy:
vercel
Follow the prompts to complete the deployment.
Type node update in shell or terminal
This project is licensed under Open License - Non-Commercial. See the LICENSE
file for more details.
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome.
If you encounter any issues, please report them at Issues.
- Dipto