Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mtcute/mtcute
modern typescript library for mtproto. supports browsers, node/bun, deno and more!
https://github.com/mtcute/mtcute
bun deno mtproto nodejs telegram typescript
Last synced: 6 days ago
JSON representation
modern typescript library for mtproto. supports browsers, node/bun, deno and more!
- Host: GitHub
- URL: https://github.com/mtcute/mtcute
- Owner: mtcute
- License: mit
- Created: 2021-04-08T09:20:09.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-11T21:33:28.000Z (3 months ago)
- Last Synced: 2024-10-29T17:32:18.533Z (2 months ago)
- Topics: bun, deno, mtproto, nodejs, telegram, typescript
- Language: TypeScript
- Homepage: https://mtcute.dev
- Size: 9.24 MB
- Stars: 161
- Watchers: 2
- Forks: 12
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - mtcute/mtcute - modern typescript library for mtproto. supports browsers, node/bun, deno and more! (TypeScript)
README
modern typescript library for mtproto
documentation
•
api reference
•
telegram chat
> [!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!```ts
import { TelegramClient } from '@mtcute/node'
import { Dispatcher, filters } from '@mtcute/dispatcher'const tg = new TelegramClient({
apiId: Number.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! 🌸')
})const self = await tg.start({ /* optional params */ })
console.log(`✨ logged in as ${self.displayName}`)
```mtcute is a modern, performant and *✨ cute ✨* [mtproto](https://mtcute.dev/guide/intro/mtproto-vs-bot-api.html) library and bot framework,
supporting both web and nodejs.## quick start
🤖 just starting a (user)bot? use the scaffolding tool:
```bash
pnpm create @mtcute/bot
```🏭 want to integrate it into your existing nodejs app? use the nodejs package:
```bash
pnpm add @mtcute/node
# optional, for faster crypto
pnpm add @mtcute/crypto-node
```✨ building something for web? use the web package:
```bash
pnpm add @mtcute/web
```🚀 using the newfangled runtimes? we've got you covered:
- bun: `bun add @mtcute/bun`
- deno: `import { TelegramClient } from 'jsr:@mtcute/deno'`learn more: [guide](https://mtcute.dev/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 🐈
## project goals
mtcute strives to:
- be customizable enough to fit most of the possible use-cases
- be lightweight, both in terms of runtime and bundle size
- support (theoretically) any environment without much hassle
- provide a solid foundation for all kinds of applications on telegram platform
- provide a convenient high-level api for the most commonly used featuresmtcute is **NOT** and will never be:
- a library for spam/flood or otherwise malicious activities
- a fully feature-complete library - highlevel apis will never cover the entirety of the apis. feel free to contribute, though!
- a drop-in replacement for (insert library name)
- a teapot## setting up for development
```bash
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:
- [TDLib](https://github.com/tdlib/td) - the official mtproto client library
- [TDesktop](https://github.com/telegramdesktop/tdesktop) - the official desktop client
- [Pyrogram](https://github.com/pyrogram/pyrogram), [Telethon](https://github.com/LonamiWebs/Telethon) - popular python librariesthanks [@dotvhs](//t.me/AboutTheDot) for the logo <3