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

ssb-bot

v1.0.0

Published

create conversational user interfaces (bots) on Scuttlebutt

Downloads

2

Readme

ssb-bot :computer: :speech_balloon:

npm install --save ssb-bot

what?

original post: %2JaltAdhcWnJwOXJPbHvGE9+SlVrR7Vfq+RhJbMhVUM=.sha256

ssb-bot is scuttlebot plugin to help make it easy to develop conversational user interfaces, similar to a Slack bot or a Facebook Messenger bot.

example

var bot = Bot({
  name: 'greeter',
  version: '0.0.0',
  initBot: (sbot) => {
    var { id } = sbot.whoami()
    var hasMentionForBot = hasMentionFor(id)

    return {
      handleMessage,
      handleAction
    }

    function handleMessage (state, message) {
      if (hasMentionForBot(message)) {
        return {
          state,
          action: {
            type: 'hello',
            id: message.value.author
          }
        }
      }

      return { state }
    }

    function handleAction (action, sbot, cb) {
      var { type } = action
      if (type === 'hello') {
        var { id } = action
        sbot.about.get((err, abouts) => {
          if (err) return cb(err)
          var name = abouts[id].name[id][0]
          cb(null, {
            type: 'post',
            text: `hello [@${name}](${id})!`,
            mentions: [
              {
                name,
                link: id
              }
            ]
          })
        })
      }
      else cb()
    }
  }
})

see example.js for the full example source.

with your main Scuttlebutt client (such as Patchwork) running, run node example, which should create a new bot who will request to replicate with your current feed.

if you @mention this new bot, it should respond with hello ${name}!

(you may need to restart the bot once or twice after sending a message)

why?

@mix brought up the idea of developing systems butt-first: %3MS64b+lB4Dk5gag8tJKnA+zy8BEQ2cLmyxF06sBKyM=.sha256. with this approach, we use ssb as a database, where a "api call" is publishing a message to your feed and a "database transaction" is the bot publishing a message to their feed.

i want to make it easier for people to create pub invites, as currently the only way is for a pub owner to ssh into their server and run sbot invite.create 1. (easy-ssb-pub gets around this by allowing anyone to create an invite from a public webpage, but i want something to help the network grow with personal invites.)

so i'm interested in a conversational approach to creating invites. i want to be able to private message a pub and say "hey can i have an invite?" and the pub responds with "sure, here you go: .... !"

how?

inspired by Elm or inu:

a bot is two functions:

handleMessage receives the current state and the next message, returns the next state and any new actions.

var handleMessage = (state, message) => {
  return {
    state: nextState,
    action
  }
}

handleAction receives the new action and asyncronously returns (via the callback) a new message to publish.

var handleAction = (action, sbot, callback) => {
  var content = {
    type: 'post',
    text: 'did i hear something?'
  }
  cb(null, content)
}

license

The Apache License

Copyright © 2017 Michael Williams

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.