ruby 推特 gem:战术反喷子响应机器人回复,但时间轴不显示推文回复

ruby twitter gem: tactical anti-troll response-bot replies, but timeline doesn't show tweet replied to

我正在创建一个机器人来回复某些单词(可能指定为 'troll' 单词),其中引用了 George Orwell 小说 1984 使用 'twitter' ruby gem。目前我的代码如下所示:

require 'yaml'
require 'twitter'
require 'thor'
require 'httparty'
require 'colorize'

puts '\|/|\|/'.red + ' Loading anti-troll tactical auto-canon! '.blue + '\|/|\|/'.red + "\n"

trollWords = ['Satan', 'Trump tower', 'libtard', 'nihilism', 'alt-right', 'feminazi', 'genocide', 'gulag', 'trigger-warning', 'special snowflake', 'privilege', 'ugly', 'moron', 'block-list', 'nazi']
quotes = ['Perhaps one did not want to be loved so much as to be understood.', 'Who controls the past controls the future. Who controls the present controls the past.', 'War is peace. Freedom is slavery. Ignorance is strength.', 'The best books... are those that tell you what you know already.', 'If you want to keep a secret, you must also hide it from yourself.', 'If you want a picture of the future, imagine a boot stamping on a human face — forever.', 'We shall meet in the place where there is no darkness.', 'But if thought corrupts language, language can also corrupt thought.', 'Doublethink means the power of holding two contradictory beliefs in one\'s mind simultaneously, and accepting both of them.', 'Until they became conscious they will never rebel, and until after they have rebelled they cannot become conscious.', 'The Party seeks power entirely for its own sake.', 'Russian Communists came very close to us in their methods, but they never had the courage to recognize their own motives.', 'Perhaps a lunatic was simply a minority of one.', 'If you loved someone, you loved him, and when you had nothing else to give, you still gave him love.', 'In the face of pain there are no heroes.', 'Big Brother is Watching You.', 'Reality exists in the human mind, and nowhere else.', 'Orthodoxy means not thinking--not needing to think. Orthodoxy is unconsciousness.', 'Nothing was your own except the few cubic centimetres inside your skull.', 'Confession is not betrayal.', 'Sanity is not statistical.']
client = Twitter::REST::Client.new do |config|
  config.consumer_key = '[key]'
  config.consumer_secret = '[secret]'
  config.access_token = '[token]'
  config.access_token_secret = '[token secret]'
end

word = trollWords.sample
quote = quotes.sample

def output_init_string(word, quote)
   puts "Troll identification word: " + word + ".\n" + "Response quote: " + quote
end

client.search(word, count: 10).each do |t|
  quote = quotes.sample
  word = trollWords.sample
  replystring = "@" + t.user.screen_name + " " + quote
  puts "Found possible troll suspect: " + t.user.screen_name + "\nTweeting: " + t.text + "\nReplied with: " + replystring + "\n"
  client.update(replystring, in_reply_to_status_id: t)
  sleep(300)
end

它确实有效,但是当我展开回复的详细信息时,我看不到原始推文,只能看到我的机器人的回复和@[用户]。谁能告诉我如何使原始用户的推文在详细信息展开时可见? 因此,例如在控制台输出中我可以看到:

但是如果我点击我的机器人的回复,我只会看到:

https://twitter.com/bravebot1984/status/832328576619921413,没有说明推文的回复内容。

这个问题不是链接问题的重复,因为我已经在使用建议给 'reply' 的方法,并且该方法确实导致了各种回复,但它没有正确显示详细展开,我需要。

in_reply_to_status_id: tt 必须是推文的 id。您的当前值看起来像对象。尝试 t.idt["id"]

我知道 tTwitter::Tweet 的一个实例。您可以使用 in_reply_to_status 而不是 in_reply_to_status_id,例如:

client.update(replystring, in_reply_to_status: t)

参见:http://www.rubydoc.info/gems/twitter/Twitter/REST/Tweets#update-instance_method