Giter Club home page Giter Club logo

hubot-twitter's Introduction

Hubot Twitter Adapter

Description

This is the Twitter adapter for hubot that allows you to send an tweet to your Hubot and he will send an tweet back with the response.

Installation

  • Add hubot-twitter as a dependency in your hubot's package.json
  • Install dependencies with npm install
  • Run hubot with bin/hubot -a twitter -n the_name_of_the_twitter_bot_account

Note if running on Heroku

You will need to change the process type from app to web in the Procfile.

Usage

You will need to set some environment variables to use this adapter.

Heroku

% heroku config:add HUBOT_TWITTER_KEY="key"
% heroku config:add HUBOT_TWITTER_SECRET="secret"
% heroku config:add HUBOT_TWITTER_TOKEN="token"
% heroku config:add HUBOT_TWITTER_TOKEN_SECRET="secret"

Non-Heroku environment variables

% export HUBOT_TWITTER_KEY="key"
% export HUBOT_TWITTER_SECRET="secret"
% export HUBOT_TWITTER_TOKEN="token"
% export HUBOT_TWITTER_TOKEN_SECRET="secret"

Then you will need to set the HTTP endpoint on Twitter to point to your server and make sure the request type is set to GET.

Contribute

Just send pull request if needed or fill an issue !

Copyright

Copyright © Mathilde Lemee. See LICENSE for details.

hubot-twitter's People

Contributors

flimshaw avatar mathildelemee avatar mikrofusion avatar owenthereal avatar pathawks avatar pyro2927 avatar technicalpickles avatar tenten0213 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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hubot-twitter's Issues

NPM not installing latest version

Hey there again. It seems like the version numbers are messed up in NPM for some reason. When I run 'npm install hubot-twitter', it installs a mysterious version 2.1.1 that doesn't include @mikrofusion's fix for the stream data chunk syntax errors. Not really sure where/how you fix this, but figured you oughta know. Here's what NPM reports for info on your library:

{ name: 'hubot-twitter',
  time:
   { modified: '2014-03-30T14:03:52.439Z',
     created: '2011-11-23T22:33:58.656Z',
     '2.0.0': '2011-11-23T22:34:00.257Z',
     '2.0.1': '2011-12-06T21:28:52.120Z',
     '2.0.2': '2011-12-07T20:49:07.012Z',
     '2.0.4': '2011-12-12T21:09:43.781Z',
     '2.0.5': '2014-03-30T08:33:09.678Z',
     '2.1.0': '2014-03-30T08:36:40.939Z',
     '2.1.1': '2014-03-30T14:03:52.439Z' },
  maintainers: 'mathilde_lemee <[email protected]>',
  'dist-tags': { latest: '2.1.1' },
  description: 'A Twitter adapter for hubot',
  versions: '2.1.1',
  homepage: 'https://github.com/mathildelemee/hubot-twitter',
  keywords: 'github hubot twitter adapter',
  repository:
   { type: 'git',
     url: 'git://github.com/mathildelemee/hubot-twitter.git' },
  author: 'Mathilde Lemee',
  bugs: { url: 'https://github.com/mathildelemee/hubot-twitter/issues' },
  readmeFilename: 'README.md',
  users: {},
  version: '2.1.1',
  licenses:
   { type: 'MIT',
     url: 'http://github.com/tombell/hubot-twilio/raw/master/LICENSE' },
  dependencies: { oauth: '0.9.10' },
  devDependencies: { 'coffee-script': '1.1.3' },
  main: './src/twitter',
  engine: 'node > 0.6.0 < 0.7.0',
  engines: { node: '*' },
  dist:
   { shasum: 'e9c5e4cb0588b796403e2302179b8e44914d9233',
     tarball: 'http://registry.npmjs.org/hubot-twitter/-/hubot-twitter-2.1.1.tgz' },
  directories: {} }

Looks like there's a .tgz file that's overriding the current master branch somehow?

Unexpected Token

Adapter connects to twitter, but when I send a message to the twitter account, it simply returns this in the terminal:

[SyntaxError: Unexpected token :]

Any thoughts what isn't set up correctly?

ERROR Cannot load adapter twitter - TypeError

Running this adapter presents this error:

$ bin/hubot -a twitter -n twitterbot

[Thu Sep 05 2013 11:17:28 GMT-0400 (EDT)] ERROR Cannot load adapter twitter - TypeError: Object # has no method 'robot'

Installed with:

