mispy-archive / twitter_ebooks

Better twitterbots for all your friends~
MIT License
972 stars 140 forks source link

Mention reply breaks Twitter limit #126

Closed koboldunderlord closed 8 years ago

koboldunderlord commented 8 years ago

I haven't dug enough into this to get a good understanding of what happened enough to submit a pull request to fix this or anything, but my bot recently broke by generating a Twitter response with mentions that had more than 140 characters.

The method call just stuffs the response into the make_response method in the model.

The following is the tweet that it generated to break it, as well as the stack trace:

@vahnj_blabber: Replying to @allynfolksjr with: @allynfolksjr @vahnj the only thing I can think I would actually approve of off the game's mechanically quit
e good now so important and she deserves hella $$$!
@vahnj_blabber: #<Twitter::Error::Forbidden: Status is over 140 characters.>
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/rest/response/raise_error.rb:13:in `on_complete'
        /var/lib/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/response.rb:9:in `block in call'
        /var/lib/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/response.rb:57:in `on_complete'
        /var/lib/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/response.rb:8:in `call'
        /var/lib/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/request/url_encoded.rb:15:in `call'
        /var/lib/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/request/multipart.rb:14:in `call'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/rest/request/multipart_with_file.rb:19:in `call'
        /var/lib/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/rack_builder.rb:139:in `build_response'
        /var/lib/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/connection.rb:377:in `run_request'
        /var/lib/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/connection.rb:177:in `post'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/rest/request.rb:33:in `perform'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/rest/utils.rb:50:in `perform_request'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/rest/utils.rb:72:in `perform_request_with_object'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/rest/utils.rb:64:in `perform_post_with_object'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/rest/tweets.rb:158:in `update!'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/rest/tweets.rb:128:in `update'
        /var/lib/gems/2.1.0/gems/twitter_ebooks-3.1.6/lib/twitter_ebooks/bot.rb:416:in `reply'
        bots.rb:55:in `on_mention'
        /var/lib/gems/2.1.0/gems/twitter_ebooks-3.1.6/lib/twitter_ebooks/bot.rb:373:in `fire'
        /var/lib/gems/2.1.0/gems/twitter_ebooks-3.1.6/lib/twitter_ebooks/bot.rb:297:in `receive_event'
        /var/lib/gems/2.1.0/gems/twitter_ebooks-3.1.6/lib/twitter_ebooks/bot.rb:363:in `block in start'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/streaming/client.rb:116:in `block in request'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/streaming/response.rb:27:in `call'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/streaming/response.rb:27:in `block in on_body'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/streaming/response.rb:25:in `each'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/streaming/response.rb:25:in `on_body'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/streaming/response.rb:16:in `<<'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/streaming/response.rb:16:in `<<'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/streaming/connection.rb:22:in `stream'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/streaming/client.rb:119:in `request'
        /var/lib/gems/2.1.0/gems/twitter-5.16.0/lib/twitter/streaming/client.rb:92:in `user'
        /var/lib/gems/2.1.0/gems/twitter_ebooks-3.1.6/lib/twitter_ebooks/bot.rb:362:in `start'
        /var/lib/gems/2.1.0/gems/twitter_ebooks-3.1.6/bin/ebooks:346:in `block (3 levels) in start'
        /var/lib/gems/2.1.0/gems/twitter_ebooks-3.1.6/bin/ebooks:344:in `loop'
        /var/lib/gems/2.1.0/gems/twitter_ebooks-3.1.6/bin/ebooks:344:in `block (2 levels) in start'
ncovercash commented 8 years ago

Your Model.make_response(###) is too high. For replys, I would do 80, maybe 90 at most

koboldunderlord commented 8 years ago

Ah, so the limit doesn't automatically account for the mentions size, just the total character count of the response generated. Thanks

ncovercash commented 8 years ago

Yes. If you try ebooks console you can find that the number supplied is the maximum number of chars that will be generated