电报给我 {" ok" => true,"结果" => true} 甚至显示按钮"切换到PM",但没有出现任何答案结果。从我的观点来看,唯一可以解决的是我为阵列发送数据做准备。有谁可以帮助我?
这里的代码示例:
Telegram::Bot::Client.run(token) do |bot|
bot.listen do |message|
case message
when Telegram::Bot::Types::Message
puts "Message @#{message.from.username}: #{message.text}"
bot.api.send_message(chat_id: message.chat.id, text: "I am only inline bot for now" )
when Telegram::Bot::Types::InlineQuery
puts " InlineQuery @#{message.from.username}: #{message.query} and #{message.id}"
results = [ JSON.parse('{"type":"article", "id":"0", "title":"Cool Blog", "message_text":"I am the author of this bot, please visit my blog"}'), JSON.parse('{"type":"article", "id":"1", "title":"Cool Blog", "message_text":"I am the author of this bot, please visit my blog"}')]
puts bot.api.answer_inline_query(inline_query_id: message.id, results: results, switch_pm_text:"PM me please", cache_time: 86400)
end
end
end
答案 0 :(得分:0)
只需将gem更新为版本'0.5',它就可以正常运行gem install 'telegram-bot-ruby'