0
votes

This is very noob, but I'm still very interested. I'm using Ruby to develop telegram bot. https://github.com/atipugin/telegram-bot-ruby - this is my wrapper for this.

I have code:

bot.api.get_Chat_Members_Count(chat_id: message.chat.id)

I want to present a result in text in:

bot.api.send_message(chat_id: message.chat.id, text: "Results: %")

How can I link result of this method and print in into text?

1

1 Answers

0
votes

bot.api.get_chat_members_count(chat_id: message.chat.id) returns hash in format {"ok"=>true, "result"=>8}

So you need use key for this:

Telegram::Bot::Client.run(token) do |bot|
  bot.listen do |message|
    if message.text == '/start'
      count = bot.api.get_chat_members_count(chat_id: message.chat.id)['result']
      bot.api.send_message(chat_id: message.chat.id, text: "Result: #{count}")
    end
  end
end