Giter Site home page Giter Site logo

slack-traductor's Introduction

slack-traductor

Slack bot to translate chat messages of any language into specified language

example

Why?

Because we are an international team and sometimes I don't understand what they all are talking about.

Usage

Traductor is using Microsoft Translator API, because it's free ๐Ÿ˜…

  1. Get Translator API account
  2. Create Slack bot
  3. Rename .env.example file into .env and fill in values in fields
BOT_NAME=slack_bot_name
BOT_TOKEN=slack_bot_token
BOT_AS_USER=1
CLIENT_ID=microsoft_translator_client_id
CLIENT_SECRET=microsoft_translator_client_secret
TRANSLATE_TO=en
ADD_MESSAGE=message_to_append
SUSPEND_TIMEOUT=600000
  • BOT_NAME โ€” bot name given when you create a bot
  • BOT_TOKEN โ€” a token which you will receive after creating a bot
  • BOT_AS_USER โ€” pass true to post the message as the authed user
  • CLIENT_ID โ€” take it from your Translator API account
  • CLIENT_SECRET โ€” take it from your Translator API account
  • TRANSLATE_TO โ€” translate messages to specified language, check lang codes in lib/lang_codes.js
  • ADD_MESSAGE โ€” specify the message you want to add to every translation, check the screenshot above.
  • SUSPEND_TIMEOUT โ€” the time period in ms while the bot will not translate messages
  1. Install dependencies of a project
$ npm i
  1. Start server
$ npm start

Chat commands

@traductor: stop โ€” suspend the bot for 10 minutes in current channel/group

slack-traductor's People

Contributors

bugsbunny338 avatar roman01la avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

slack-traductor's Issues

Error when running

I see this output:

โžœ  slack-traductor git:(master) โœ— npm start

> [email protected] start /Users/sam/code/slack-traductor
> babel-node index.js

[TypeError: Cannot read property 'name' of undefined]
[TypeError: Cannot read property 'name' of undefined]
[TypeError: Cannot read property 'name' of undefined]
[TypeError: Cannot read property 'name' of undefined]

Layman's Instructions Needed

Hey there, Roman. I would love to integrate the bot into our Slack team, but I am not sure I understand all the steps involved. I added MS Translator to my Live account, but beyond that I am not sure what to do with the ENV file or integration into Slack. Help, pls? :)

Enhancements and configuration

List of possible improvements (from bare ideas to ongoing work) for the bot. Place for discussion.

  • Turn on/off the bot
  • Specify target language
  • Specify source languages
  • Sanitize input (see #1)
  • Translation on demand?
  • Add support for different APIs (e.g. Google Translate)

Installation with pm2 not possible

Hej, I tried to install it using your instructions, but pm2 gives me this error:

error: unknown option '--next-gen-js'

Without the option, the run fails.

I tried to run it with forever index.js, but then it says:

Syntax Error: Unexpected token import

Can't launch

Here is what i get via "npm start":
npm ERR! [email protected] start: babel-node index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is most likely a problem with the chatslate package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! babel-node index.js npm ERR! You can get their info via: npm ERR! npm owner ls chatslate npm ERR! There is likely additional logging output above. npm ERR! System Linux 3.16.0-4-amd64 npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "start" npm ERR! cwd /bot/slack/slack-traductor npm ERR! node -v v0.10.29 npm ERR! npm -v 1.4.21 npm ERR! code ELIFECYCLE npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /bot/slack/slack-traductor/npm-debug.log npm ERR! not ok code 0

And here is npm-debug.log:
0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'start' ] 2 info using [email protected] 3 info using [email protected] 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info prestart [email protected] 6 info start [email protected] 7 verbose unsafe-perm in lifecycle true 8 info [email protected] Failed to exec start script 9 error [email protected] start:babel-node index.js9 error Exit status 1 10 error Failed at the [email protected] start script. 10 error This is most likely a problem with the slack-traductor package, 10 error not with npm itself. 10 error Tell the author that this fails on your system: 10 error babel-node index.js 10 error You can get their info via: 10 error npm owner ls slack-traductor 10 error There is likely additional logging output above. 11 error System Linux 3.16.0-4-amd64 12 error command "/usr/bin/nodejs" "/usr/bin/npm" "start" 13 error cwd /bot/slack/slack-traductor 14 error node -v v0.10.29 15 error npm -v 1.4.21 16 error code ELIFECYCLE 17 verbose exit [ 1, true ]