$ npm install
npm http GET https://registry.npmjs.org/hubot-twitter
npm http 304 https://registry.npmjs.org/hubot-twitter
npm http GET https://registry.npmjs.org/oauth/0.9.5
npm http 304 https://registry.npmjs.org/oauth/0.9.5
[email protected] node_modules/hubot-twitter
âââ [email protected]

SyntaxError

[SyntaxError: Unexpected token E]

When twitter send string with content 'Exceeded connection limit for user' or other twitter response, that error are shown.
in
src/twitter.coffee:120
I change code to this

          try
             callback JSON.parse(json), null
          catch err
             console.log err, "While parse json: ", json

In that case I understand why I got those messages

How can I test adapter?

I did everything what's in readme. I've deployd the app to heroku, everything looks fine but when I tweet newly created account for this adapter there is no response. What's the good way to test what's wrong? What's the usage of this adapter.

hubot-twitter received message from Twitter but didn't reply the message

Hi,

I tried to test hobot-twitter locally and try to send message on twitter with something like this

"@cortana_ai image me hubot"

From the logs (attached), I can see it received the messages but it didn't reply the message. Could you help me to understand why?

Thanks,
Owen

23:52:51 app.1     | https://stream.twitter.com/1/statuses/filter.json?track=cortana_ai, 434705154-tWxUDMMePxq35ihoaMQ8bYYDgMiXVBfghejqtUEA, ClTX06zV6BQ1YOGFjCZHUbW0dVVXOui0Bw9h5jws, null23:52:51 app.1     | { output: [],23:52:51 app.1     |   outputEncodings: [],23:52:51 app.1     |   writable: true,23:52:51 app.1     |   _last: false,23:52:51 app.1     |   chunkedEncoding: false,23:52:51 app.1     |   shouldKeepAlive: true,23:52:51 app.1     |   useChunkedEncodingByDefault: false,23:52:51 app.1     |   _hasBody: true,23:52:51 app.1     |   _trailer: '',23:52:51 app.1     |   finished: false,23:52:51 app.1     |   agent: 23:52:51 app.1     |    { options: {},23:52:51 app.1     |      requests: {},23:52:51 app.1     |      sockets: { 'stream.twitter.com:443': [Object] },23:52:51 app.1     |      maxSockets: 5,23:52:51 app.1     |      _events: { free: [Function] },23:52:51 app.1     |      createConnection: [Function: createConnection] },23:52:51 app.1     |   socketPath: undefined,23:52:51 app.1     |   method: 'GET',23:52:51 app.1     |   path: '/1/statuses/filter.json?track=cortana_ai',23:52:51 app.1     |   _headers: 23:52:51 app.1     |    { authorization: 'OAuth oauth_consumer_key="PUgzBc80R9bsS2ArGu7vQ",oauth_nonce="qLN7tivBpoIxgxNH2MLdjzpfTGkslApv",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1323676371",oauth_token="434705154-tWxUDMMePxq35ihoaMQ8bYYDgMiXVBfghejqtUEA",oauth_version="1.0",oauth_signature="G0gRc2Bpf2NH7%2BihC4esbX1THqo%3D"',23:52:51 app.1     |      host: 'stream.twitter.com',23:52:51 app.1     |      accept: '*/*',23:52:51 app.1     |      connection: 'close',23:52:51 app.1     |      'user-agent': 'Node authentication',23:52:51 app.1     |      'content-length': 0,23:52:51 app.1     |      'content-type': 'application/x-www-form-urlencoded' },23:52:51 app.1     |   _headerNames: 23:52:51 app.1     |    { authorization: 'Authorization',23:52:51 app.1     |      host: 'Host',23:52:51 app.1     |      accept: 'Accept',23:52:51 app.1     |      connection: 'Connection',23:52:51 app.1     |      'user-agent': 'User-Agent',23:52:51 app.1     |      'content-length': 'Content-length',23:52:51 app.1     |      'content-type': 'Content-Type' },23:52:51 app.1     |   _events: { socket: { [Function: g] listener: [Function] } } }23:52:51 app.1     | [Mon, 12 Dec 2011 07:52:51 GMT] INFO Loading hubot-scripts from /Users/Owen/workspace/cortana_ai/node_modules/hubot-scripts/src/scripts23:52:51 app.1     | The "sys" module is now called "util". It should have a similar interface.23:52:51 app.1     | [Mon, 12 Dec 2011 07:52:51 GMT] INFO Successfully connected to Redis

