plaintl

1.2.3 • Public • Published

PlainTL

A plain telegram listener based on GramJS

Installation

# npm
npm i plaintl

# yarn
yarn add plaintl
// esm
import { startSession, eventEmitter } from "plaintl"

// cjs
const { startSession, eventEmitter } = require("plaintl")

Usage

Listen to Requires events and then submit your values with emitter functions. (only for the first session)

eventEmitter
    .on("RequiresPhoneNumber", (phoneNumberEmitter) => {
        phoneNumberEmitter("+989990009999")
    })
    .on("RequiresPhoneCode", (phoneCodeEmitter) => {
        phoneCodeEmitter("550055")
    })
    .on("RequiresPassword", (passwordEmitter) => {
        passwordEmitter("password")
    })
    .on("RequiresFirstAndLastNames", (firstAndLastNamesEmitter) => {
        firstAndLastNamesEmitter("firstname", "lastname")
    })

Preparing provider parameters.

Obtain apiId and apiHash from here.

For receive phone code via SMS set forceSMS to true.

For logLevel, one can select between error , warn , info , debug or none.

const providerParameters = {
    /* required */
    apiId: "your-api-id",
    apiHash: "your-api-hash",

    /* optional */
    forceSMS: false,
    logLevel: "info",
}

Start PlainTL session.

// async
const client = await startSession(providerParameters)

// sync
startSession(providerParameters).then((client) => {
    //
})

Listen to Telegram Update events.

eventEmitter.on("UpdateShortMessage", (event) => {
    console.log(event)
})

Cli

# npm
npx plaintl

# github
npx github:dalirnet/plaintl

Limitation

  • Not browser-compatible.

Update events

/plaintl/

    Package Sidebar

    Install

    npm i plaintl

    Weekly Downloads

    2

    Version

    1.2.3

    License

    GPL-3.0

    Unpacked Size

    60.8 kB

    Total Files

    11

    Last publish

    Collaborators

    • dalirnet