modern typescript library for mtproto. supports browsers, node/bun, deno and more! github mirror: https://github.com/mtcute/mtcute
Find a file
2024-03-07 05:35:36 +03:00
.config chore!: started extracting platform-specific stuff into separate packages 2024-03-07 05:35:36 +03:00
.github chore: initial bun support 2024-02-20 00:55:41 +03:00
e2e ci: fix canary builds 2024-02-08 01:45:41 +03:00
packages chore!: started extracting platform-specific stuff into separate packages 2024-03-07 05:35:36 +03:00
scripts refactor!: merged client into core + fixed dispatcher for new storage 2024-01-31 19:30:57 +03:00
.dockerignore ESM + end-to-end tests (#11) 2023-10-16 19:23:53 +03:00
.editorconfig feat: tl reference web application 2021-04-14 18:08:53 +03:00
.gitattributes Initial commit 2021-04-08 12:19:38 +03:00
.gitignore test(tl-utils): improved test coverage 2023-11-09 21:03:52 +03:00
.nvmrc chore: better dependencies management 2023-06-04 17:00:33 +00:00
LICENSE chore: change license to MIT 2023-10-12 07:26:26 +03:00
package.json v0.7.3 2024-02-28 11:03:43 +00:00
pnpm-lock.yaml chore!: started extracting platform-specific stuff into separate packages 2024-03-07 05:35:36 +03:00
pnpm-workspace.yaml ESM + end-to-end tests (#11) 2023-10-16 19:23:53 +03:00
README.md Update README.md 2023-12-18 15:22:15 +03:00
tsconfig.json refactor!: merged client into core + fixed dispatcher for new storage 2024-01-31 19:30:57 +03:00

mtcute logo

modern typescript library for mtproto
documentation  •  api reference  •  telegram chat  •  kanban board

NodeJS CI tl layer npm alpha version

Warning

mtcute is currently in alpha stage: the api is not very stable yet, and there may be a lot of bugs
feel free to try it out, though, any feedback is appreciated!

releases may not follow semver just yet, so please pin the versions for now

import { NodeTelegramClient } from '@mtcute/node'
import { Dispatcher, filters } from '@mtcute/dispatcher'

const tg = new NodeTelegramClient({
    apiId: parseInt(process.env.API_ID),
    apiHash: process.env.API_HASH,
    storage: 'my-account'
})
const dp = Dispatcher.for(tg)

dp.onNewMessage(filters.chat('private'), async (msg) => {
    await msg.replyText('hiiii from mtcute! 🌸')
})

tg.run({ /* optional params */ }, async (self) => {
    console.log(`✨ logged in as ${self.displayName}`)
})

mtcute is a modern, performant and cute mtproto library and bot framework, supporting both web and nodejs.

quick start

🤖 just starting a (user)bot? use the scaffolding tool:

pnpm create @mtcute/bot

🏭 want to integrate it into your existing nodejs app? use the nodejs wrapper:

pnpm add @mtcute/node
# for native crypto
pnpm add @mtcute/crypto-node

building something for web? use the client directly:

pnpm add @mtcute/client

learn more: guide

features

  • 🍰 simple: mtcute hides all the complexity and provides a clean and modern API
  • compatible: mtcute supports almost everything Bot API does, and even more!
  • 🍡 lightweight: Running instance uses less than 50 MB of RAM.
  • 🛡️ type-safe: Most of the APIs (including MTProto) are strictly typed to help your workflow
  • ⚙️ hackable: Almost every aspect of the library is customizable, including networking and storage
  • 🕙 up-to-date: mtcute uses the latest TL schema to provide the newest features as soon as possible

cat in the readme 🐈

setting up for development

git clone https://github.com/mtcute/mtcute
fnm use # or `nvm use`
cd mtcute
pnpm install --frozen-lockfile

# generate code from tl schema
pnpm -C packages/tl run gen-code

acknowledgements

some parts were based on or greatly inspired by these projects: