得到电报以回应新用户(红宝石)

时间:2018-12-12 01:48:14

标签: ruby-on-rails bots telegram

我正在尝试用ruby对电报机器人进行编码,以识别new_chat_members并响应命令,而在该bot正常工作的那一刻,它只是无法识别新成员,而是使用else命令来响应。

有人有任何解决方案或解决方法吗?

require 'telegram_bot'

bot = TelegramBot.new(token: 'token api')
bot.get_updates(fail_silently: true) do |message|
puts "@#{message.from.username}: #{message.text}"

command = message.get_command_for(bot)

  message.reply do |reply|
    case command
    when /start/i
      reply.text = "Hi Try /help for command list."
    when /help/i 
      reply.text = "A list of commands that you can use.

     /greet - greets new users.  

     /website - Provides a link to the Connect Platform.

    /price - Displays current price.

    /supply - Total circulating supply."
    when /greet/i
      reply.text = "Hello, #{message.from.first_name}.  Welcome to Connect 
      telegram, If you need any /help just ask."
    when /website/i
      reply.text = "welcome, #{message.from.first_name} to the Connect 
      Platform."
    when /price/i
      reply.text = "Current price of 
    when /supply/i
      reply.text = "Circulating supply.
    when /hi/i
      reply.text = "Hi, #{message.from.first_name} Welcome to Connect 
      telegram, If you need any /help just ask."        
    if 
      reply.text = "Hi, #{message.from.new_chat_member}Welcome to the 
      connect telegram channel"
    end
    else  
      reply.text = "Hi, #{message.from.first_name} I do not know what # 
      {command.inspect} means, try /help for command list"
   end
      puts "sending #{reply.text.inspect} to @#{message.from.username}"
      reply.send_with(bot) 
   end
 end

0 个答案:

没有答案