Skip to content
/ BotBee Public template
forked from dipto-008/BotBee

A Simple Telegram Bot for personal usages and fun

License

Notifications You must be signed in to change notification settings

rrashedul59/BotBee

Β 
Β 

Repository files navigation


Bot'Beev1.0.0πŸš€
- Made By Dipto

A Powerful Telegram bot built by Dipto for various automated tasks.

Version 1.0.0


Nodejs Support v20.x size code-version visitors license


πŸ“¦ Features

  • 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.

πŸš€ Getting Started

1. Setting Up Your Bot with BotFather

  1. Open Telegram and search for BotFather.
  2. Start a chat with BotFather and type /newbot to create a new bot.
  3. Follow the prompts to name your bot and create a unique username.
  4. Once created, BotFather will provide you with a bot token. This token is crucial for connecting your bot to Telegram.

2. Cloning the Repository

Clone the repository to your local machine:

git clone https://github.com/your-username/telegram-bot.git
cd telegram-bot

3. Setting Up Your Bot Configuration

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": []
}

4. Installing Dependencies

Install the required dependencies:

npm install

5. Starting the Bot

Start your bot using the following command:

npm start

or

node index

πŸ›  Usage

Custom Message Functions

message.reply()

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);
  },
};

message.stream()

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 "
   });
  },
};

message.code()

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()");
  },
};

message.download()

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 
   });

message.unsend()

Is used to unsend message

Example:

await message.unsend(event.message_id)

message.err()

Is used to show error

Example:

await message.err(error)

Command and Event Handling

Aliases

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 }) {
   
};

usePrefix

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 }) {
   
};

Reply Handling

reply

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 πŸ¦†")
    }
};

onReply

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 πŸ¦†")
    }
};

reply

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 }) => {}

Commands

  • 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) {
    
  }
}
}

Events

  • 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.

Example of Database

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();

πŸ“¦ Deployment with Vercel

  1. Install Vercel CLI:

    npm install -g vercel
  2. 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" }
      ]
    }
  3. Deploy Your Bot:

    Run the following command to deploy:

    vercel

    Follow the prompts to complete the deployment.


How to update

Type node update in shell or terminal


πŸ“œ License

This project is licensed under Open License - Non-Commercial. See the LICENSE file for more details.


🀝 Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome.


🐞 Issues

If you encounter any issues, please report them at Issues.


✍️ Author

  • Dipto

Dipto's Profile Facebook ID


🌐 Support Group

Your Baby Group(Telegram)

Your Baby Group(Messager)


πŸ”— Links


About

A Simple Telegram Bot for personal usages and fun

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 95.5%
  • HTML 4.4%
  • Nix 0.1%