npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tg-resolve

v1.3.1

Published

Resolves Telegram usernames and/or ids to a complete User or/and Chat JSON object(s)

Downloads

323

Readme

https://telegram.me/kamikazechaser Travis

👤 tg-resolve

A light Node.js Library that resolves Telegram usernames and/or ids to a complete User or/and Chat JSON object(s)

Powered by PWRTelegram API

Background

The official Telegram API does not allow bots to resolve usernames/ids out of the box. One is forced to create his/her own database so as to resolve usernames. Resolving of usernames is particularly useful in that a bot is able to get a user/chat id of a person or groub it hasn't even seen! Unlike before where a bot is only able to see a person if it has ever recieved his/her message whether in private or in a group.

Useful Scenarios

  • Group administration bots
  • In a bot which has lost its database, but users had previously started the bot
  • General resolving to get user details e.g UResolverBot
  • And much more!

Install

$ npm install tg-resolve --save

Usage

const tgresolve = require("tg-resolve");

// using the 'bare' function
tgresolve(token, "@kamikazechaser", function(error, result) {
    // ... handle error ...
    console.log(result.id);
});

// you can create a client (referred to as 'resolver')
// that you can repeatedly use
const resolver = new tgresolver.Tgresolve(token);

// using the 'resolver'
resolver.tgresolve("@kamikazechaser", function(error, result) {
    // ... handle error ...
    console.log(result.id);
});

Refer to example.js for a more comprehensive guide

  • As of v1.2.0, you will need your own bot token!
  • As of v1.3.0, you can pass in your own pwrtg url!

tgresolve(token, username[, options], callback)

Resolve the username to a Result.

  • token (String): Telegram bot token
  • username (String)
  • options (Object, Optional)
  • callback (Function):
    • signature: callback(error, result)

resolver = new tgresolve.Tgresolve(token[, options])

Create a client/resolver.

  • token (String): Telegram bot token
  • options (Object, Optional): same as above

resolver.tgresolve(username, callback)

Resolve the username to a Result, using the client.

  • username (String)
  • callback (Function): same as above

Result

When resolving for a Group/Channel

{
    id: -1001065761006,
    title: "End Of The World Party",
    username: "EOTWGroup",
    type: "supergroup",
    when: "2016-10-18 11:22:56"
}

When resolving for a User

{
    id: 58258161,
    first_name: "John",
    username: "john_doe",
    type: "private",
    last_name: "Doe",
    when: "2016-10-18 11:22:56"
}

Issues And Contribution

Fork the repository and submit a pull request for whatever change you want to be added to this project. If you have any questions, just open an issue.