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

raccoonjs

v2.0.2

Published

[![Build Status](https://travis-ci.org/josestg/raccoonjs.svg?branch=master)](https://travis-ci.org/josestg/raccoonjs)

Downloads

4

Readme

Raccoonjs : Mini-framework for Telegram Bots

Build Status

Making a telegram bot using Raccoonjs makes it easy for developers to focus on developing features.

One of Raccoonjs's goals is to be able to automatically execute the methods in each feature just by entering the name of the method to be executed in the callback data.

Why use Raccoonjs

  1. Easy workflow (focus on developing feature).
  2. Easily set how long a session for a feature over.
  3. The response format is easy to read, etc.

Quick Start

Create project

$ mdkir app
$ touch app/Task.js
$ touch main.js

Install racconjs

$ npm i [email protected]

Create Feature

// ./app/Task.js
const { Feature } = require("raccoonjs/Feature");
const { makeButton } = require("raccoonjs/helper");
const { ResponseMessage } = require("raccoonjs/ResponseMessage");
class Task extends Feature {
    constructor(onwer) {
        super(owner);
    }

    start() {
        const keyboard = [
            [
                makeButton("Left", {
                    prefix: this.prefix,
                    action: "onLeftClicked",
                    params: "1"
                }),
                makeButton("Right", {
                    prefix: this.prefix,
                    action: "onRightClicked",
                    params: "2"
                })
            ]
        ];

        return new ResponseMessage("$send", {
            owner: this.owner,
            message: "Hello, World!",
            inline_keyboard: keyboard
        });
    }

    onLeftClicked(params, context) {
        console.log(params); // 1
        // edit current message
        const { reply_markup } = context.message;
        return new ResponseMessage("$edit", {
            owner: this.owner,
            message: "Halo, Dunia!",
            inline_keyboard: reply_markup.inline_keyboard
        });
    }

    onRightClicked(params, context) {
        console.log(params); // 2
        // delete current message and destroy feature session
        return new ResponseMessage("$delete", {
            owner: this.owner,
            destroy: true
        });
    }
}

Generate SSL

$ openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem

Create Public URL using ngrok

#./ngrok http <port>
$ ./ngrok http 5000

Result:

ngrok by @inconshreveable                                       (Ctrl+C to quit)

Session Status                online
Account                       Jose Sitanggang (Plan: Free)
Version                       2.3.35
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://1234.ngrok.io -> http://localhost:5000
Forwarding                    https://1234.ngrok.io -> http://localhost:5000

Connections                   ttl     opn     rt1     rt5     p50     p90
                              72      0       0.00    0.00    5.73    45.72

Create Environment Variable

$ # e.q export BOT_TOKEN=<TOKEN>
$ export BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
$ # e.q export BASE_URL=<Forwading https>
$ export BASE_URL="https://1234.ngrok.io"

Create Main

// main.js
const { Raccoon } = require("raccoonjs/Raccoon");
const { Task } = require("./app/Task");
const R = new Raccoon(process.env.BOT_TOKEN, process.env.BASE_URL);

R.onText(/\/t/, context => {
    const { from } = context;
    const task = new Task(from.id);
    const token = R.registerFeature(from.id, task);
    R.start(token, task);
    R.deleteMessage(from.id, context.message_id);
});
R.watchFeatureCallback();

R.startServer(
    {
        port: 5000,
        cert: "path/to/cert.pem",
        key: "path/to/key.pem"
    },
    () => console.log("started")
);

Result

See more example

Similar Projects

  1. raccoonjs-example
  2. privy-standup-meeting-bot

Thank You

  1. Dimas
  2. M. Taufiq