1.1.7 • Published 10 months ago

tg-bot-sender v1.1.7

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

Link to the documentation

Nodejs

How to install ?

npm i tg-bot-sender

Imports

import { TelegaSender, Methods, Data } from "tg-bot-sender";

The structure of the Data message

type Data = {
    text: string,
    photo?: string,
    buttons?: {
        buttonTitle: string,
        buttonUrl: string
    }[]
}

Response structure

{ "amount": 0 } // number of messages sent

Getting started

The logs parameter indicates that logs are saved in json format

const tg = new TelegaSender(telegramToken, pathForLogs, logs = false)

Options for sending messages

Sending photos

Methods.sendPhoto

sendFromIds - sending to users

tg.sendFromIds([...telegramUserIds], {
    text: 'Hello from npm',
    photo: 'Photo link',
    buttons:[{
        buttonTitle: 'Hello',
        buttonUrl: 'https://google.com'
    }]
}, Methods.sendPhoto)
    .then((res: any) => console.log(res))
    .catch((err: any) => console.log(err))

sendFromId - sending to the user

tg.sendFromIds(telegramUserId, {
    text: 'Hello from npm',
    photo: 'Photo link',
    buttons:[{
        buttonTitle: 'Hello',
        buttonUrl: 'https://google.com'
    }]
}, Methods.sendPhoto)
    .then((res: any) => console.log(res))
    .catch((err: any) => console.log(err))

Sending a message

Methods.sendMessage

sendFromIds - sending to users

tg.sendFromIds([...telegramUserIds], {
    text: 'Hello from npm',
    buttons:[{
        buttonTitle: 'Hello',
        buttonUrl: 'https://google.com'
    }]
}, Methods.sendMessage)
    .then((res: any) => console.log(res))
    .catch((err: any) => console.log(err))

sendFromId - sending to the user

tg.sendFromIds(telegramUserId, {
    text: 'Hello from npm',
    buttons:[{
        buttonTitle: 'Hello',
        buttonUrl: 'https://google.com'
    }]
}, Methods.sendPhoto)
    .then((res: any) => console.log(res))
    .catch((err: any) => console.log(err))
1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago