Code Monkey home page Code Monkey logo

slack-pokemon-emoji's Introduction

slack-pokemon-emoji

A tool to upload all the pokemon to slack emoji.

slack-pokemon-emoji

Installation

Install Docker: https://docs.docker.com/engine/installation/

or

Install Package Locally

$ npm install slack-pokemon-emoji -g

Requirement

  • team Your team name.
  • cookie Slack does not have an api to upload emoji, so we have to emulate a browser environment to pass the cookie to our request. You can find the cookie from the Chrome devtools Networks tab, and it's under Header tab of any request.

cookie

Usage

Docker:

./run-docker.sh TEAM "COOKIE"

Local Install:

$ slack-pokemon-emoji TEAM "COOKIE"
# or
$ slack-pokemon-emoji -t TEAM -c "COOKIE"
# or
$ slack-pokemon-emoji team=TEAM cookie=COOKIE

How it works?

Fetch pokemon images from http://www.pokemon.com/us/pokedex/

Do this in Chrome devtools and get all the pokemon indexs

/**
 * Quick and dirty jQuery script to extract pokemon name and image url
 */
var pokemons = $($0).find('li').toArray().map(function(li) {
  return {
    imgSrc: $($(li).find('figure')[0]).find('img')[0].src,
    name: $($(li).find('.pokemon-info')[0]).find('h5')[0].innerHTML
  }
})

Download all the images to local and resize them to 128 * 128

$ node index.js

Resize all the images and rename it to pokemonname.png

pokemons.forEach(function (pokemon) {
  var readStream = hyperquest.get(pokemon.imgSrc)
  gm(readStream)
    .resize('128', '128')
    .stream()
    .pipe(fs.createWriteStream(`./images/${pokemon.name.toLowerCase()}.png`))
})

Upload all images to slack

$ node uploader.js

Tools

  • gm A nodejs wrapper for imageMagick, used for resizing image
  • hyperquest A nodejs stream based http request utils
  • cheerio A nodejs module to parse html text on server side
  • form-data A nodejs module to build form data and upload to slack

Slack does not provide a upload emoji api, and this tool is inspired by slack-emojinator.

Some of the code here use ES6 syntax so you might need nodejs 4.. to run the code.

License

MIT

slack-pokemon-emoji's People

Contributors

fraserxu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.