Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

telegram-ts-api

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telegram-ts-api

High level wrapper for node-telegram-bot-api

  • 1.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Telegram API - TypeScript

How to start

  1. Install lib via github or npm
  • Import lib via import Telegram from "./src/Telegram";
  • To set up your Telegram API key use Telegram.launchBot(TELEGRAM_API); where TELEGRAM_API is your bot token
  1. How to send messages?
  • For sending message to specific user you should know his/her user_id
   const user_id = 100000;
   await Telegram.user(user_id).message(`Hello!`);
  1. How to use buttons?

3.1 Keyboard buttons

    const button = Telegram.button('keyboard', {pageId: "Main", name: "Phone Number Get", layer: 0});
## Attributes
- pageId - (string or number): used to create specific space where the button is located
- layer - (number): row on the page where the button is located
- name - (string): button name

To force the button to process events, call the following code
    const button = Telegram.button('keyboard', {pageId: "Main", name: "Phone Number Get", layer: 0});
    
    button.click(async (msg: any) =>
    {
        const id = msg.from.id;
        const name = msg.from.name;

        // On event open another button page using 'messageWithData'
        // Second argument 'true' is 'one_time_keyboard'
        // If it's true after click event keyboard will close
        await Telegram.user(id).messageWithData("hi", await Telegram.getKeyboardButtonPageById("Phone Number", true));
    });

3.2 Inline buttons

    const button = Telegram.button('keyboard', {pageId: "Main", name: "Phone Number Get", layer: 0});
## Attributes
- pageId - (string or number): used to create specific space where the button is located
- layer - (number): row on the page where the button is located
- name - (string): button name

To force the button to process events, call the following code
    const button = Telegram.button('inline', {pageId: "Main", callback: "Main", name: "Phone Number Get", layer: 0});
    
    button.click(async (msg: any) =>
    {
        const id = msg.from.id;
        const name = msg.from.name;

        await Telegram.user(userId).messageWithData("hi", await Telegram.getInlineButtonPageById("Main"));
    });

Keywords

FAQs

Package last updated on 24 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc