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

dev
Aaron Johnson 7 years ago committed by Gitea
commit f0b2947455

@ -8,4 +8,8 @@ admin:
- 11111111
authorized_chats:
- 11111111
allowed_sources:
- 'private'
- 'group'
- 'supergroup'

@ -1,3 +1,10 @@
def validate_incoming_data(message)
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)
puts message.chat.type
return true
end
def message_from_admin?(message, adm)
#return @admin_userids.include? message.from.id.to_s
#puts adm.class

@ -13,6 +13,7 @@ token = @conf['token']
telnet = @conf['telnet']
admin = @conf['admin']
@auth_chat = @conf['authorized_chats']
@allowed_sources = @conf['allowed_sources']
# Sanity check
errcount = 0
@ -72,12 +73,12 @@ def handle_message(message)
#Format command
command = message.text.split(" ")[0].split("@")[0].downcase #Strip command from arguments and @tags
#command = message.text
reply = 'Empty String'
#conf = YAML.load_file("bot_config.yaml")
telnet = @conf['telnet']
adm = @conf['admin']
#case message.text.split(" ")[0].split("@")[0].downcase #Strip command from arguments and @tags
puts "Received command from #{message.from.username}: #{command}"
case command
when '/start'
@ -142,12 +143,20 @@ end
Telegram::Bot::Client.run(token) do |bot|
bot.listen do |message|
#pp message
validation = validate_incoming_data(message)
#puts "DEBUG: #{validation}"
if validation
reply = handle_message(message)
if reply == "dance" || reply == "flex"
bot.api.sendVideo(chat_id: message.chat.id, video: "https://img.skyfalltech.net/togra/#{reply}.gif")
else
bot.api.send_message(chat_id: message.chat.id, text: "#{reply}")
end
else
puts "Received bad data! [#{message.chat.type}]"
puts validation
end
end
end

Loading…
Cancel
Save