tg-bot-sender
v1.1.7
Published
This lib for sending messages to bot
Downloads
36
Maintainers
Readme
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))