Socket
Socket
Sign inDemoInstall

telelib

Package Overview
Dependencies
52
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    telelib

An interface for the Telegram Bot API


Version published
Weekly downloads
4
decreased by-71.43%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Telelib

This is an ESM compliant implementation of the Telegram Bot API. It can handle much of the heavy lifting for you.

Currently, Node.js can only have ES modules enabled while using the --experimental-modules argument when running the node executable. You will currently need to be running a version of node that supports ES modules if you want to take advantage of them. If you wish to run in compatability mode with CommonJS modules, you can use require("telelib/index.cjs") to access it. This module was developed on the v12 branch of Node.js, and may not be compatible with older releases.

You can easily start making a bot with the BotController class in telelib. Here is some example code to show you how it's done!

import { BotController } from "telelib/BotController";
const bot = new BotController("123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11");
function isDeveloperUser(message) {
    "use strict";
    return message.from.id === 777000;
}
function isPrivateChat(message) {
    "use strict";
    return message.chat.type === "private";
}
async function onHelloCommand(message) {
    "use strict";
    await message.sendMessage({
        text: "<b>Hello</b> <i>World</i>!",
        parse_mode: "HTML",
    });
}
bot.on("message", onHelloCommand, "/hello", isDeveloperUser);
bot.on("edited_message", onHelloCommand, "/hello", isDeveloperUser, isPrivateChat);
bot.on("channel_post", onHelloCommand, "/hello");
bot.on("edited_channel_post", onHelloCommand, "/hello");
bot.start();

Keywords

FAQs

Last updated on 03 Oct 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc