reply="I am #{@botname}, and I am here to provide temperature information from various sensors. Currently I can retrieve information "+
"from temperature sensors as well as report when temperatures are out of a specified range.\n\n"+
"Commands available:\n/start (Shows this message)\n/check (Show temperatures, currently non-functional)\n/whoami or /chatinfo (Provides IDs for internal use)\n/whereareyou or /location (Provides hostname for bot server)\n\n"+
"Check again later to see if any new functions have been added, or use /patchnotes to learn about recent updates.\n"+
"You can also view the source code at the following location:\nhttps://git.skyfall.tech/skyfall/heatbot"
ifmessage_from_admin?(message,adm)
msg_from_admin=true
end
ifis_chat_authorized?(message,@auth_chat)
chat_authorized=true
end
if!msg_from_admin&&!chat_authorized
ifmessage.from.id==message.chat.id
reply=reply+"\n\nWARNING: I am not authorized to work with you directly. My functionality is limited."
else
reply=reply+"\n\nWARNING: I am not authorized to participate with this group. My functionality is limited."
end
elsifmsg_from_admin&&!chat_authorized
reply=reply+"\n\nWARNING: Although you are an administrator, I have not been authorized to participate in this group. My functionality is limited."
putstimestamp+"send_question called without any possible answers provided"
end
STDOUT.flush
end
defhandle_message(message)
if!message.reply_to_message.nil?then
#drop message. Someone's replying to a message
#sent by our bot
#drop message. Someone's replying to a message sent by our bot
message.text=nil
return
end
ifmessage.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
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
@ -159,91 +233,108 @@ def handle_message(message)
#Format command
command=message.text.split("")[0].split("@")[0].downcase#Strip command from arguments and @tags
## Constant collection model (may be scrapped)
#last_collection = 0
#loop do
# collection_time = Time.now
# if collection_time - last_collection >= 10
# puts timestamp + ": [#{collection_time}] Updating records //Not really"
# last_collection = collection_time
# STDOUT.flush
# end
#end
reply='Empty String'
adm=@conf['admin']
putsTime.now.strftime("%F %H:%M:%S").yellow+": Received command from "+"#{message.from.username}".cyan.bold+" ["+"#{message.from.id}".cyan+"]: "+"#{command}".magenta.bold
putstimestamp+": Received command from "+"#{message.from.username}".cyan.bold+" ["+"#{message.from.id}".cyan+"]: "+"#{command}".magenta.bold
casecommand
when'/start'
reply="I am #{@botname}, and I am here to provide temperature information from various sensors. Currently I can retrieve information "+
"from temperature sensors as well as report when temperatures are out of a specified range.\n\n"+
"Commands available:\n/start (Shows this message)\n/check (Show temperatures, currently non-functional)\n/whoami or /chatinfo (Provides IDs for internal use)\n/whereareyou or /location (Provides hostname for bot server)\n\n"+
"Check again later to see if any new functions have been added, or use /patchnotes to learn about recent updates.\n"+
"You can also view the source code at the following location:\nhttps://git.skyfall.tech/skyfall/heatbot"
ifmessage_from_admin?(message,adm)
msg_from_admin=true
end
ifis_chat_authorized?(message,@auth_chat)
chat_authorized=true
end
if!msg_from_admin&&!chat_authorized
ifmessage.from.id==message.chat.id
reply=reply+"\n\nWARNING: I am not authorized to work with you directly. My functionality is limited."
else
reply=reply+"\n\nWARNING: I am not authorized to participate with this group. My functionality is limited."
end
elsifmsg_from_admin&&!chat_authorized
reply=reply+"\n\nWARNING: Although you are an administrator, I have not been authorized to participate in this group. My functionality is limited."