Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
$store.users.set(user.id, user)
return next()
})
airgram.on(UPDATE.updateNewChat, async ({ $store, update }, next) => {
const { chat } = update
$store.chats.set(chat.id, chat)
return next()
})
airgram.on(UPDATE.updateChatLastMessage, async ({ $store, update }, next) => {
$store.chatLastMessage.set(update.chatId, update)
return next()
})