messaging-telegram-bot-api
v1.0.4
Published
This package will be used to send the messages to Telegram Channels and Groups.
Downloads
10
Maintainers
Readme
Messaging Telegram Bot API
This package is created by using Telegram Bot API to send message to Public Telegram Group and Telegram Channel via installed Bot.
- TelegramBotMemberAccess use to confirm the existence of telegram group/channel and also confirmed that bot is already installed
- TelegramBot use to send the message to telegram group/channel where bot is already installed
Installation
npm install messaging-telegram-bot-api
Usage
TelegramBotMemberAccess
const { TelegramBotMemberAccess } = require("messaging-telegram-bot-api");
const token = "bot_token_here";
const options = {
method: "sendMessage",
action: "member_access",
chat_id: "telegram group channel name",
tg_bot_username: "bot username here",
bot_dsiplay_name: "Bot display Name",
};
async function confirmTelegramGroupChannelExistence() {
try {
const bot = new TelegramBotMemberAccess(token, options);
const response = await bot.sendRequest();
console.log("response: ", response);
} catch (error) {
console.log("error", error);
}
}
confirmTelegramGroupChannelExistence();
TelegramBot
const { TelegramBot } = require("messaging-telegram-bot-api");
const token = "bot_token_here";
const content = `<b>Token Name: Demo</b>
Token Symbol: Demo
Description: Demo Description Here
Hard Cap: 1
Soft Cap: 1
Chain: 123
Tokens Per BNB: 123
Date & Time: Date/Time Here
Minimum Buy: 1
Maximum Buy: 1
<a href="link_url">HREF CAPTION IF ANY NEEDED</a>`;
const header_image_url = "header_image_URL_here";
const presale_listing_link = "presale_link_url_here";
const presale_listing_link_caption = "Presale Link Test";
const options = {
method: "sendPhoto",
action: "send",
message: {
chat_id: "group_name_here",
image_url: header_image_url,
content,
button_link: presale_listing_link,
button_caption: presale_listing_link_caption,
},
};
async function sendTelegramTestMessage() {
try {
const bot = new TelegramBot(token, options);
const response = await bot.sendRequest();
console.log("response:", response);
} catch (error) {
console.log("error:", error);
}
}
sendTelegramTestMessage();