Skip to content

🤝 Telegram userBot with ai translator | Automatically translate messages and edit them.

Notifications You must be signed in to change notification settings

sudoskys/tgTranslator.ts

Repository files navigation

i18n_me

I18 With AI...

A Telegram UserBot that provides real-time message translation capabilities, allowing users to seamlessly communicate across language barriers.

Features

  • 🔄 Real-time message translation(but only for yourself)
  • 🎯 Custom target language settings per chat
  • 🤖 Easy-to-use commands

Prerequisites

  • Bun, go to Bun to install
  • OpenAI API Key (for translation service)

Installation

  1. Clone the repository
git clone https://github.com/sudoskys/i18n_me.git
pnpm install
  1. Create a .env file in the root directory with the following variables:
OAI_BASE_URL=https://api.openai.com/v1
DB_FILE_NAME=file:group.db
OAI_API_KEY=sk-xxxxx
OAI_MODEL=gpt-4o
  1. Edit tgsnake.config.js
nano tgsnake.config.js

get your apiHash and apiId from my.telegram.org

/** @type {import('tgsnake').Options } */
const config = {
  apiHash : 'xxxx',
  apiId : 123456,
  login : {
    botToken : '',
    sessionName : 'user',
    forceDotSession : true,
  },
  logLevel : ['error','info'],
  clientOptions : {"ipv6":false},
  plugins : []
}
module.exports = config

Usage

Starting the Bot

Connect to your Telegram account and start the bot:

pnpm run start

Then, Ctrl+C to stop the bot and run the following command to start the bot in production mode:

Build for production:

apt install npm
npm install -g pm2
# In the repo root directory
pm2 start pm2.json
pm2 status

Do not share your .env file or .session file with others.

Bot Commands

  • /ping - Test if the bot is active and get current chat ID
  • /local - Toggle translation feature on/off
  • /use [target_language] - Set target language for translations
  • tl [text] - Translate the following text (prefix any message with 'tl' to translate)

Acknowledgments

  • tgsnake - Telegram MTProto framework
  • instructor-ai - Translate text with AI
  • Bun - For the amazing runtime and tooling

Made with ❤️ by @sudoskys

About

🤝 Telegram userBot with ai translator | Automatically translate messages and edit them.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published