Listen to entities: links, email, phone number
import { IContext, IMessage } from 'degreet-telegram/src/types'
bot.on('message:email', async (ctx: IContext): Promise<any> => {
try {
console.log(ctx.parsed) // { email: 'example@gmail.com', emails: ['example@gmail.com', 'second@gmail.com'] }
} catch (e: any) {
console.error(e)
}
})bot.command('start', async (ctx) => {
try {
const result = await ctx.answer.sendDice('🎯')
console.log(result.dice) // { emoji: '🎯', value: 1 (1-6, 6 as max) }
} catch (e) {
console.error(e)
}
})
bot.on('dice', console.log) // when user drop diceYou can also use 'message:entity' and pass into 'entity' one of allowed entitiy types instead 'message:email' (bold, bot_command, email, url, phone_number)
Last updated