Skip to content

About

A lightweight, serverless Telegram bot that extracts Premium Custom Emoji IDs and their usage codes from any message. Built entirely on Telegram Serverless — no external server, no VPS, no hosting costs.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🤖 Custom Emoji ID Bot

A lightweight, serverless Telegram bot that extracts Premium Custom Emoji IDs and their usage codes from any message. Built entirely on Telegram Serverless — no external server, no VPS, no hosting costs.

Open Source Platform Language


✨ What Does It Do?

When a user sends a message containing Telegram Premium Custom Emojis (or an emoji pack link like t.me/addemoji/...), the bot:

  1. Detects each custom emoji or fetches the entire sticker pack.
  2. Fetches metadata (the original emoji character) via getCustomEmojiStickers
  3. Returns a formatted list showing:
    • The rendered Premium Emoji
    • Its Emoji ID
    • Ready-to-paste Button Code (icon_custom_emoji_id)
    • Ready-to-paste Caption Code (<tg-emoji> HTML tag)
  4. Provides inline copy buttons for each field

📁 Project Structure

JSEmojiIDBot/
├── handlers/
│   └── message.js      # Main message handler (all logic lives here)
├── schema.js           # Database schema (users table)
├── package.json        # Project config & scripts
└── README.md

Note: In Telegram Serverless, each file in handlers/ maps to a Telegram update type. message.js handles all incoming messages.


🛠️ Tech Stack

Layer Tool
Runtime Telegram Serverless (V8 Isolate)
API Wrapper Built-in sdk/api
Database Built-in sdk/db (SQLite + Drizzle-style ORM)
File Upload Built-in InputFile from sdk
Language Modern JavaScript (ES Modules)

⚠️ No external npm packages are supported on the Telegram Serverless platform. Everything must use the provided sdk modules or pure JavaScript.


🚀 Getting Started

Prerequisites

  • Node.js v18+
  • A Telegram Bot Token from @BotFather
  • The tgcloud CLI (installed automatically via npx)

1. Clone This Repo

git clone https://github.com/JSOrganizations/JSEmojiIDBot.git
cd JSEmojiIDBot
npm install

2. Get Your CLI Access Token

Open your bot in BotFather → tap the bot → go to "Bot Settings" → "CLI Access". You'll see an Access Token in this format:

app1234567890:xxxxxxxxxxxxxxxxxxxxxx

⚠️ This is not the regular Bot API token (123:AAFxxx). It's a separate CLI-specific token generated by BotFather for the Serverless platform.

3. Login & Link Your Bot

npx tgcloud login

Paste the CLI Access Token from BotFather when prompted. This links the project to your bot on the Serverless platform.

4. Set Your Admin ID

Open handlers/message.js and change the ADMIN_ID constant to your own Telegram User ID:

const ADMIN_ID = 6162684693; // ← Replace with your Telegram ID

Don't know your ID? Send any message to the bot after deploying and check the console logs.

5. Deploy

npm run deploy

6. Migrate the Database

Only needed once (or whenever schema.js changes):

npx tgcloud migrate

7. Test It Live

Send /start to your bot on Telegram. Then send a message containing any Premium Custom Emoji and the bot will respond with the extracted IDs.


🧱 Building Your Own Serverless Bot

Want to build a different bot from scratch using the same platform? Here's the quick-start:

Create a New Project

npm create @tgcloud/bot@latest ./MyNewBot
cd MyNewBot
npm install
npx tgcloud login

Add a Message Handler

Create handlers/message.js:

import { api } from 'sdk';

export default async function (message) {
  await api.sendMessage({
    chat_id: message.chat.id,
    text: `Hello, ${message.from?.first_name}!`,
  });
}

Use the Database

Define your schema in schema.js:

import { table, integer, text } from 'sdk/db';

export const items = table('items', {
  id:    integer('id').primaryKey(),
  value: text('value').notNull(),
});

Then use it in a handler:

import { db } from 'sdk';
import { sql } from 'sdk/db';
import { items } from 'schema';

const rows = await db.all(sql`SELECT * FROM items`);

Send a File

import { api, InputFile } from 'sdk';

const content = new TextEncoder().encode('Hello World');
const file    = new InputFile(content, 'hello.txt', { type: 'text/plain' });

await api.sendDocument({ chat_id: chatId, document: file });

Deploy & Migrate

npm run deploy          # Push code changes
npx tgcloud migrate     # Apply DB schema changes
npm run status          # Check deployment status

⚙️ Available Scripts

Command Description
npm run deploy Push code to the Telegram Serverless cloud
npm run status Check current deployment status
npm run run Run the bot locally for testing
npx tgcloud migrate Apply any pending database schema changes
npx tgcloud migrate --yes Apply migrations without confirmation prompt

👤 Admin Commands

These commands only work for the user whose ID matches ADMIN_ID in message.js:

Command Description
/stats View total users, premium users, and top languages
/export Download full user database as a users_export.json file

🗄️ Database Schema

// schema.js
users {
  userId       INTEGER  PRIMARY KEY
  firstName    TEXT     NOT NULL
  username     TEXT
  languageCode TEXT
  isPremium    BOOLEAN  DEFAULT false
  lastActive   INTEGER  (timestamp)
  createdAt    INTEGER  (timestamp)
}

Every user who interacts with the bot is automatically saved (or updated) in this table.


📄 License

This project is open source under the MIT License. Feel free to fork, modify, and build upon it!


A project by JSOrganizations

About

A lightweight, serverless Telegram bot that extracts Premium Custom Emoji IDs and their usage codes from any message. Built entirely on Telegram Serverless — no external server, no VPS, no hosting costs.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages