1.1.7 • Published 1 year ago
tg-bot-sender v1.1.7
Nodejs
How to install ?
npm i tg-bot-senderImports
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 sentGetting 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.sendPhotosendFromIds - 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.sendMessagesendFromIds - 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))