1
0
Fork 0

Remove unnecessary code

This commit is contained in:
Alex Kotov 2018-11-30 00:27:36 +05:00
parent f1ee0cc1b5
commit a4b08d98c3
No known key found for this signature in database
GPG Key ID: 4E831250F47DE154
1 changed files with 0 additions and 20 deletions

View File

@ -23,21 +23,9 @@ private
raise NotAuthorizedError unless params[:secret] == @telegram_bot.secret
end
# rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity
def handle_message(message)
handle_user message[:from] if message[:from]
return if message[:chat].nil?
(message[:entities] || []).each do |message_entity|
next unless message_entity[:type] == 'bot_command' &&
message_entity[:offset].zero? &&
message_entity[:length] == message[:text].length
handle_command message[:chat][:id], message[:text] if message[:chat]
end
end
# rubocop:enable AbcSize, CyclomaticComplexity, PerceivedComplexity
def handle_user(user)
telegram_user =
@ -51,12 +39,4 @@ private
telegram_user.save!
end
def handle_command(chat_id, command)
RestClient.post(
"https://api.telegram.org/bot#{@telegram_bot.api_token}/sendMessage",
chat_id: chat_id,
text: "Command: #{command}",
)
end
end