Created
April 6, 2012 16:11
-
-
Save jacobk/2321047 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Flip things!!! | |
# | |
# flip <something> - Flips something | |
# flip <something>, <something else>, ... - Flips all the things | |
# FLIP!?|flip! <something> - Really flips something | |
module.exports = (robot) -> | |
robot.respond /FLIP( ME)? (.*)/, (msg) -> | |
msg.send flip_angry(msg.match[2]) | |
robot.respond /flip( me)? ?(.*)?/, (msg) -> | |
what = msg.match[2] | |
if not what? | |
msg.send flip_calm() | |
else | |
what = what.split(',') | |
if what.length > 1 | |
msg.send flip_all_the_things(what...) | |
else | |
msg.send flip_calm(what[0]) | |
TABLE = '\u253B\u2501\u253B' | |
flip_calm = (what=TABLE) -> | |
flipper = "(\u256F\u00B0\u25A1\u00B0)\u256F\uFE35" | |
"#{flipper}#{flip_string what}" | |
flip_angry = (what) -> | |
flipper = "(\uFF89\u0CA5\u76CA\u0CA5)\uFF89\uFE35" | |
"#{flipper}#{flip_string what}" | |
flip_all_the_things = (what...) -> | |
flipper = "\uFE35\u30FD(`\u0414´)\uFF89\uFE35" | |
left = what.splice 0, what.length/2.0 | |
"#{flip_string left.join(' ')}#{flipper}#{flip_string what.join(' ')}" | |
flip_string = (str) -> | |
mappings = # http://www.fileformat.info/convert/text/upside-down-map.htm | |
'\u0021': '\u00A1', '\u0022': '\u201E', '\u0026': '\u214B' | |
'\u0027': '\u002C', '\u0028': '\u0029', '\u002E': '\u02D9' | |
'\u0033': '\u0190', '\u0034': '\u152D', '\u0036': '\u0039' | |
'\u0037': '\u2C62', '\u003B': '\u061B', '\u003C': '\u003E' | |
'\u003F': '\u00BF', '\u0041': '\u2200', '\u0042': '\u10412' | |
'\u0043': '\u2183', '\u0044': '\u25D6', '\u0045': '\u018E' | |
'\u0046': '\u2132', '\u0047': '\u2141', '\u004A': '\u017F' | |
'\u004B': '\u22CA', '\u004C': '\u2142', '\u004D': '\u0057' | |
'\u004E': '\u1D0E', '\u0050': '\u0500', '\u0051': '\u038C' | |
'\u0052': '\u1D1A', '\u0054': '\u22A5', '\u0055': '\u2229' | |
'\u0056': '\u1D27', '\u0059': '\u2144', '\u005B': '\u005D' | |
'\u005F': '\u203E', '\u0061': '\u0250', '\u0062': '\u0071' | |
'\u0063': '\u0254', '\u0064': '\u0070', '\u0065': '\u01DD' | |
'\u0066': '\u025F', '\u0067': '\u0183', '\u0068': '\u0265' | |
'\u0069': '\u0131', '\u006A': '\u027E', '\u006B': '\u029E' | |
'\u006C': '\u0283', '\u006D': '\u026F', '\u006E': '\u0075' | |
'\u0072': '\u0279', '\u0074': '\u0287', '\u0076': '\u028C' | |
'\u0077': '\u028D', '\u0079': '\u028E', '\u007B': '\u007D' | |
'\u203F': '\u2040', '\u2045': '\u2046', '\u2234': '\u2235' | |
'\u252C': '\u253B' | |
mappings[down] = upside for upside, down of mappings | |
(mappings[c] ? c for c in str).reverse().join("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment