How to use the airgram.Airgram function in airgram

To help you get started, we’ve selected a few airgram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airgram / airgram / examples / custom-context / src / index.ts View on Github external
import { UPDATE } from '@airgram/constants'
import { Airgram, Auth, isError, prompt } from 'airgram'
import debug from 'debug'
import { Store } from './Store'

const writeLog = debug('airgram:log')
const writeError = debug('airgram:error')

const store = new Store()

const airgram = new Airgram({
  apiId: process.env.APP_ID as number | undefined,
  apiHash: process.env.APP_HASH,
  command: process.env.TDLIB_COMMAND,
  databaseDirectory: '../../db',
  logVerbosityLevel: 2,
  // the following option allows to extend the base context
  context: { $store: store }
})

airgram.use(new Auth({
  code: () => prompt('Please enter the secret code:\n'),
  phoneNumber: () => prompt('Please enter your phone number:\n')
}))

airgram.on(UPDATE.updateUser, async ({ $store, update }, next) => {
  const { user } = update
github airgram / airgram / examples / getting-started / src / index.ts View on Github external
import { Airgram, Auth, isError, prompt, toObject } from 'airgram'
import debug from 'debug'

const writeLog = debug('airgram:log')
const writeInfo = debug('airgram:info')
const writeError = debug('airgram:error')

const airgram = new Airgram({
  apiId: process.env.APP_ID as number | undefined,
  apiHash: process.env.APP_HASH,
  command: process.env.TDLIB_COMMAND,
  databaseDirectory: '../../db',
  logVerbosityLevel: 2
})

airgram.use(new Auth({
  code: () => prompt('Please enter the secret code:\n'),
  phoneNumber: () => prompt('Please enter your phone number:\n')
}))

// async/await style of requests
void (async () => {
  const me = toObject(await airgram.api.getMe())
  writeInfo('[Me] ', me)

airgram

Documentation is available [here](https://airgram.io).

GPL-3.0
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis