Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Bot authorization:
const Bot = require('nk-ntba');
let bot = new Bot('API token of your bot');
Events for listening updates:
message
edited_message
channel_post
edited_channel_post
inline_query
chosen_inline_result
callback_query
shipping_query
pre_checkout_query
poll
poll_answer
my_chat_member
chat_member
chat_join_request
reply_to_message
For specific types of messages:
text
animation
audio
channel_chat_created
contact
delete_chat_photo
dice
document
game
group_chat_created
invoice
left_chat_member
location
migrate_from_chat_id
migrate_to_chat_id
new_chat_member
new_chat_photo
new_chat_title
passport_data
photo
pinned_message
poll
sticker
successful_payment
supergroup_chat_created
video
video_note
voice
voice_chat_started
voice_chat_ended
voice_chat_participants_invited
voice_chat_scheduled
message_auto_delete_timer_changed
chat_invite_link
chat_member_updated
To use specific types of messages in listener you should write event with prefix message.
, for example message.text
.
Adding a listener to some event:
bot.setCallback('your event', callback);
Removing a listener:
bot.removeCallback('your event');
Starting listener:
bot.start({
short_polling: 500
});
or
bot.start({
long_polling: 60
});
Webhookes are not available yet.
Stoping listener:
bot.stop();
Downloading file by file_id
:
const fs = require('fs');
const Bot = require('nk-ntba');
let bot = new Bot('API token of your bot');
(async () => {
await bot.downloadFile('your file_id', fs.createWriteStream('your file'));
})();
All other methods are async and need await
or .then
constructions (.catch
is not used, promise is always resolved).
You can check available methods in source code of this library.
Example of echo bot:
const Bot = require('nk-ntba');
let bot = new Bot('API token of your bot');
bot.setCallback('message.text', async (msg) => {
let cid = msg.chat.id;
let msgid = msg.message_id;
let tx = msg.text;
let r = await bot.sendMessage(cid, `You sent: ${tx}`);
setTimeout(() => {
bot.deleteMessage(cid, msgid);
bot.deleteMessage(cid, r.message_id);
bot.sendMessage(cid, `Messages were deleted after 5 sec`);
}, 5000);
});
bot.listen({
long_polling: 300
});
FAQs
Telegram Bot Api library for NodeJS. Developer's telegram: @NekitKuzmenko
We found that nk-ntba demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.