Remove unnecessary code
This commit is contained in:
parent
f1ee0cc1b5
commit
a4b08d98c3
|
@ -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
|
||||
|
|
Reference in New Issue