Merge branch 'dev' of skyfall/empyrion-bot into master

dev
Aaron Johnson 7 years ago committed by Gitea
commit b24e853413

@ -1,7 +1,9 @@
def validate_incoming_data(message) def validate_incoming_data(message)
auth_chat = @conf['auth_chat']
message = message.message if message.is_a? Telegram::Bot::Types::CallbackQuery message = message.message if message.is_a? Telegram::Bot::Types::CallbackQuery
return "Received message is not from a valid source! Type: \"#{message.chat.type}\". Ignoring." if ! @allowed_sources.include?(message.chat.type) return "Received message is not from a valid source! Type: \"#{message.chat.type}\". Ignoring." if ! @allowed_sources.include?(message.chat.type)
puts message.chat.type #return "Unauthorized user sent message. User ID: #{message.from.id} Source ID: #{message.chat.id}." if ! auth_chat.include?(message.chat.id.to_s)
#puts message.chat.type
return true return true
end end

@ -64,6 +64,23 @@ puts "Bot token: #{token}\n\n\n\n"
#end #end
def handle_message(message) def handle_message(message)
if ! message.reply_to_message.nil? then
#drop message. Someone's replying to a message
#sent by our bot
message.text = nil
return
end
if message.text.nil?
# Find out if user(s) joined the group. If so, welcome them
#if ! message.new_chat_members.nil?
# handle_user_join(message)
#else
# #Handle non-messages and non-joins here
#end
return #so that we don't try to process this as a command (below)
end
#Format sender name #Format sender name
if ! message.from.username.nil? if ! message.from.username.nil?
message.from.username = "@" + message.from.username message.from.username = "@" + message.from.username
@ -150,7 +167,7 @@ Telegram::Bot::Client.run(token) do |bot|
reply = handle_message(message) reply = handle_message(message)
if reply == "dance" || reply == "flex" if reply == "dance" || reply == "flex"
bot.api.sendVideo(chat_id: message.chat.id, video: "https://img.skyfalltech.net/togra/#{reply}.gif") bot.api.sendVideo(chat_id: message.chat.id, video: "https://img.skyfalltech.net/togra/#{reply}.gif")
else elsif ! message.text.nil?
bot.api.send_message(chat_id: message.chat.id, text: "#{reply}") bot.api.send_message(chat_id: message.chat.id, text: "#{reply}")
end end
else else

Loading…
Cancel
Save