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

@dreamcoder-uzbek/telegramjs

v1.2.5

Published

To integrate with the telegram bot from browser trough the project

Downloads

27

Readme

NPM

About The Project

This project was created to facilitate communication with Telegram using javascript

Add for Node js project(ReactJs)

  • npm
npm install @dreamcoder-uzbek/telegramjs
  • yarn
yarn add @dreamcoder-uzbek/telegramjs

Add to project via CDN link

https://cdn.jsdelivr.net/npm/@dreamcoder-uzbek/[email protected]/dist/telegram.min.js
https://unpkg.com/@dreamcoder-uzbek/[email protected]/dist/telegram.min.js

Add to project for browser

<html>
  <head>
    <title>Telegram Js | Connection example</title>
    <script src="dist/telegram.min.js"></script>
  </head>
<body>
<script>
  // your js code...
</script>
</body>
</html>

This is a complete guide to using this library. After reading it, you will be able to use it. I hope it will be useful for you


Getting Started

First of all, a special object is created to use the library. it will be possible to connect to the library using the telegram keyword

const connected = new telegram.init(botToken, chatId, parseMode);

| Keyword | required | default | |-------------|:---------|------------| | botToken | yes | | | chatId | yes | | | parseMode | optional | Markdown |

Usage

getMe

A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.

getUpdates

Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects.

getFile

| Parameter | Type | Required | Description | |-----------|--------|----------|------------------------------------------| | file_id | String | Yes | File identifier to get information about |

See here for more information

sendMessage

Use this method to send text messages. On success, the sent Message is returned.

connected.sendMessage(text, reply_to_message_id, protect_content, disable_notification);

| Parameter | Type | Required | Description | |------------------------|---------|----------|--------------------------------------------------------------------------------| | text | String | yes | Text of the message to be sent, 1-4096 characters after entities parsing | | reply_to_message_id | Integer | optional | If the message is a reply, ID of the original message | | protect_content | Boolean | optional | Protects the contents of the sent message from forwarding and saving | | disable_notification | Boolean | optional | Sends the message silently. Users will receive a notification with no sound. |

Markdown

