OpenEastleigh / eastleighmp

Eastleigh MP twitter bot
https://twitter.com/eastleighmp
Apache License 2.0
0 stars 0 forks source link

Error mirroring tweet #1

Closed jt-nti closed 4 years ago

jt-nti commented 4 years ago

Error tweeting second tweet with following env vars:

FROM=pauljholmes SINCE=2020-07-11 UNTIL=2020-07-12

First tweet was successful, but this tweet...

"RT HedgeEndTown: Hedge End Good Neighbours Network** \nVolunteer drivers & Call handlers urgently needed to help assist elderly clients to…"

...fails with:

Traceback (most recent call last):
        13: from /home/jtnix/.rbenv/versions/2.6.5/bin/twurl:23:in `<main>'
        12: from /home/jtnix/.rbenv/versions/2.6.5/bin/twurl:23:in `load'
        11: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/bin/twurl:4:in `<top (required)>'
        10: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/cli.rb:21:in `run'
         9: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/cli.rb:40:in `dispatch'
         8: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/abstract_command_controller.rb:7:in `dispatch'
         7: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/request_controller.rb:15:in `dispatch'
         6: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/request_controller.rb:19:in `perform_request'
         5: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/oauth_client.rb:182:in `perform_request_from_options'
         4: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/oauth_client.rb:173:in `build_request_from_options'
         3: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/oauth_client.rb:173:in `map'
         2: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/oauth_client.rb:173:in `each'
         1: from /home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/oauth_client.rb:174:in `block in build_request_from_options'
/home/jtnix/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/oauth_client.rb:174:in `escape': no implicit conversion of nil into String (TypeError)
jt-nti commented 4 years ago

I think this is being caused by the & but not sure how to fix it. Encoding it as %26 didn't work, i.e. it did then successfully tweet but did not show an ampersand! https://twitter.com/eastleighmp/status/1282246593815732224

jt-nti commented 4 years ago

Need to use the --raw-data option with encoded tweet text to fix the & problem. See twitter/twurl#33

jt-nti commented 4 years ago

Hopefully fixed now

jt-nti commented 4 years ago

Note: apparently html entity encoding is expected with the Twitter API, so decoding entities in retrieved Tweets should be ok...

https://twittercommunity.com/t/ampersands-are-translated-to-amp-when-received-by-the-account-activity-api/107607/3