System is Debian

Sanitize input

Non-verbal text should not be translated, but (more often than not) should be kept as it complements the message with contextual, social, or emotional information. These non-verbal texts include:

  • Emojis
  • URLs

This issue aims to track down these kinds of text and link to the issues/PRs in which they are addressed individually.

Error: no auth mechanism defined

When loading this up for the first time I get the following error messages. My .env file seems to be filled out correctly.

< Error: no auth mechanism defined
<     at Auth.onRequest (/some/pathnode_modules/request/lib/auth.js:133:32)
<     at Request.auth (/some/pathnode_modules/request/request.js:1233:14)
<     at Request.init (/some/pathnode_modules/request/request.js:380:10)
<     at new Request (/some/pathnode_modules/request/request.js:129:8)
<     at request (/some/pathnode_modules/request/index.js:55:10)
<     at Function.get (/some/pathnode_modules/request/index.js:63:12)
<     at /some/pathlib/translator.js:35:13
<     at Object.isLang (/some/pathlib/translator.js:33:10)
<     at /some/pathlib/any_to_eng.js:34:18
<     at /some/pathlib/translator.js:57:25

It was working at one point without me changing anything, then it stopped. When it was working I was getting a different error:

TypeError: Cannot read property 'name' of undefined
    at replyToUser (/some/pathlib/message_handler.js:30:64)
    at Bot.<anonymous> (/some/pathlib/message_handler.js:25:15)
    at emitOne (events.js:96:13)
    at Bot.emit (events.js:188:7)
    at Bot.<anonymous> (/some/pathnode_modules/slackbots/index.js:59:18)
    at emitTwo (events.js:106:13)
    at WebSocket.emit (events.js:191:7)
    at Receiver.ontext (/some/pathnode_modules/ws/lib/WebSocket.js:797:10)
    at /some/pathnode_modules/ws/lib/Receiver.js:473:18
    at Receiver.applyExtensions (/some/pathnode_modules/ws/lib/Receiver.js:360:5)

Better docs..

I try to integrate but for me a error apper..

I use a heroku, and try with GET and POST method.

<DOCTYPE html>
   <html>
   <head>
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <style type="text/css">
       html, body, iframe { margin: 0; padding: 0; height: 100%; }
       iframe { display: block; width: 100%; border: none; }
     </style>
   <title>Application Error</title>
   </head>
   <body>
     <iframe src="//s3.amazonaws.com/heroku_pages/error.html">
       <p>Application Error</p>
     </iframe>
   </body>
   </html>

Thread support

Hi,

Would you consider supporting thread support - was thinking it would be less noisy if it answered as a thread

Microsoft Translator API is Dead

Microsoft Translator API is no longer working as existing subscriptions were retired and cancelled 3/31/2017. Any plans on adjusting slack-traductor to a different service?

Update docs

Hi, I can not connect using your documentation.
I've never used before slack. And for me it is a problem.

It is not clear what bot_name, bot_token and where to take them.
What to write in the URL option on the slack.
(https: // [YOUR_TEAM] .slack.com / services / new / slash-commands here)
And in general, how to configure everything on the slack.

After I run npm start, nothing happens.

Write please more detailed documentation on the connection.

And he added that when connecting pm2 need to use io.js.
Since Flag --next-gen-js does not work in node.js

(By the way, through io I also did not work)

Trouble getting started

Seems Translator has moved to Azure? Made an account, create a new instance of Translator, but unsure how to proceed from here. Can't find any .env files!
image

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.