Skip to content

Commit fb8de8b

Browse files
committed
Add better anonymous confessions
1 parent 1f534e9 commit fb8de8b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"hubot-shortcut": "^1.0.0",
2424
"hubot-slack": "^3.4.0",
2525
"hubot-wolfram": "1.0.7",
26+
"node-google-translate-skidz": "^0.1.1",
2627
"timeago": "^0.2.0"
2728
},
2829
"engines": {

scripts/confess.coffee

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
# Commands:
88
# hubot confess <confession> - submit anonymous confession (can be sent in a private message)
99
# hubot c0nf3ss <confession> - submit super anonymous confession (can be sent in a private message)
10+
# hubot anonymous <confession> - submit confession that will be automatically anonymized (can be sent in a private message)
1011
#
1112
# Author:
1213
# anishathalye
1314

15+
gtranslate = require 'node-google-translate-skidz'
16+
1417
module.exports = (robot) ->
1518

1619
config = require('hubot-conf')('confess', robot)
@@ -31,6 +34,21 @@ module.exports = (robot) ->
3134
room = config('room')
3235
robot.send {room: room}, translate(text)
3336

37+
robot.respond /anonymous (.+)$/i, (res) ->
38+
text = res.match[1]
39+
language = 'en'
40+
intermediates = ['es', 'de', 'hi', 'fr', 'af', 'en']
41+
chain = (lang, int) -> (text) ->
42+
if int.length > 0
43+
next = int.shift()
44+
gtranslate {text: text, source: lang, target: next}, chain(next, int)
45+
else
46+
message = "[Anonymous] #{text}"
47+
room = config 'room'
48+
robot.send {room: room}, message
49+
chain(language, intermediates)(text)
50+
51+
3452
translate = (text) ->
3553
`var firstCharacter`
3654
`var firstCharacter`

0 commit comments

Comments
 (0)