如何通过Ruby中的Telegram Bot发送照片

时间:2019-08-23 17:04:10

标签: ruby telegram telegram-bot photo

当我尝试使用以下代码通过图片链接或图片的系统路径运行服务器时,出现以下错误

 message.reply do |reply|
    case command
    when /start/i
      reply.text = "Tudo o que consigo fazer é dizer Olá. Tenta /greet."
    when /greet/i
      greetings = ['bonjour', 'hola', 'hallo', 'sveiki', 'namaste', 'salaam', 'szia', 'halo', 'ciao']
      reply.text = "#{greetings.sample.capitalize}, #{message.from.first_name}!"
    when /photo/i
      reply.photo = ""
    else
      reply.text = "Não faço ideia do que #{command.inspect} significa."
    end
    puts "sending #{reply.text.inspect} to @#{message.from.username}"
    reply.send_with(bot)
  end
end
Traceback (most recent call last):
    8: from bot.rb:7:in `<main>'
    7: from /var/lib/gems/2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:32:in `get_updates'
    6: from /var/lib/gems/2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:32:in `loop'
    5: from /var/lib/gems/2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:34:in `block in get_updates'
    4: from /var/lib/gems/2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:34:in `each'
    3: from /var/lib/gems/2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:37:in `block (2 levels) in get_updates'
    2: from bot.rb:11:in `block in <main>'
    1: from /var/lib/gems/2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/message.rb:16:in `reply'
bot.rb:19:in `block (2 levels) in <main>': undefined method `photo=' for #<TelegramBot::OutMessage:0x000056463bf692f8> (NoMethodError)

0 个答案:

没有答案