23:57:41 app.1     | {"in_reply_to_user_id_str":"434705154","in_reply_to_status_id":null,"text":"@cortana_ai image me cortana","entities":{"urls":[],"hashtags":[],"user_mentions":[{"indices":[0,11],"screen_name":"cortana_ai","id_str":"434705154","name":"Cortana AI","id":434705154}]},"id_str":"146136627905961984","place":null,"truncated":false,"contributors":null,"in_reply_to_user_id":434705154,"source":"web","created_at":"Mon Dec 12 07:57:41 +0000 2011","geo":null,"retweet_count":0,"favorited":false,"coordinates":null,"in_reply_to_screen_name":"cortana_ai","in_reply_to_status_id_str":null,"user":{"profile_use_background_image":true,"lang":"en","favourites_count":0,"profile_text_color":"333333","id_str":"434705154","profile_background_image_url":"http:\/\/a1.twimg.com\/images\/themes\/theme14\/bg.gif","screen_name":"cortana_ai","statuses_count":5,"profile_link_color":"009999","description":"My name is Cortana and I am a Hubot.","is_translator":false,"follow_request_sent":null,"following":null,"geo_enabled":false,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme14\/bg.gif","created_at":"Mon Dec 12 06:19:52 +0000 2011","friends_count":1,"listed_count":0,"verified":false,"profile_background_color":"131516","show_all_inline_media":false,"profile_background_tile":true,"default_profile":false,"profile_sidebar_fill_color":"efefef","followers_count":1,"protected":false,"url":"https:\/\/github.com\/jingweno\/cortana_ai","profile_image_url":"http:\/\/a1.twimg.com\/profile_images\/1688503817\/Cortana_h3_normal.png","time_zone":null,"name":"Cortana AI","default_profile_image":false,"contributors_enabled":false,"profile_sidebar_border_color":"eeeeee","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1688503817\/Cortana_h3_normal.png","id":434705154,"notifications":null,"utc_offset":null,"location":"Halo"},"id":146136627905961984,"retweeted":false}
23:57:41 app.1     | 
23:57:41 app.1     | json{"in_reply_to_user_id_str":"434705154","in_reply_to_status_id":null,"text":"@cortana_ai image me cortana","entities":{"urls":[],"hashtags":[],"user_mentions":[{"indices":[0,11],"screen_name":"cortana_ai","id_str":"434705154","name":"Cortana AI","id":434705154}]},"id_str":"146136627905961984","place":null,"truncated":false,"contributors":null,"in_reply_to_user_id":434705154,"source":"web","created_at":"Mon Dec 12 07:57:41 +0000 2011","geo":null,"retweet_count":0,"favorited":false,"coordinates":null,"in_reply_to_screen_name":"cortana_ai","in_reply_to_status_id_str":null,"user":{"profile_use_background_image":true,"lang":"en","favourites_count":0,"profile_text_color":"333333","id_str":"434705154","profile_background_image_url":"http:\/\/a1.twimg.com\/images\/themes\/theme14\/bg.gif","screen_name":"cortana_ai","statuses_count":5,"profile_link_color":"009999","description":"My name is Cortana and I am a Hubot.","is_translator":false,"follow_request_sent":null,"following":null,"geo_enabled":false,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme14\/bg.gif","created_at":"Mon Dec 12 06:19:52 +0000 2011","friends_count":1,"listed_count":0,"verified":false,"profile_background_color":"131516","show_all_inline_media":false,"profile_background_tile":true,"default_profile":false,"profile_sidebar_fill_color":"efefef","followers_count":1,"protected":false,"url":"https:\/\/github.com\/jingweno\/cortana_ai","profile_image_url":"http:\/\/a1.twimg.com\/profile_images\/1688503817\/Cortana_h3_normal.png","time_zone":null,"name":"Cortana AI","default_profile_image":false,"contributors_enabled":false,"profile_sidebar_border_color":"eeeeee","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1688503817\/Cortana_h3_normal.png","id":434705154,"notifications":null,"utc_offset":null,"location":"Halo"},"id":146136627905961984,"retweeted":false}
23:57:41 app.1     | received @cortana_ai image me cortana from cortana_ai

Unclear documentation in README.md

There is a reference to Twilio in the Usage section of README.md - "Then you will need to set the HTTP endpoint on Twilio to point to your server and make sure the request type is set to GET." I'm not sure why it's there.

Adapter posts to @undefined user when using http-post-say script

After installing http-post-say I was successfully able to use it to post content to my twitter timeline.

However by default the adapter apparently assumes that every message has to reply to a user and since there is none javascript gives us @undefined.

It may be that something had to be done either in the post-say script to play nice with this adapter or the adapter will have to account for posts done by cURL and http-post-say.

(At least for the short term, I'm getting what I need done with Twidge.)

Heroku crashes

It seems to not be able to load on heroku with latest hubot and twitter adapter. What more do you need to fix?

State changed from crashed to starting
2012-09-27T00:16:15+00:00 heroku[web.1]: Starting process with command bin/hubot -a twitter -n my_twitter
2012-09-27T00:16:16+00:00 app[web.1]: bin/hubot: 3: npm: not found
2012-09-27T00:16:19+00:00 app[web.1]: [Thu Sep 27 2012 00:16:19 GMT+0000 (UTC)] ERROR Cannot load adapter twitter - TypeError: Object # has no method 'robot'
2012-09-27T00:16:19+00:00 app[web.1]: TypeError: Object # has no method 'robot'
2012-09-27T00:16:19+00:00 app[web.1]: at Object. (/app/node_modules/hubot-twitter/src/twitter.coffee:7:28)
2012-09-27T00:16:19+00:00 app[web.1]: at Object. (/app/node_modules/hubot-twitter/src/twitter.coffee:169:4)
2012-09-27T00:16:19+00:00 app[web.1]: at Module._compile (module.js:446:26)
2012-09-27T00:16:19+00:00 app[web.1]: at Object..coffee (/app/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/coffee-script.js:22:21)
2012-09-27T00:16:19+00:00 app[web.1]: at Module.load (module.js:353:31)
2012-09-27T00:16:19+00:00 app[web.1]: at Function._load (module.js:311:12)
2012-09-27T00:16:19+00:00 app[web.1]: at Module.require (module.js:359:17)
2012-09-27T00:16:19+00:00 app[web.1]: at require (module.js:375:17)
2012-09-27T00:16:19+00:00 app[web.1]: at Robot.loadAdapter (/app/node_modules/hubot/src/robot.coffee:215:31)
2012-09-27T00:16:19+00:00 app[web.1]: at new Robot (/app/node_modules/hubot/src/robot.coffee:47:14)
2012-09-27T00:16:19+00:00 app[web.1]: TypeError: Cannot call method 'on' of null
2012-09-27T00:16:19+00:00 app[web.1]: at Object. (/app/node_modules/hubot/bin/hubot:105:19)
2012-09-27T00:16:19+00:00 app[web.1]: at Object. (/app/node_modules/hubot/bin/hubot:109:4)
2012-09-27T00:16:19+00:00 app[web.1]: at Module._compile (module.js:446:26)
2012-09-27T00:16:19+00:00 app[web.1]: at Object.run (/app/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/coffee-script.js:79:25)
2012-09-27T00:16:19+00:00 app[web.1]: at /app/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/command.js:175:29
2012-09-27T00:16:19+00:00 app[web.1]: at /app/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/command.js:150:18
2012-09-27T00:16:19+00:00 app[web.1]: at [object Object]. (fs.js:123:5)
2012-09-27T00:16:19+00:00 app[web.1]: at [object Object].emit (events.js:64:17)
2012-09-27T00:16:19+00:00 app[web.1]: at Object.oncomplete (fs.js:1190:12)
2012-09-27T00:16:20+00:00 heroku[web.1]: Process exited with status 1
2012-09-27T00:16:20+00:00 heroku[web.1]: State changed from starting to crashed

Filter reply make by Hubot

Just check before analyse the message if it's the bot who is tweeting or not. If it's it, do nothing with the tweet.

More detail in README please

"Then you will need to set the HTTP endpoint on Twitter to point to your server and make sure the request type is set to GET"

I'm not exactly sure where to go on Twitter to set this. Please can you help? I'm deploying with Heroku.

TypeError at run hubot

When I run hubot command, I got type error.

$ bin/hubot -a twitter -n TWITTER_USERNAME

ERROR Cannot load adapter twitter - TypeError: Object #<Object> has no method 'robot'
TypeError: Object #<Object> has no method 'robot'
at Object.<anonymous> (hubot/node_modules/hubot-twitter/src/twitter.coffee:7:28)
at Object.<anonymous> (hubot/node_modules/hubot-twitter/src/twitter.coffee:169:4)

And I've already read this:
https://github.com/MathildeLemee/hubot-twitter/blob/master/README.md

I've tried

to install bundle:

npm install

to add this into dependencies on package.json:

"hubot-twitter": ">= 2.0.4",
"hubot": ">= 2.0.0"

to add variables on Heroku

% heroku config:add HUBOT_TWITTER_KEY="..."
% heroku config:add HUBOT_TWITTER_SECRET="..."
% heroku config:add HUBOT_TWITTER_TOKEN="..."
% heroku config:add HUBOT_TWITTER_TOKEN_SECRET="..."

Is that means hubot of the latest version is not compatible hubot-twitter?

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.