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

@effect-ak/tg-bot-emulator

v1.12.0

Published

In-memory Telegram Bot API emulator: test bots without a token, network, or BotFather

Readme

@effect-ak/tg-bot-emulator

In-memory Telegram Bot API emulator. Test bots built with @effect-ak/tg-bot without a token, network, or BotFather — the whole Bot API round trip happens in memory, in Node or in the browser.

import { createBot } from "@effect-ak/tg-bot"
import { makeTgBotEmulator } from "@effect-ak/tg-bot-emulator"

const emulator = makeTgBotEmulator()

const bot = await createBot()
  .command("/start", ({ ctx }) => ctx.reply("Hello!"))
  .run({ client: emulator.client })

emulator.sendMessage("/start")

const reply = await emulator.nextBotMessage()
console.log(reply.text) // "Hello!"

bot.stop()

Scope: a private chat with your bot

The emulator deliberately models one private 1:1 conversation between one user and the bot — the mode most bots are built and tested in first, and the mode the playground's virtual phone shows. Everything below happens inside that single chat. Groups, channels, forum topics, and communities are not modeled (yet — see docs/todo.md); methods that only make sense there return a regular "not supported" error.

What it emulates

Inside that private chat — the Bot API surface a typical bot needs:

  • get_updates — with real long-poll semantics (a pending call resolves the moment an update is pushed) and offset-based confirmation
  • Messaging — send_message, edit_message_text, edit_message_caption, edit_message_reply_markup, delete_message(s), forward_message, copy_message, reply_parameters, parse_mode: "HTML" → real entities
  • Streaming drafts (Bot API 9.3+) — send_message_draft with the "Thinking…" placeholder and animated draft updates; sending a message finalizes the draft
  • Rich messages (Bot API 10.1+) — send_rich_message and send_rich_message_draft: blocks pass through, html is converted to blocks; edit_message_text accepts rich_message too
  • Media — send_photo/document/video/audio/voice/animation/sticker/dice/location/contact; uploaded file_content payloads round-trip through get_file / client.getFile
  • Chat-level — send_chat_action, set_message_reaction, answer_callback_query, get_me, get_chat

Unknown methods return a regular NotOkResponse client error, so bots degrade the same way they would against the real API.

Observing drafts, actions, and reactions

emulator.draft // current streamed draft (or null)
emulator.reactions // reactions by message id
emulator.subscribe((event) => {}) // + draft / draft_cleared / chat_action / reactions

Acting as the user

emulator.sendMessage("/help")        // delivers a `message` update
emulator.sendMessage("yes", { reply_to: 12 }) // reply — embeds reply_to_message
emulator.tapButton("color:red")      // taps an inline button → `callback_query` update
emulator.deleteMessage(12)           // removes from the chat (no update, like real TG)
emulator.sendPhoto(file)             // media updates; bytes round-trip via getFile
emulator.sendDocument(file, { caption: "notes" })
emulator.editMessage(id, "fixed")    // → `edited_message` update
emulator.react(id, "👍")             // → `message_reaction` update (null clears)
emulator.sendInlineQuery("cats")     // → `inline_query`; bot answers…
emulator.chooseInlineResult("r1")    // …→ `chosen_inline_result` + chat message
emulator.pushUpdate({ ... })         // escape hatch: deliver any update

Observing the chat

emulator.messages // chat history snapshot
emulator.subscribe((event) => {}) // message / message_edited / message_deleted / callback_answered
await emulator.nextBotMessage() // wait for the bot's next message
await emulator.nextEvent((e) => e.type === "callback_answered")

Docs

  • Guides and the interactive playground: https://tg-bot-sdk.website
  • docs/architecture.md — module map and how the emulator works inside
  • docs/todo.md — known gaps against Bot API 10.3