npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

telegram-bot-mark-loku

v1.0.7

Published

This npm package is a lightweight and efficient solution designed to streamline the process of sending messages via Telegram Bot API. Whether you're a developer building a sophisticated bot or an enthusiast experimenting with Telegram's capabilities, this

Downloads

3

Readme

telegram-bot-mark-loku

Install

1 - Create a new JavaScript file in your project directory. You can name it something like bot.js.

2 - Open the bot.js file in a code editor of your choice.

Uses

3 - Begin by requiring the npm i telegram-bot-loku package at the top of your file:

#CODE: 

    const TelegramBot = require('telegram-bot-loku');

4 - Initialize the bot by passing your API token and enabling the polling option. This allows the bot to listen for and receive new messages:

#CODE: 

    const token = 'YOUR_TELEGRAM_BOT_TOKEN'; // Replace with your own bot token
    const channel = 'YOUR_TELEGRAM_BOT_CHANNEL'; // Replace with your own bot channel
    const message = 'Hi Everyone'; // Replace with your message

    async function sendMessage() {
        try {
            const telegramResponse = await telegramInstance.sendMessage("token", "channel", "Hi");
            console.log(telegramResponse);
            return telegramResponse;
        } catch (error) {
            console.error('Error:', error);
            throw error; // Re-throw the error if necessary
        }
    }

5 - Add an event listener to handle incoming messages. This listener will be triggered whenever a user sends a message to your bot:

#CODE: 

    sendMessage()
    .then(response => {
        console.log('Success:', response);
    })
    .catch(error => {
        console.error('Error:', error);
    });

By following the previous steps, your bot.js file will look like this:

#CODE: 

    const telegramInstance = require('telegram-bot-loku')

    const token = 'YOUR_TELEGRAM_BOT_TOKEN'; // Replace with your own bot token
    const channel = 'YOUR_TELEGRAM_BOT_CHANNEL'; // Replace with your own bot channel
    const message = 'Hi Everyone'; // Replace with your message

    async function sendMessage(token,channel,message) {
        try {
            const telegramResponse = await telegramInstance.sendMessage(token, channel, message);
            console.log(telegramResponse);
            return telegramResponse;
        } catch (error) {
            console.error('Error:', error);
            throw error; // Re-throw the error if necessary
        }
    }

    sendMessage().catch(error => {
        console.error('Error:', error);
    });

Running the Bot

1 - Open a terminal or command prompt and navigate to your project directory.

2 - Run the command node bot.js to start the bot. You should see a message indicating that the bot is running and waiting for incoming messages.

3 - Switch to the Telegram app on your device and find your bot by its username or display name.

4 - Send a message to your bot and observe its response. If you implemented the /start command, you should receive a welcome message.