Please note:

  • Entities must not be nested, use parse mode MarkdownV2 instead.
  • There is no way to specify underline and strikethrough entities, use parse mode MarkdownV2 instead.
  • To escape characters _, *, `, [ outside of an entity, prepend the characters '' before them.
  • Escaping inside entities is not allowed, so entity must be closed first and reopened again: use _snake_\__case_ for italic snake_case and *2*\**2=4* for bold 2*2=4.

MarkdownV2

Please note:

  • Any character with code between 1 and 126 inclusively can be escaped anywhere with a preceding '' character, in which case it is treated as an ordinary character and not a part of the markup. This implies that '' character usually must be escaped with a preceding '' character.
  • Inside pre and code entities, all '`' and '' characters must be escaped with a preceding '' character.
  • Inside (...) part of inline link definition, all ) and \ must be escaped with a preceding '' character.
  • In all other places characters _, *, [, ], (, ), ~, `, >, #, +, -, =, |, {, }, ., ! must be escaped with the preceding character ''.
  • In case of ambiguity between italic and underline entities __ is always greadily treated from left to right as beginning or end of underline entity, so instead of ___italic underline___ use ___italic underline_\r__, where \r is a character with code 13, which will be ignored

HTML

  <b>bold</b>, <strong>bold</strong>
  <i>italic</i>, <em>italic</em>
  <u>underline</u>, <ins>underline</ins>
  <s>strikethrough</s>, <strike>strikethrough</strike>, <del>strikethrough</del>
  <span class="tg-spoiler">spoiler</span>, <tg-spoiler>spoiler</tg-spoiler>
  <b>bold <i>italic bold <s>italic bold strikethrough <span class="tg-spoiler">italic bold strikethrough spoiler</span></s> <u>underline italic bold</u></i> bold</b>
  <a href="http://www.example.com/">inline URL</a>
  <a href="tg://user?id=123456789">inline mention of a user</a>
  <code>inline fixed-width code</code>
  <pre>pre-formatted fixed-width code block</pre>
  <pre><code class="language-javascript">pre-formatted fixed-width code block written in the Javascript programming language</code></pre>

Please note:

  • Only the tags mentioned above are currently supported.
  • All <, > and & symbols that are not a part of a tag or an HTML entity must be replaced with the corresponding HTML entities (< with &lt;, > with &gt; and & with &amp;).
  • All numerical HTML entities are supported.
  • The API currently supports only the following named HTML entities: &lt;, &gt;, &amp; and &quot;.
  • Use nested pre and code tags, to define programming language for pre entity.
  • Programming language can't be specified for standalone code tags.

sendPhoto

connected.sendPhoto(photo, caption, disable_notification = false, protect_content = false, reply_to_message_id);

| Parameter | Type | Required | Description | |------------------------|---------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | photo | InputFile or String | yes | Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. More information on Sending Files » | | caption | String | optional | Photo caption (may also be used when resending photos by file_id), 0-1024 characters after entities parsing | | reply_to_message_id | Integer | optional | If the message is a reply, ID of the original message | | disable_notification | Boolean | optional | Sends the message silently. Users will receive a notification with no sound. | | protect_content | Boolean | optional | Protects the contents of the sent message from forwarding and saving |

Methods with the same properties as sendPhoto

sendPhoto, sendVideo,sendDocument, sendAudio,sendAnimation, sendVideoNote,


sendPoll

connected.sendPoll(question, options, correct_option_id, is_anonymous, explanation, type, reply_to_message_id, disable_notification, protect_content)

| Parameters | Type | Required | Description | |------------------------|-----------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | question | String | yes | Poll question, 1-300 characters | | options | Array of String | yes | A JSON-serialized list of answer options, 2-10 strings 1-100 characters each | | correct_option_id | Integer | Optional | 0-based identifier of the correct answer option, required for polls in quiz mode | | is_anonymous | Boolean | Optional | True, if the poll needs to be anonymous, defaults to True | | type | String | Optional | Poll type, quiz or regular, defaults to regular | | explanation | String | Optional | Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing | | reply_to_message_id | Integer | Optional | If the message is a reply, ID of the original message | | disable_notification | Boolean | optional | Sends the message silently. Users will receive a notification with no sound. | | protect_content | Boolean | optional | Protects the contents of the sent message from forwarding and saving |

sendDice

connected.sendDice(emoji, disable_notification, protect_content, reply_to_message_id)

| Parameters | Type | Required | Description | |------------------------|---------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | emoji | String | Optional | Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲” | | reply_to_message_id | Integer | Optional | If the message is a reply, ID of the original message | | disable_notification | Boolean | optional | Sends the message silently. Users will receive a notification with no sound. | | protect_content | Boolean | optional | Protects the contents of the sent message from forwarding and saving |

sendLocation

connected.sendLocation (latitude, longitude, horizontal_accuracy, disable_notification = false, protect_content = false, reply_to_message_id)

| Parameters | Type | Required | Description | |------------------------|--------------|----------|--------------------------------------------------------------------------------| | latitude | Float number | Yes | Latitude of the location | | longitude | Float number | Yes | Longitude of the location | | reply_to_message_id | Integer | Optional | If the message is a reply, ID of the original message | | disable_notification | Boolean | optional | Sends the message silently. Users will receive a notification with no sound. | | protect_content | Boolean | optional | Protects the contents of the sent message from forwarding and saving |

sendContact

connected.sendContact (phone_number, first_name, last_name, disable_notification, protect_content, reply_to_message_id)

| Parameters | Type | Required | Description | |------------------------|---------|----------|--------------------------------------------------------------------------------| | phone_number | String | Yes | Contact's phone number | | first_name | String | Yes | Contact's first number | | last_name | String | Optional | Contact's last number | | reply_to_message_id | Integer | Optional | If the message is a reply, ID of the original message | | disable_notification | Boolean | optional | Sends the message silently. Users will receive a notification with no sound. | | protect_content | Boolean | optional | Protects the contents of the sent message from forwarding and saving |