Strict typed library to create Telegram apps with Typescript/JavaScript (based on TDLib 1.8)
This is a wrapper for Telegram Database library written in TypeScript.
Node.js
# TDLib 1.8.0:
npm install airgram
# TDLib 1.7.2:
npm install [email protected]
Web
# TDLib 1.8.0:
npm install @airgram/web
# TDLib 1.7.2:
npm install @airgram/[email protected]
Check out webpack config example.
import { Airgram, Auth, prompt, toObject } from 'airgram'
const airgram = new Airgram({
apiId: process.env.APP_ID,
apiHash: process.env.APP_HASH
})
airgram.use(new Auth({
code: () => prompt(`Please enter the secret code:\n`),
phoneNumber: () => prompt(`Please enter your phone number:\n`)
}))
void (async () => {
const me = toObject(await airgram.api.getMe())
console.log(`[me]`, me)
})
// Getting all updates
airgram.use((ctx, next) => {
if ('update' in ctx) {
console.log(`[all updates][${ctx._}]`, JSON.stringify(ctx.update))
}
return next()
})
// Getting new messages
airgram.on('updateNewMessage', async ({ update }, next) => {
const { message } = update
console.log('[new message]', message)
return next()
})
Guides and API-reference are available here.
If you are interested in v1.*
, follow to corresponding branch.
The source code is licensed under GPL v3. License is available here.