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

botsito

v0.0.1

Published

Mentor bot

Downloads

1

Readme

Botsito extension

Extending botsito is pretty straight forward. Within the scripts/students directory, create a new file. In the file, declare a named function. Let's use a for the purposes of example.

function a() {

}

In order to interact with botsito, our function will receive it as a parameter.

function a(botsito) {

}

Having botsito within our function scope allows us to interact with it. The following methods are available:

botsito.logger.info

Logs to the console. Helpful for debugging.

Takes in a single parameter. The value of what is gonna be logged.

Returns undefined.

function a(botsito) {
  botsito.logger.info('function "a" is being loaded');
}

botsito.logger.error

Logs to the console. It's used when we want to inform ourselves that something went wrong.

Takes in a single parameter. The value of what is gonna be logged.

Returns undefined.

function a(botsito) {
  botsito.logger.error(new Error('omg something went wrong'));
}

botsito.brain.get

Looks for a previously stored value in botsito.

It takes a single parameter. The key used to fetch the value;

Returns the value previously stored.

function a(botsito) {
  var b = botsito.brain.get('my key');
  if (!b) {
    return botsito.logger.error(new Error('b is undefined!'));
  }
}

botsito.brain.set

Stores a value within botsito.

Takes two parameters. First parameter is the key for which you will look for it later via botsito.brain.get. The second parameter is the value you wish botsito to store.

function a(botsito) {
  botsito.brain.set('my key', 'my valueeee');
  var b = botsito.brain.get('my key');
  if (!b) {
    return botsito.logger.error(new Error('b is undefined!'));
  }

  botsito.logger.info(b);
}

botsito.listen

Interface in which botsito receives messages and acts upon them.

Takes two parameters. Both are functions.

First parameter function receives a single parameter called msg. It holds properties like text (the message posted) and user (the poster of the message). In this function you will determine if you will act upon the msg received. This function must return true or false.

Second parameter function receives a single parameter called response. It holds the method reply which allows us to write to the channel. This is where you will put the bulk of your logic will live. This function will only be called if the first parameter function returned true.

function a(botsito) {

  function validator(msg) {
    var willReply = false;
    if (msg.text.indexOf('pi time') !== -1) {
      willReply = true;
    }
    return willReply;
  }

  function postBack(response) {
    return response.reply('PI TIMEEEEE');
  }

  botsito.listen(validator, postBack);
}

This function will listen for messages that include the phrase pi time and will reply with PI TIMEEEEE to the channel.

The response object also contains additional information inside the envelope property. Try logging this property out to see what you learn.

Exposing the function

Once you are satisfied with your function, we need to make it readable. To do so, add the following line at the end of your file:

module.exports = a;

That's it! Now your function is ready to join botsito.