modern typescript library for mtproto. supports browsers, node/bun, deno and more! github mirror: https://github.com/mtcute/mtcute
Find a file
2023-11-12 19:19:02 +03:00
.github build: fixed tl versioning + changelog generation 2023-11-12 19:19:02 +03:00
.husky build: use lint-staged + pre-commit prettier and type checking 2023-06-10 01:43:52 +03:00
e2e test(e2e): added wasm tests 2023-11-04 21:23:45 +03:00
packages build: fixed tl versioning + changelog generation 2023-11-12 19:19:02 +03:00
scripts build: fixed tl versioning + changelog generation 2023-11-12 19:19:02 +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
.eslintignore chore: code quality improvements 2023-06-05 00:30:48 +00:00
.eslintrc.ci.js ESM + end-to-end tests (#11) 2023-10-16 19:23:53 +03:00
.eslintrc.js fix(eslint): better /dist import restriction 2023-11-12 00:43:58 +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
.lintstagedrc.cjs test(core): improved test coverage 2023-11-11 18:38:57 +03:00
.nvmrc chore: better dependencies management 2023-06-04 17:00:33 +00:00
.prettierignore refactor: prettier-ed code, rearranged imports, fixed tests 2022-06-30 16:32:56 +03:00
.prettierrc chore: changed prettier width to 120 2023-09-24 01:32:22 +03:00
commitlint.config.js chore: code quality improvements 2023-06-05 00:30:48 +00:00
LICENSE chore: change license to MIT 2023-10-12 07:26:26 +03:00
package.json ci: added codecov to test action 2023-11-12 01:42:43 +03:00
pnpm-lock.yaml build(deps): pinned all deps 2023-11-12 01:34:01 +03:00
pnpm-workspace.yaml ESM + end-to-end tests (#11) 2023-10-16 19:23:53 +03:00
README.md docs: added telegram chat badge 2023-11-11 21:43:49 +03:00
tsconfig.build.json chore: removed dispatcher dep from core (again), improved build script 2023-11-12 01:17:20 +03:00
tsconfig.json test(tl-utils): improved test coverage 2023-11-09 21:03:52 +03:00
typedoc.base.cjs fix(docs): exclude test files from docs, also fixed build for crypto-node 2023-11-12 01:55:26 +03:00
typedoc.cjs docs: updated typedoc, added ci, fixed some docs 2023-10-27 14:25:21 +03:00
vite.config.mts chore(core): moved random to crypto provider, added tests for functions relying on rng 2023-11-12 00:36:00 +03:00

mtcute logo

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

NodeJS CI tl layer npm telegram chat 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!

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({
    phone: () => tg.input('phone > '),
    code: () => tg.input('code > '),
    password: () => tg.input('password > ')
}, 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 @cryptography/aes

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: