DEV Community

Syed Iqbal Ahammad
Syed Iqbal Ahammad

Posted on

Telegram Bots Are Useful — But at What Cost to Privacy?

Rise of Telegram Bots in Private Groups

This example is for educational purposes only, to demonstrate how leaked data can be misused.

Telegram bots are very popular in Telegram groups because they make life easier by automating tasks, sharing content, and managing groups efficiently.

Telegram bot

Today’s generation largely depends on Telegram bots for entertainment, such as downloading anime, movies, music, and other digital content. Because of this convenience, Telegram bots are growing rapidly and are becoming a major part of online life for young users.

How did I figure all these things out?

Telegraf.js

When I was in the process of developing a Telegram bot (in JavaScript) using Telegraf.js, I had an experience that truly amazed me. The result of this experience made me reconsider my perception of Telegram bots and the inner workings associated with them, resulting in greater knowledge and understanding through further investigation.

import { Telegraf } from 'telegraf'
import { message } from 'telegraf/filters'

if (!process.env.BOT_TOKEN) {
  throw new Error('BOT_TOKEN is missing');
}

const bot = new Telegraf(process.env.BOT_TOKEN) //Add Your telegram bot token 

bot.on(message('text'), async (ctx) => {
  if (ctx.message.chat.type === "group" || ctx.message.chat.type === "supergroup") {

    const ctxJson = JSON.stringify(ctx.message, null, 2);
    console.log(ctxJson)
    await ctx.reply(`Hello`)
  }
})
bot.launch()

process.once('SIGINT', () => bot.stop('SIGINT'))
process.once('SIGTERM', () => bot.stop('SIGTERM'))
Enter fullscreen mode Exit fullscreen mode

Output :-

{
  "message_id": 9,
  "from": {
    "id": "telegram id of sender",
    "is_bot": false,
    "first_name": "sender first name",
    "last_name": "sender last name",
    "username": "sender user name",
    "language_code": "en"
  },
  "chat": {
    "id": "chat id of private group",
    "title": "Demo",
    "type": "supergroup"
  },
  "date": 1766301711,
  "text": "hi"
}
Enter fullscreen mode Exit fullscreen mode

Telegram bot permissions

This often happens when a bot is added as an admin in private groups. What’s shocking is that even without any active admin permissions, the bot can still access private group data.

You can clearly see how Telegram bots can access your chats, chat IDs, and sender information, including your Telegram ID. They can also see all active members info in private groups. This shows how powerful bots are and why users should be careful while using them in private chats and groups.

Privacy Risks of Telegram Bots ⚠️

You can clearly see how dangerous Telegram bots can be when they are made admins in private groups.

Once a bot becomes an admin, it can access very sensitive data, such as:

  • Private group chats
  • Private group chat IDs
  • User Telegram IDs
  • Telegram group IDs

But how exactly do they use this data?

import { Telegraf } from 'telegraf'

if (!process.env.BOT_TOKEN) {
    throw new Error('BOT_TOKEN is missing');
}

const bot = new Telegraf(process.env.BOT_TOKEN) //Add Your telegram bot token

const StolenChatIds = [
    // -1001234567890,
]
const StolledUsersIds = [
    // 123456789,
]
const AdvertisingMessage = 'Your message here'

async function sendMessageToVictim(chatId, text) {
    await bot.telegram.sendMessage(chatId, text);
}

async function FreeIllegalAdvertisement() {

    for (const chatId of StolenChatIds) {
        await sendMessageToVictim(chatId, AdvertisingMessage)
    }
    for (const userId of StolledUsersIds) {
        await sendMessageToVictim(userId, AdvertisingMessage)
    }
}
FreeIllegalAdvertisement()
Enter fullscreen mode Exit fullscreen mode

In the above example we can see how they use these data for some unwanted legal/illegal advertisement or else they sell these data to some other third party buyer.

We have a responsibility to protect our valuable data by avoiding the use of free group management, group help, and spam protection bots in our private groups.

Final Conclusion

  • Avoid using bots in private groups
  • Bots are tools
  • Risk depends on permissions + developer intent
  • The real danger is blind trust

Bots are not evil , but careless usage makes users vulnerable.

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.