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

chatbox-utility

v1.0.6

Published

A package to handle chat functionalities and file downloads for facebook chatbot messenger!

Downloads

71

Readme

# chatbox-utility

A package that provides chat utilities, text formatting styles, and file downloading features.

## Installation

Install the package using npm:

```bash
npm install chatbox-utility

Usage

Importing the Package

After installation, you can import the package in your code:

const { OnChat, font } = require('chatbox-utility');

Font Styles

You can use the font object to apply different text styles:

console.log(font.bold("Bold text"));
console.log(font.italic("Italic text"));
console.log(font.underline("Underlined"));

OnChat Class

Creating an Instance of OnChat

You need to pass your apiObject and eventObject to create an instance of OnChat:

// can be embeded in auto, mirai, goatbot cmds
module.exports["run"] = async ({ api, event }) => {

const box = new OnChat(api, event);
      box.reply("hello world", event.threadID);
}

Methods of OnChat

Here’s a list of available methods:

  • log(text): Logs a message with a rainbow effect.

    box.log("Hello, World!");
  • profile(link, caption, date): Changes the profile picture.

    /* this will change your bot fb profile picture*/
    box.profile('https://example.com/image.jpg', 'Profile Updated');
  • post(message): Creates a post.

    /* this will post a content in your fb bot*/
    box.post("Your post content here.");
      
    /* to attach image in your post*/
    box.post({ body: "my caption", attachment: await box.stream("your image url, you can also change this into array to attach multiple url image all at once") })
  • react(emoji, messageID, isReaction): Reacts to a specific message with an emoji.

    box.react('👍', event.messageID);
  • reply(message, threadID): Replies to a message in a thread.

    box.reply("Hello!", event.threadID);
  • nickname(name, userID): Changes the nickname in a group chat.

    box.nickname("New Nickname", '123456789');
    /* this doesnt work sometimes on other gc idk the reason */
  • userInfo(userID): Retrieves information about a user.

    box.userInfo('123456789').then(info => box.reply(JSON.stringify(info)));
  • arraybuffer(url, extension): Downloads a file as an array buffer.

    box.arraybuffer('https://example.com/image.png', 'png').then(buffer => {
        box.reply(buffer) /* converted to base64 */
    });

-stream(url): Streams the file url directly without needing to download.

box.stream('https://example.com/image.png').then(stream => {
    box.reply(stream) /* converted to stream response */
});
  • cover(link): Changes the cover photo of the chatbot.

    box.cover('https://example.com/cover.png');

API Reference

font Styles

  • bold: Makes text bold.
  • italic: Makes text italicized.
  • underline: Underlines the text.
  • monospace: Renders text in monospace font.
  • strike: Strikes through the text.
  • roman: turns the text to roman style.
  • bubble: turns the text to bubble style.
  • squarebox: turns the text to squarebox style.
  • thin: makes the text thin.
  • origin: turns any text with font style back to original.

OnChat Methods

| Method | Description | |---------------------|-------------------------------------------------------------------| | log(text) | Logs a rainbow-style message to the console. | | error(text) | Logs an error message in red. | | profile(link) | Changes the bot's profile picture. | | post(message) | Posts a content. | | react(emoji) | Reacts to a specific message. | | nickname(name) | Changes the nickname of the bot in a chat. | | userInfo(id) | Retrieves user information by ID. | | reply(message) | Sends a reply message in a thread. | | arraybuffer(url) | Downloads a file from the provided URL as an array buffer. | | stream(url) | stream the file url directly without downloading. | cover(link) | Changes the cover photo of the chatbot. |

Error Handling

If any method throws an error due to missing arguments, a relevant error message will be displayed.

For example:

box.reply(); // Throws an error due to "Missing parameters or message to reply!" you will need handle it manually using try catch

Contributing

Feel free to open issues or submit pull requests to improve this package.

License

This package is licensed under the MIT License.