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

macramoji

v0.2.2

Published

A Slack-centric macro language for altering emoji

Downloads

25

Readme

Macramoji

npm version Build Status

A slack-centric programming language for altering emoji

How it works

Macramoji parses a simple functional programming language for emoji, where function names can either precede or follow the parenthesis and emoji are slack-style (i.e. beginning and ending with a :). For example:

(dealwithit(:rage1:, :kamina-glasses:))splosion

This produces the following gif (assuming you have kamina-glasses):

dealwithit-rage1-kamina-glasses-splosion

Defined macros

  • dealwithit(<base> [, glasses]) - Draw sunglasses that descend onto the base emoji. Optionally, provide the emoji for the glasses that will be used.
  • (<base>)splosion - Draw the base emoji followed by an explosion
  • firstframe(<base>) - Take the first frame of base
  • lastframe(<base>) - Take the last frame of base
  • (<base>)intensifies - Make the last frame of base shake intensely
  • (<base>)skintone_1 - Colorize base in Fitzpatrick skin tone 1. Tones 1-6 are defined

Reference Implementation: Hubot script

This script allows you to message a hubot instance with the command emojify (dealwithit(:rage1:, :kamina-glasses:))splosion

macramoji = require 'macramoji'
refreshSeconds = 15 * 60 # refesh emoji list every 15 minutes
module.exports = (robot) ->
  emojiFetchFn = (callback) ->
    robot.adapter.client.web.emoji.list (err, result) ->
      return callback(err) if err
      callback(err, result.emoji)
  emojiStore = new macramoji.EmojiStore(emojiFetchFn, refreshSeconds)
  processor = new macramoji.EmojiProcessor(emojiStore, macramoji.defaultMacros)

  robot.respond /emojify (.*)/i, (res) ->
    emojiStr = res.match[1].trim()
    processor.process emojiStr, (slackResp) ->
      slackResp.respondHubot(res)

Defining Your Own Functions

Arbitrary emoji-processing functions are straightforward to add; they are GraphicsMagick (or ImageMagick) scripts. Their input arguments will be an array of paths and a callback function. The callback takes a single parameter -- an ImageResult. The ImageResult conveys the result (if successful), any error messages (if unsuccessful) and a set of ImageContainer objects for any temporary files created during the processing that would need to be cleaned up later.

What Macramoji guarantees

  • your function will only be called if the input arguments successfully resolve to ImageResults
  • all input image arguments will automatically be rescaled to the size of the smallest image

What Macramoji does not guarantee

  • input animations may need to be coalesced
  • no alpha channel is explicitly provided
  • your function may not receive all the arguments it expects (in which case, you should return an ImageResult that holds an error message)

A basic exaple is greyscale which converts an emoji to greyscale:

imageTransform = (require 'macramoji').imageTransform

greyscaleMacro = (paths, callback) ->
  greyWorkFn = (inputGmObject) ->
    inputGmObject.modulate(100, 0) # http://aheckmann.github.io/gm/docs.html#modulate
  imageTransform.resultFromGM gm(paths[0]), greyWorkFn, callback

# assume processor = new macramoji.EmojiProcessor as above
processor.addMacro("greyscale", greyscaleMacro)

You are encouraged to contribute functions that you write back to this project by adding them to defaultMacros.coffee.

Known Issues

TODO

  • Check that proper cleanup is happening
  • Enable slack reponses without hubot

Author

Macramoji was written by Ian Katz in 2017, after realizing that making explosion gifs for literally hundreds of emoji just wasn't scalable.