1.1.1 • Published 7 years ago
tguserresolver v1.1.1
tguserresolver
Get users your telegram bot was in contact with using their id or username. Note that this package requires you to use telegraf
Installation
npm i tguserresolverAPI
const Resolver = require('tguserresolver')
const resolver = new Resolver({
// Optional. Pass your telegraf instance to listen on:
telegraf: <your telegraf instance>,
// Optional. The storage filename:
store: 'tgusers.db'
})resolver.byUsername(username)
Get a user by it's telegram username.
const user = await resolver.byUsername('testify')- username
<string>- The username (without'@')
resolver.search(str)
Search for users where the username, first name or last name contains the given string.
const users = await resolver.search('test')- str
<string>- The string to search for. - returns
<array>- An array of users.
resolver.listen(telegraf)
Add an additional telegraf instance to listen for users.
resolver.listen(telegraf)event: error
Handle errors that occur in the telegram or database layer.
resolver.on('error', err => {
console.error(err)
})