1.1.7 • Published 1 year ago

tg-bot-sender v1.1.7

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year 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

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago