npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tg-lisa

v1.1.0

Published

TypeScript Telegram client for listening to messages across all chats and channels

Readme

tg-lisa

TypeScript Telegram client for listening to messages across all chats and channels.

Installation

npm install tg-lisa

Demo

Try the interactive demo application:

cd demo
npm install
cp .env.example .env
# Edit .env with your credentials from https://my.telegram.org
npm start

See demo/README.md for more details.

Usage

import { TgLisa } from 'tg-lisa';

const client = new TgLisa({
  apiId: YOUR_API_ID,
  apiHash: 'YOUR_API_HASH',
  sessionFilePath: './telegram-session.txt', // Session will be saved to file
});

// Connect and authenticate
await client.connect();

// Get all chats
const chats = await client.getAllChats();
console.log(chats);

// Listen to messages from specific chat
client.addChatListener('CHAT_ID', (message) => {
  // message is Api.Message from telegram/tl
  // You have full access to all message properties
  console.log(`New message: ${message.text}`);
  console.log(`Sender ID: ${message.senderId}`);
  console.log(`Date: ${message.date}`);
  console.log(`Message ID: ${message.id}`);
});

// Remove listener
client.removeChatListener('CHAT_ID');

API

TgLisa(config)

Create a new Telegram client instance.

Config:

  • apiId: number - Telegram API ID from https://my.telegram.org
  • apiHash: string - Telegram API hash from https://my.telegram.org
  • sessionFilePath?: string - Path to file where session will be stored
  • sessionName?: string - Manual session string (overrides sessionFilePath)

connect(): Promise<void>

Authenticate and start the client session. Will prompt for phone number and verification code on first run.

getAllChats(): Promise<TelegramChat[]>

Get all available chats, channels, and groups.

Returns: Array of TelegramChat objects with properties:

  • id: string - Unique chat identifier
  • title: string - Chat name or title
  • type: 'private' | 'group' | 'channel' - Chat type
  • username?: string - Username if available

addChatListener(chatId: string, handler: MessageHandler): void

Subscribe to messages from a specific chat.

Parameters:

  • chatId: string - Chat ID to listen to
  • handler: (message: TelegramMessage) => void | Promise<void> - Callback function that receives Api.Message objects

Note: TelegramMessage is an alias for Api.Message from telegram/tl, giving you full access to all message properties including text, media, reactions, and more.

removeChatListener(chatId: string, handler?: MessageHandler): void

Unsubscribe from chat messages.

Parameters:

  • chatId: string - Chat ID to stop listening to
  • handler?: MessageHandler - Specific handler to remove. If omitted, removes all handlers for the chat.

disconnect(): Promise<void>

Disconnect from Telegram and clean up resources.

getSessionString(): string

Get the current session string for reuse in future connections.

Returns: Session string that can be used with sessionName config option.

Types

TelegramMessage

Type alias for Api.Message from telegram/tl. Provides full access to all Telegram message properties.

TelegramChat

interface TelegramChat {
  id: string;
  title: string;
  type: 'private' | 'group' | 'channel';
  username?: string;
}

TelegramClientConfig

interface TelegramClientConfig {
  apiId: number;
  apiHash: string;
  sessionName?: string;
  sessionFilePath?: string;
}

MessageHandler

type MessageHandler = (message: TelegramMessage) => void | Promise<void>;

License

MIT