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

@ilyadrmx/aminojs

v1.0.97

Published

Library for access to the Amino API (AminoApps)

Downloads

7

Readme

Status GitHub Issues License


📝 Table of Contents

🧐 About

This library easily allows you to use Amino API. Notice that this library is not official AND according to Narvii's TOS it is prohibited. You can get banned if you use this library. The author is not responsible for the use of AminoJS.

🎈 Usage

Here will be some notes how to use AminoJS.

Prerequisites

Firstly, you should have up-to-date Node JS version. Do not forget to install NPM manager.

Installing

After installing Node JS and NPM, you should create your project. Just make a folder for your bot. For example, we will create folder named "AminoJSBot". Then you should open your CMD or Terminal and open this folder.

Open terminal and type

cd PATH_TO_YOUR_FOLDER

And then you need to install AminoJS package.

npm install @ilyadrmx/aminojs

NPM manager will download all files that you need.

Setting bot folder

I recommend that you create a folder named "bot" inside of our "AminoJSBot" folder. Then, inside of "bot" folder you should create two files:

  • main.mjs
  • config.mjs

So, we have a project structure like this:

AminoJSBot
¦    package-lock.json
¦    package.json
¦
+--- bot
¦       config.mjs
¦       main.mjs
¦       
L--- node_modules
     ...

Creating simple bot

Firstly, let's login our bot. Open "main.mjs" file (/AminoJSBot/bot). Now, let's import AminoJS library.

import { Client, SubClient } from "@ilyadrmx/aminojs";

So, we've imported library and now we need to make an instance of Client class. It allows us to use Amino's global user features.

const client = new Client(null, false); // Don't change if you don't know what is this
client.login("YOUR_EMAIL", "YOUR_PASSWORD"); // Here you should replace text

Lines that we've added above allows our bot to login. Now we should to make an instance of SubClient class. It allows us to use Amino's community user features.

const client = new Client(null, false);
client.login("YOUR_EMAIL", "YOUR_PASSWORD")
    .then(() => { // .then() is necessary
        const subClient = new SubClient(client, "COM_ID");
    });

Com ID is an ID that allows you to enter in community. You can easily get a list of communities by this code:

const client = new Client(null, true);
client.login("YOUR_EMAIL", "YOUR_PASSWORD")
    .then(() => {
        client.getSubClients()
            .then((communities) => { // .then() is necessary
                for (let community in communities) {
                    let com = communities[community];
                    console.log(`${com.name}: ${com.ndcId}`);
                }
            });
    });

Copy the id of the current community and paste it in "COM_ID" field. Now, let's create a message listener. You should make a WebSocket listener for amino by using

client.startListeningMessages();

But if you don't know how to do it, just get code here. Paste this code in "config.mjs" (/AminoJSBot/bot). Now your "config.mjs" code structure is

export function customSocketListening(client, subClient) {
    client.startListeningMessages();
    client.ws.then((webSocket) => {
        /**
         * It's when everyting works
         */
         webSocket.on(
            "open", () => {
                // ...
            }
        );

        /**
         * It's when client got Amino message
         */
        webSocket.on(
            "message", (message) => {
                // ... 
            }
        );

        /**
         * It's when something does not work and it needs to restart
         */
        webSocket.on(
            // ... 
        );
    });
}

We are going to create a bot, that replies user the message after command. How it will work:

User: /say Hello!

Bot: Reply to: User Hello!

So, we need to take user's text after "/say" word. In JavaScript, we use

String.substring()

Now, let's implement this to our code

// ...

webSocket.on(
    "message", (message) => {
        var data = toJson(message).o; // This is necessary
        data = data.chatMessage;
        /**
         * Empty text check
         */
        if (typeof data.content !== "undefined" && data.author.uid !== client.profile.uid) {
            /**
             * Command "/say" check
             */
            if (data.content.toLowerCase().startsWith("/say ")) {
                try {
                    subClient.replyTo(
                        data.threadId,
                        data.messageId,
                        data.content.substring(5)
                    );
                } catch (e) {
                    console.log("Noncritical error. " + e.toString());
                }
            }
        }
    }
);

// ...

We created the main logic for our command. Let's add it to Client.

import { Client, SubClient } from "../index";
import  { customSocketListening } from "./config"; // Import our function above from config file

const client = new Client(null, true);
client.login("YOUR_EMAIL", "YOUR_PASSWORD")
    .then(() => {
        const subClient = new SubClient(client, "COM_ID");
        customSocketListening(client, subClient);
    });

And that's all!

✍️ Authors