1.2.3 • Published 2 years ago

plaintl v1.2.3

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
2 years ago

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

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago