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

message-suite-fisherman

v1.0.1

Published

A middleware used to add some features to fisherman, like bot typing, or Embed compatibility

Downloads

7

Readme

Message Suite - Fisherman

Add some message features to fisherman. Copyrights (c), Simon Sassi 2017

What is the message suite

The message suite is a fisherman middleware that is using the prototype editing available by fisherman It edits the FisherResponse prototype to provide some cool features like:

  • Bot Typing: send a message with a delay to simulate real user typing, with response.send()
  • Embed compatibility: it checks if the bot can send embed, if it can't, it convert the embed to a formatted text

Setting up

npm install --save command-loader-fisherman

Include the middleware to the bot:

[...]
const MessageSuite = require("message-suite-fisherman")
var messageSuitePlugin = new MessageSuite({enableTyping: true, enableEmbedCompatibilityMode: true})
bot.use(messageSuitePlugin)
[...]

Api docs

new MessageSuite(opts)

Creates an instance of MessageSuite.

MessageSuite constructor options

| Parameter name | Description | Type | Default value | |------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|----------|---------------| | enableTyping | Enable typing when it's a command and response.send() is used | Boolean | false | | defaultTypingCount | Default typing count when no typing count is specified in the command's locales | Integer | 1 | | defaultTimeout | Default timeout in MS to send the message after starting typing when no timeout is specified in the command's locales | Integer | 1000 | | enableEmbedCompatibilityMode | If it should enable the Compatibilty mode, it will send formatted text instead of an embed if the bot hasn't the perm EMBED_LINKS | Boolean | true | | embedCompatibilityModeFormat | The function used to convert the embed to formatted text | Function | defaultFormat |

Setting the embedCompatibilityModeFormat options

This parameter is an option used to parse the embed.

The default value is a simple function who looks like this:

  defaultFormat (embed) {
    var formatted = ''
    if (embed.title) formatted = formatted + '__' + embed.title + '__\n'
    if (embed.description) formatted = formatted + '\n' + embed.description + '\n'
    if (embed.fields) for (var i in embed.fields)formatted = formatted + '=> **' + embed.fields[i].name + '**\n ' + embed.fields[i].value + '\n'
    return formatted
  }

The embed parameter is an Object. This function has to return a string value

Custom timeout and typing count in the command locales property

You can set as well the timeout and the typing count in the command's locales property:

Example with a timeout of 5s and a typing count of 1

register.textCommand('test', {locales: {typingCount:1, typingTimeout:5000}}, function (req, res) {
  console.log("Command trigerred")
  var embed = {
    title: "a test",
    description: "Just a simple test",
    fields: [{name: "Cat title", value: "Guoi daziou duoaoauj dqiupou"},{name: "Cat title", value: "Guoi daziou duoaoauj dqiupou"}]
  }
  res.send("ok", {embed: embed})
})