├── Procfile ├── .gitignore ├── bin ├── hubot.cmd └── hubot ├── hubot-scripts.json ├── .editorconfig ├── external-scripts.json ├── scripts ├── ios.coffee ├── ipad.coffee ├── tvos.coffee ├── macos.coffee ├── pong.coffee ├── xcode.coffee ├── iphone.coffee ├── watchos.coffee ├── monads.coffee ├── hamburger.coffee ├── arrays.coffee ├── dumb.coffee ├── john-troll.coffee ├── functions.coffee ├── code-of-conduct.coffee ├── httpd.coffee ├── thanks.coffee ├── heroku.coffee ├── sorry.coffee ├── ch-hook.coffee └── cocoaheads.coffee ├── package.json └── README.md /Procfile: -------------------------------------------------------------------------------- 1 | web: bin/hubot --adapter slack 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store* 3 | .hubot_history 4 | *.orig 5 | npm-debug.log -------------------------------------------------------------------------------- /bin/hubot.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | npm install && node_modules\.bin\hubot.cmd --name "hubot" %* -------------------------------------------------------------------------------- /bin/hubot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | npm install 6 | export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH" 7 | 8 | exec node_modules/.bin/hubot --name "hubot" "$@" 9 | -------------------------------------------------------------------------------- /hubot-scripts.json: -------------------------------------------------------------------------------- 1 | [ 2 | "redis-brain.coffee", 3 | "shipit.coffee", 4 | "9gag.coffee", 5 | "advice.coffee", 6 | "base64.coffee", 7 | "decide.coffee", 8 | "geocodeme.coffee", 9 | "hashing.coffee", 10 | "isup.coffee" 11 | ] 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /external-scripts.json: -------------------------------------------------------------------------------- 1 | [ 2 | "hubot-diagnostics", 3 | "hubot-help", 4 | "hubot-heroku-keepalive", 5 | "hubot-google-images", 6 | "hubot-google-translate", 7 | "hubot-pugme", 8 | "hubot-maps", 9 | "hubot-redis-brain", 10 | "hubot-rules", 11 | "hubot-youtube" 12 | ] 13 | -------------------------------------------------------------------------------- /scripts/ios.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Corrige quem escrever "iOS" errado 3 | # 4 | 5 | functions = require "./functions" 6 | 7 | module.exports = (robot) -> 8 | 9 | robot.hear /[a-zA-Z0-9\/\.:\-\_]*(IOS|(I(os|Os|oS)))[a-zA-Z0-9\/\.:\-\_#]*/, (res) -> 10 | 11 | functions.mistyping(res, "iOS") -------------------------------------------------------------------------------- /scripts/ipad.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Corrige quem escrever "iPad" errado 3 | # 4 | 5 | functions = require "./functions" 6 | 7 | module.exports = (robot) -> 8 | 9 | robot.hear /[a-zA-Z0-9\/\.:\-\_]*(I(p|P)(a|A)(d|D)|ip(aD|Ad|AD)|iP(aD|Ad|AD))[a-zA-Z0-9\/\.:\-\_#]*/, (res) -> 10 | 11 | functions.mistyping(res, "iPad") -------------------------------------------------------------------------------- /scripts/tvos.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Corrige quem escrever "tvOS" errado 3 | # 4 | 5 | functions = require "./functions" 6 | 7 | module.exports = (robot) -> 8 | 9 | robot.hear /[a-zA-Z0-9\/\.:\-\_]*((T(v|V)(o|O)(s|S))|(t(V)(o|O)(s|S))|tv(Os|oS))[a-zA-Z0-9\/\.:\-\_#]*/, (res) -> 10 | 11 | functions.mistyping(res, "tvOS") -------------------------------------------------------------------------------- /scripts/macos.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Corrige quem escrever "macOS" errado 3 | # 4 | 5 | functions = require "./functions" 6 | 7 | module.exports = (robot) -> 8 | 9 | robot.hear /[a-zA-Z0-9\/\.:\-\_]*((M(a|A)(c|C)(o|O)(s|S))|(m(A)(c|C)(o|O)(s|S))|(ma(C)(o|O)(s|S))|mac(Os|oS))[a-zA-Z0-9\/\.:\-\_#]*/, (res) -> 10 | 11 | functions.mistyping(res, "macOS") -------------------------------------------------------------------------------- /scripts/pong.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # You say pong. Hubot says PING. 3 | # 4 | # Dependencies: 5 | # none 6 | # 7 | # Configuration: 8 | # none 9 | # 10 | # Commands: 11 | # hubot pong 12 | # 13 | # Notes: 14 | # 15 | # 16 | # Author: 17 | # Gustavo Barbosa 18 | 19 | module.exports = (robot) -> 20 | robot.respond /PONG$/i, (msg) -> 21 | msg.send "PING" 22 | -------------------------------------------------------------------------------- /scripts/xcode.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Corrige quem escrever "Xcode" errado 3 | # 4 | 5 | functions = require "./functions" 6 | 7 | module.exports = (robot) -> 8 | 9 | robot.hear /[a-zA-Z0-9\/\.:\-\_]*((xC((o|O)(d|D)(e|E)))|(XC((o|O)(d|D)(e|E)))|((x|X)cO((d|D)(e|E)))|(Xco((D)(e|E)))|XcodE)[a-zA-Z0-9\/\.:\-\_#]*/, (res) -> 10 | 11 | functions.mistyping(res, "Xcode") 12 | -------------------------------------------------------------------------------- /scripts/iphone.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Corrige quem escrever "iPhone" errado 3 | # 4 | 5 | functions = require "./functions" 6 | 7 | module.exports = (robot) -> 8 | 9 | robot.hear /[a-zA-Z0-9\/\.:\-\_]*(I(p|P)(h|H)(o|O)(n|N)(e|E)|iPH(o|O)(n|N)(e|E)|ipH(o|O)(n|N)(e|E)|iPhO(n|N)(e|E)|iPho(Ne|nE|NE))[a-zA-Z0-9\/\.:\-\_#]*/, (res) -> 10 | 11 | functions.mistyping(res, "iPhone") -------------------------------------------------------------------------------- /scripts/watchos.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Corrige quem escrever "watchOS" errado 3 | # 4 | 5 | functions = require "./functions" 6 | 7 | module.exports = (robot) -> 8 | 9 | robot.hear /[a-zA-Z0-9\/\.:\-\_]*((W(a|A)(t|T)(c|C)(h|H)(o|O)(s|S))|(wA(t|T)(c|C)(h|H)(o|O)(s|S))|(wa(T)(c|C)(h|H)(o|O)(s|S))|(wat(C)(h|H)(o|O)(s|S))|(watc(H)(o|O)(s|S))|watch(Os|oS))[a-zA-Z0-9\/\.:\-\_#]*/, (res) -> 10 | 11 | functions.mistyping(res, "watchOS") -------------------------------------------------------------------------------- /scripts/monads.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Script that sends a monads definition 3 | # Commands: 4 | # monads 5 | # Author: 6 | # diegoventura 7 | 8 | module.exports = (robot) -> 9 | robot.hear /monads/, (msg) -> 10 | msg.send "Uma Monad em `X` é apenas uma monóide na categoria das endofunctors de `X`, com o produto :heavy_multiplication_x: substituído pela composição de endofunctors e a unidade ajustada para o endofunctor identidade :monads:" 11 | -------------------------------------------------------------------------------- /scripts/hamburger.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Script that sends a link medium about hamburger menu 3 | # Commands: 4 | # hamburger menu, menu hamburger, :hamburger: menu, menu :hamburger: 5 | # 6 | # Notes: 7 | # It just listens to the feed and interact with the medium link 8 | # 9 | # Author: 10 | # ltsuda 11 | 12 | module.exports = (robot) -> 13 | robot.hear /hamburger menu|menu hamburger|:hamburger: menu|menu :hamburger:/i, (msg) -> 14 | msg.send "https://medium.com/@kollinz/hamburger-menu-alternatives-for-mobile-navigation-a3a3beb555b8#.h6v94pyyy" -------------------------------------------------------------------------------- /scripts/arrays.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Arquivo que contém arrays comuns 3 | # 4 | 5 | exports.weapons = [ 6 | ":gun:", 7 | ":knife:", 8 | ":bomb:", 9 | ":dagger_knife:" 10 | ] 11 | 12 | exports.animals = [ 13 | {emoji: ":panda_face:", description: "um panda", gender: "masculine"}, 14 | {emoji: ":koala:", description: "um koala", gender: "masculine"}, 15 | {emoji: ":unicorn_face:", description: "um unicórnio", gender: "masculine"}, 16 | {emoji: ":dolphin:", description: "um golfinho", gender: "masculine"}, 17 | {emoji: ":dove_of_peace:", description: "uma pomba branca", gender: "feminine"} 18 | ] -------------------------------------------------------------------------------- /scripts/dumb.coffee: -------------------------------------------------------------------------------- 1 | 2 | # Description: 3 | # Sugere que faça melhorias ao hubot caso seja chamado de "burrinho" 4 | # 5 | 6 | module.exports = (robot) -> 7 | dumbwords = ["burro","burrinho","burrão","idiota","otário","vacilão"] 8 | regex = RegExp(dumbwords.join('.*hubot|').concat '.*hubot|hubot.*'.concat dumbwords.join('|hubot.*'), 'i') 9 | 10 | robot.hear regex, (msg) -> 11 | msg.send "Ei <@#{msg.envelope.user.id}>! Talvez eu até seja, mas estou sempre disposto a melhorar. Bem que você poderia dar uma mão com isso né? :wink:" 12 | msg.send "https://github.com/iOSDevBR/iosdevbr-hubot" 13 | -------------------------------------------------------------------------------- /scripts/john-troll.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Script to troll John Calistro 3 | # 4 | # Dependencies: 5 | # none 6 | # 7 | # Configuration: 8 | # none 9 | # 10 | # Commands: 11 | # :john: 12 | # 13 | # Notes: 14 | # It just listens to the feed and interact with the emoji 15 | # 16 | # Author: 17 | # ghvillasboas 18 | 19 | emojis = [ 20 | ":rage:", 21 | ":heart_eyes:", 22 | ":heart_eyes:", 23 | ":thumbsdown:", 24 | ":thumbsup:", 25 | ":v:", 26 | ":tongue:", 27 | ":nail_care:", 28 | ":kiss:", 29 | ":broken_heart:", 30 | ":broken_heart:", 31 | ":heart_beat:" 32 | ] 33 | 34 | module.exports = (robot) -> 35 | robot.hear /:john:/i, (msg) -> 36 | msg.send ":john: #{msg.random emojis}" -------------------------------------------------------------------------------- /scripts/functions.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Arquivo que contém funções comuns 3 | # 4 | 5 | url = require('url') 6 | request = require('request') 7 | arrays = require "./arrays" 8 | 9 | exports.mistyping = (res, correct, length) -> 10 | 11 | if (!url.parse(res.match[0]).hostname && res.match[0].length == correct.length) 12 | 13 | animal = res.random arrays.animals 14 | dead = if animal.gender == 'feminine' then 'mortas' else 'mortos' 15 | request.post "http://panda-counter.herokuapp.com/#{animal.emoji}", (error, response, body) -> 16 | count = JSON.parse(body)[animal.emoji] 17 | res.send "Você acabou de matar #{res.random arrays.weapons} #{animal.description} #{animal.emoji} ao escrever #{correct} errado. Total de #{animal.emoji} #{dead}: #{count}" -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hubot", 3 | "version": "0.0.0", 4 | "private": true, 5 | "author": "Gustavo Barbosa ", 6 | "description": "A simple helpful robot for your Company", 7 | "dependencies": { 8 | "hubot": "^2.16.0", 9 | "hubot-diagnostics": "0.0.1", 10 | "hubot-google-images": "^0.1.4", 11 | "hubot-google-translate": "^0.1.0", 12 | "hubot-help": "^0.1.1", 13 | "hubot-heroku-keepalive": "0.0.4", 14 | "hubot-maps": "0.0.2", 15 | "hubot-pugme": "^0.1.0", 16 | "hubot-redis-brain": "0.0.2", 17 | "hubot-rules": "^0.1.0", 18 | "hubot-scripts": "^2.5.16", 19 | "hubot-shipit": "^0.2.0", 20 | "hubot-slack": "^3.3.0", 21 | "hubot-youtube": "^0.1.2", 22 | "htmlparser": "1.7.6", 23 | "soupselect": "0.2.0", 24 | "big-integer": "1.1.5", 25 | "googleanalytics":"0.3.6", 26 | "date-utils": ">=1.2.5", 27 | "request":">=2.40.0" 28 | }, 29 | "engines": { 30 | "node": "0.10.x", 31 | "npm": ">= 1.1.x" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /scripts/code-of-conduct.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Script para Código de Conduta 3 | # 4 | # Dependencies: 5 | # none 6 | # 7 | # Configuration: 8 | # none 9 | # 10 | # Commands: 11 | # none 12 | # 13 | # Notes: 14 | # none 15 | # 16 | # Author: 17 | # Gustavo Barbosa 18 | 19 | module.exports = (robot) -> 20 | homophobic = ["gay", "viado", "bicha", "boiola", "viadinho", "bichona", "chupar", "lésbica", "homossexual", "machona", "baitola"] 21 | chauvinist = ["coisa de menina", "afeminado", "igual mulher", "igual garota", "igual menina", "mocinha", "moçoila", "lugar de mulher", "vadia", "vagabunda"] 22 | racist = ["coisa de preto", "igual preto", "lugar de preto"] 23 | 24 | expressions = homophobic.concat(chauvinist, racist) 25 | expressions = ('\\b' + word + '\\b' for word in expressions) 26 | 27 | regex = RegExp('(' + expressions.join('|') + ')', 'i') 28 | robot.hear regex, (msg) -> 29 | msg.send "Ei <@#{msg.envelope.user.id}>. *#{msg.match[1]}* não é legal de se falar por aqui. " + 30 | "Depois dá uma conferida no Código de Conduta do grupo :wink:" 31 | msg.send "https://github.com/iOSDevBR/Codigo-De-Conduta" 32 | -------------------------------------------------------------------------------- /scripts/httpd.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # A simple interaction with the built in HTTP Daemon 3 | # 4 | # Dependencies: 5 | # None 6 | # 7 | # Configuration: 8 | # None 9 | # 10 | # Commands: 11 | # None 12 | # 13 | # URLS: 14 | # /hubot/version 15 | # /hubot/ping 16 | # /hubot/time 17 | # /hubot/info 18 | # /hubot/ip 19 | 20 | spawn = require('child_process').spawn 21 | 22 | module.exports = (robot) -> 23 | 24 | robot.router.get "/hubot/version", (req, res) -> 25 | res.end robot.version 26 | 27 | robot.router.post "/hubot/ping", (req, res) -> 28 | res.end "PONG" 29 | 30 | robot.router.get "/hubot/time", (req, res) -> 31 | res.end "Server time is: #{new Date()}" 32 | 33 | robot.router.get "/hubot/info", (req, res) -> 34 | child = spawn('/bin/sh', ['-c', "echo I\\'m $LOGNAME@$(hostname):$(pwd) \\($(git rev-parse HEAD)\\)"]) 35 | 36 | child.stdout.on 'data', (data) -> 37 | res.end "#{data.toString().trim()} running node #{process.version} [pid: #{process.pid}]" 38 | child.stdin.end() 39 | 40 | robot.router.get "/hubot/ip", (req, res) -> 41 | robot.http('http://ifconfig.me/ip').get() (err, r, body) -> 42 | res.end body 43 | -------------------------------------------------------------------------------- /scripts/thanks.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Agradeça o hubot que ele educadamente te responde de volta 3 | # 4 | # Dependencies: 5 | # none 6 | # 7 | # Configuration: 8 | # none 9 | # 10 | # Commands: 11 | # hubot obrigado, valeu, thanks, etc. 12 | # 13 | # Notes: 14 | # 15 | # 16 | # Author: 17 | # ghvillasboas 18 | 19 | greetings = [ 20 | "Por nada! :+1:", 21 | "De nada! :+1:", 22 | "Obrigado você! :v:", 23 | "You're welcome! :+1:", 24 | "Um dia eu cobro de volta.", 25 | "Você me deve essa!", 26 | "Não abuse.", 27 | "Vai nessa...", 28 | ":grinning:", 29 | ":pray:", 30 | "Obrigado? :dollar: ?", 31 | "This is always at your service. :space_invader:", 32 | "Ao seu dispor! :guardsman:", 33 | "Ha! ha! There's no free lunch! :trollface:", 34 | "Ao infinito... e além!!! :android: ops... Wrong green man! :sob:", 35 | "Tamo ai né? :surfer:", 36 | "Tá achando que a ajuda foi de graça? R$ 3,50 + o dinheiro do busão! :bus:", 37 | "Agradeça a eles -> :chbr:", 38 | "Agradeça a eles -> :apbr:", 39 | "You're my guest!" 40 | ] 41 | 42 | module.exports = (robot) -> 43 | robot.respond /.*(obrigado|obgd|valeu|thankx|thanks|:thumbsup:|thank you|tnkx|tnks).*/i, (msg) -> 44 | msg.send "<@#{msg.envelope.user.id}>: #{msg.random greetings}" 45 | -------------------------------------------------------------------------------- /scripts/heroku.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Accepts a heroku hook and posts to channel 3 | # 4 | # Dependencies: 5 | # none 6 | # 7 | # Configuration: 8 | # 9 | # Commands: 10 | # Posta uma mensagem ao fazer um novo deploy do website do CH 11 | # 12 | # Notes: 13 | # 14 | # 15 | # Author: 16 | # ghvillasboas (based on Artsy Editorial work) 17 | 18 | url = require('url') 19 | querystring = require('querystring') 20 | 21 | module.exports = (robot) -> 22 | 23 | robot.router.post "/post/heroku/website", (req, res) -> 24 | 25 | query = querystring.parse(req.query) 26 | heroku_app = req.body.app 27 | heroku_user = req.body.user 28 | heroku_url = req.body.url 29 | heroku_head = req.body.head 30 | heroku_head_long = req.body.head_long 31 | heroku_git_log = req.body.git_log 32 | 33 | user = {} 34 | user.room = "cocoaheads-org" 35 | 36 | emocao_hubot = [ 37 | "YAY!", 38 | "YES!", 39 | "OBA!", 40 | "EBA!", 41 | "WOW!" 42 | ] 43 | 44 | try 45 | robot.send user, "#{random emocao_hubot} Novo deploy no website do CocoaHeadsBR: #{heroku_git_log}" 46 | 47 | res.end "message sent to channel" 48 | 49 | catch error 50 | console.log "message-listner error: #{error}." 51 | 52 | shuffle = (a) -> 53 | i = a.length 54 | while --i > 0 55 | j = ~~(Math.random() * (i + 1)) # ~~ is a common optimization for Math.floor 56 | t = a[j] 57 | a[j] = a[i] 58 | a[i] = t 59 | a 60 | 61 | random = (a) -> 62 | a = shuffle(a) 63 | a[0] 64 | -------------------------------------------------------------------------------- /scripts/sorry.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Peça desculpas ao hubot que ele educadamente te responde de volta 3 | # 4 | # Dependencies: 5 | # none 6 | # 7 | # Configuration: 8 | # none 9 | # 10 | # Commands: 11 | # hubot sorry, desculpa, desculpas, foi mal, mal ae, my bad, etc. 12 | # 13 | # Notes: 14 | # 15 | # 16 | # Author: 17 | # ghvillasboas 18 | 19 | greetings = [ 20 | "Tá tranquilo :wink:", 21 | "Relaxa :smile:", 22 | "Tá de boa na lagoa :swimmer:", 23 | "Tá sussa :v:", 24 | "Hi five! :hand:", 25 | "Soquinho! :punch:", 26 | "Tudo bem! Mas estamos de olho, hein? :eyes:", 27 | "Vou pensar no seu caso... :thought_balloon:", 28 | "Paz! :v:", 29 | "Paz! :vulcan:", 30 | "Ok! Poderia ser pior... :android:", 31 | "Visualizado há 14 horas. :white_check_mark:", 32 | "De boa... mas já sabe né? Na próxima: :ledger:", 33 | "Quantidade de vezes que o Hubot perdoa: :zero:", 34 | ":see_no_evil:", 35 | "Tranquilo :john:", 36 | "Tudo certo! :doug:", 37 | "Relaxa! Não vai ser hoje que vamos ter um #fightOfTheWeek :selodougapproves:", 38 | "Está bien! :taco:", 39 | "Это нормально! :guardsman:", 40 | "やりました!(Traduzido pelo Bing: Tudo bem!) :expressionless:", 41 | "Tranquilo! Estamos apenas trabalhando para tornar nossa convivência melhor! :construction_worker:", 42 | "De boas! :beers:", 43 | "Ta tranquilo! Viram isso minha gente? Uma pessoa que escuta e aprende! :clap:", 44 | "Minha :crystal_ball: tá dizendo que não vai se repetir, então tudo bem! Relaxa!", 45 | "Ta desculpado! Vai tranquilo! :balloon:", 46 | "OK! :doge:" 47 | ] 48 | 49 | module.exports = (robot) -> 50 | robot.respond /.*(sorry|desculpa|desculpas|perdão|perdao|foi mal|foi mal ae|mal ae|mal ai|foi mal ai|my bad).*/i, (msg) -> 51 | msg.send "<@#{msg.envelope.user.id}>: #{msg.random greetings}" 52 | -------------------------------------------------------------------------------- /scripts/ch-hook.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Posta no canal toda vez que um registro é criado no website do CocoaHeadsBR (fotos, agenda, cidades e videos) 3 | # 4 | # Dependencies: 5 | # none 6 | # 7 | # Configuration: 8 | # 9 | # Commands: 10 | # Interacao automatica via backend do website 11 | # 12 | # Notes: 13 | # 14 | # 15 | # Author: 16 | # ghvillasboas 17 | 18 | url = require('url') 19 | querystring = require('querystring') 20 | 21 | module.exports = (robot) -> 22 | 23 | robot.router.post "/post/chbr/website", (req, res) -> 24 | 25 | query = querystring.parse(req.query) 26 | web_channel = if req.body.channel? then req.body.channel else "#hubottest" 27 | web_message = req.body.message 28 | web_mood = if req.body.mood? then req.body.mood else 'good' 29 | 30 | user = {} 31 | user.room = web_channel 32 | 33 | good_mood_hubot = [ 34 | "YAY!", 35 | "YES!", 36 | "OBA!", 37 | "EBA!", 38 | "WOW!", 39 | "Uhhuuuu!", 40 | 'Rádio Hubot innnnforma!' 41 | ] 42 | 43 | bad_mood_hubot = [ 44 | "PUTZ!", 45 | "NOOOOOO!", 46 | "Ahhhh!", 47 | "NÃO!", 48 | "OH NÃO!", 49 | "Nananinanã!", 50 | "Babado!" 51 | ] 52 | 53 | mood = if web_mood == 'bad' then bad_mood_hubot else good_mood_hubot 54 | 55 | try 56 | if web_mood != 'none' 57 | robot.send user, "#{random mood} #{web_message}" 58 | else 59 | robot.send user, "#{web_message}" 60 | res.end "message sent to channel" 61 | 62 | catch error 63 | console.log "message-listner error: #{error}." 64 | 65 | shuffle = (a) -> 66 | i = a.length 67 | while --i > 0 68 | j = ~~(Math.random() * (i + 1)) # ~~ is a common optimization for Math.floor 69 | t = a[j] 70 | a[j] = a[i] 71 | a[i] = t 72 | a 73 | 74 | random = (a) -> 75 | a = shuffle(a) 76 | a[0] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Hubot do iOSDevBR 4 | 5 | O hubot do iOSDevBR serve principalmente para garantir que o nosso [Código de Conduta][coc] está sendo respeitado, alertando casos de mensagens homóficas, racistas, machistas, etc. 6 | 7 | Mas também serve pra divertir :tada: 8 | > Você acabou de matar um panda ao escrever "iOS" errado. 9 | 10 | Se tiver alguma ideia que seja legal e que acredite que será útil para o grupo, fique à vontade para adicionar um novo script ou alterar algum já existente. 11 | 12 | Para mais informações, acesse a [documentação oficial][documentation]. 13 | 14 | [coc]: https://github.com/iOSDevBR/Codigo-De-Conduta 15 | [documentation]: http://hubot.github.com 16 | 17 | 18 | ## Criando novos scripts 19 | 20 | Um script que pode servir de exemplo pode ser encontrado em `scripts/thanks.coffee`. Dá uma olhada lá para ter uma ideia de como o hubot interage. Basicamente, ele atua em 2 casos principais: 21 | 22 | `message.hear` atua caso escute algum padrão de mensagem na sala em que ele está presente 23 | 24 | `message.respond` atua respondendo ao usuário que mandou uma mensagem para ele. Para isso, é preciso mencioná-lo com o `@hubot: mensagem para o hubot` 25 | 26 | Depois de criado o script, basta incluí-lo na pasta `scripts` e fazer um PR. 27 | 28 | *OBS:* 29 | 30 | 1. Para as tarefas mais comuns, há uma grande chance de alguém já ter feito algo parecido. Você pode encontrar uma lista de scripts feitos [aqui][plugins-list]. 31 | 32 | 2. Se ficar com dúvida de como fazer alguma coisa em CoffeeScript, pode acessar a [documentação da linguagem][coffeescript] ou tentar brincar com esse [REPL online][coffee-repl]. 33 | 34 | 3. Para entender mais sobre scripting, acesse a [documentação de scripting](scripting-docs) do hubot. 35 | 36 | [scripting-docs]: https://github.com/github/hubot/blob/master/docs/scripting.md 37 | [coffeescript]: http://coffeescript.org/ 38 | [coffee-repl]: http://larryng.github.io/coffeescript-repl/ 39 | [plugins-list]: https://github.com/hubot-scripts 40 | 41 | ## Rodando o hubot localmente 42 | 43 | Você pode testar suas modificações no hubot rodando o comando a seguir: 44 | 45 | *(obs: alguns plugins podem não se comportar como o esperado ao menos que algumas variáveis de ambiente tenham sido definidas corretamente.)* 46 | 47 | $ ./bin/hubot 48 | 49 | Você verá uma saída no console parecida com essa: 50 | 51 | [Sat Feb 28 2015 12:38:27 GMT+0000 (GMT)] INFO Using default redis on localhost:6379 52 | hubot> 53 | 54 | Depois disso, você pode rodar `hubot help` para se certificar que o hubot já está ouvindo os comandos: 55 | 56 | hubot> hubot help 57 | hubot animate me - The same thing as `image me`, except adds [snip] 58 | hubot help - Displays all of the help commands that hubot knows about. 59 | ... 60 | 61 | ## Deploy 62 | 63 | Quando o merge do PR é feito, ainda é preciso fazer o deploy do novo código do hubot. Pra isso, nós temos um outro **remote** do projeto hospedado no **Heroku**. Se depois de alguns minutos do merge ter sido feito, as alterações não tiverem surtido efeito, entre em contato com [um dos admins do grupo][admins]. 64 | 65 | [admins]: https://github.com/orgs/iOSDevBR/people 66 | -------------------------------------------------------------------------------- /scripts/cocoaheads.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Util scripts for the CocoaHeads BR community 3 | # 4 | # Dependencies: 5 | # none 6 | # 7 | # Configuration: 8 | # none 9 | # 10 | # Commands: 11 | # hubot quais são as próximas agendas? - Retorna a proxima agenda do cocoaheads br 12 | # hubot quantos eventos já fizemos? - Retorna a quantidade de eventos realizados 13 | # hubot quantos inscritos? - Retorna a quantidade de inscritos nos proximos eventos 14 | # hubot total de inscritos? - Retorna a quantidade de inscritos em todos os eventos 15 | # hubot total de inscritos por mês? - Retorna a quantidade de inscritos em todos os eventos agrupados por mês 16 | # hubot total de inscritos por cidade? - Retorna a quantidade de inscritos em todos os eventos agrupados por cidade 17 | # 18 | # Notes: 19 | # 20 | # 21 | # Author: 22 | # ghvillasboas - jpros 23 | 24 | module.exports = (robot) -> 25 | robot.respond /(proximas|próximas) agendas|(proxima|próxima) agenda|(qual|quando) (é|e|eh) a (proxima|próxima) agenda?|(quais|quando) (são|sao) as (proximas|próximas) agendas?|agendas/i, (msg) -> 26 | msg.http("http://www.cocoaheads.com.br/agendas.json") 27 | .get() (err, res, body) -> 28 | try 29 | json = JSON.parse(body) 30 | message = "\n" 31 | for agenda in json 32 | data = new Date(agenda.data) 33 | message += "Evento: #{agenda.nome}\nData: #{data.getDate()}/#{data.getMonth() + 1}/#{data.getFullYear()} às #{data.toLocaleTimeString()}\nLocal: #{agenda.local}\n\n" 34 | msg.reply message 35 | catch err 36 | msg.reply "Hã? Cuma? O que? Não consegui pegar as agendas! :rage:" 37 | 38 | robot.respond /.*(inscritos|inscrição|inscricao|inscricoes|inscrições|rsvps|rsvp|confirmados).*/i, (msg) -> 39 | if(msg.message.match(/.*(todos|total).*/i)) 40 | if(msg.message.match(/.*(mês|mes|ano)/i)) 41 | msg.http("http://www.cocoaheads.com.br/agendas/total_devs.json?group=month") 42 | .get() (err, res, body) -> 43 | try 44 | if (body.length > 0) 45 | json = JSON.parse(body) 46 | message = "\n" 47 | for item in json 48 | message += "-> Em #{item.month} tivemos #{item.total} pessoas nos eventos do CocoaHeads\n" 49 | 50 | msg.reply message 51 | else 52 | msg.reply "Nenhum evento cadastrado :(" 53 | catch err 54 | msg.reply "#{err} Hã? Cuma? O que? Não consegui pegar as agendas! :rage:" 55 | else if (msg.message.match(/.*(chapter|cidade|capítulo|capitulo)/i)) 56 | msg.http("http://www.cocoaheads.com.br/agendas/total_devs.json?group=chapter") 57 | .get() (err, res, body) -> 58 | try 59 | if (body.length > 0) 60 | json = JSON.parse(body) 61 | message = "\n" 62 | for item in json 63 | message += "-> No CocoaHeads #{item.chapter} já tivemos #{item.total} pessoas\n" 64 | 65 | msg.reply message 66 | else 67 | msg.reply "Nenhum evento cadastrado :(" 68 | catch err 69 | msg.reply "#{err} Hã? Cuma? O que? Não consegui pegar as agendas! :rage:" 70 | else 71 | msg.http("http://www.cocoaheads.com.br/agendas/total_devs.json?alltime=true") 72 | .get() (err, res, body) -> 73 | try 74 | if (body.length > 0) 75 | json = JSON.parse(body) 76 | messagem = "\n" 77 | for item in json 78 | messagem = "-> Já tivemos #{item.total} pessoas nos eventos do CocoaHeads\n" 79 | 80 | msg.reply messagem 81 | else 82 | msg.reply "Nenhum evento cadastrado :(" 83 | catch err 84 | msg.reply "#{err} Hã? Cuma? O que? Não consegui pegar as agendas! :rage:" 85 | 86 | else 87 | msg.http("http://www.cocoaheads.com.br/agendas/rsvps.json") 88 | .get() (err, res, body) -> 89 | try 90 | if (body.length > 0) 91 | json = JSON.parse(body) 92 | messagem = "\n" 93 | for agenda in json 94 | data = new Date(agenda.data) 95 | mensagemBasica = "-> Em #{agenda.cidade} (#{data.getDate()}/#{data.getMonth() + 1}/#{data.getFullYear()}), temos #{agenda.rsvp_sim} confirmados, #{agenda.rsvp_talvez} talvez" 96 | 97 | if agenda.rsvp_espera > 0 98 | mensagemBasica += ". #{agenda.rsvp_espera} em espera" 99 | 100 | if agenda.rsvp_limite > 0 101 | if agenda.rsvp_restante > 0 102 | mensagemBasica += ". #{agenda.rsvp_restante} vagas restantes." 103 | else 104 | mensagemBasica += ". Vagas esgotadas :thumbsup:" 105 | else 106 | mensagemBasica += ". Não existe limite de vagas." 107 | 108 | messagem += "#{mensagemBasica}\n" 109 | msg.reply messagem 110 | else 111 | msg.reply "Nenhum evento em vista. Que tal marcar um? :punch:" 112 | catch err 113 | msg.reply "#{err} Hã? Cuma? O que? Não consegui pegar as agendas! :rage:" 114 | 115 | robot.respond /quantos eventos (já|ja) fizemos( )?/i, (msg) -> 116 | msg.http("http://www.cocoaheads.com.br/agendas/todas.json") 117 | .get() (err, res, body) -> 118 | try 119 | json = JSON.parse(body) 120 | msg.reply "Já fizemos um total de #{json.length} eventos. :metal:\n" 121 | catch err 122 | msg.reply "Hã? Cuma? O que? Não consegui pegar as agendas! :rage:" 123 | --------------------------------------------------------------------------------