Skip to content

Instantly share code, notes, and snippets.

@Goty

Goty/alarma.lua Secret

Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Goty/73c999afdfa1f382d658 to your computer and use it in GitHub Desktop.
Save Goty/73c999afdfa1f382d658 to your computer and use it in GitHub Desktop.
SCRIPTS_FOLDER = "/home/pi/workspace/tg/scripts/"
TOSEND_FOLDER = "/home/pi/workspace/tg/toSend/"
USER_ALLOWED = "NAME"
function on_msg_receive (msg)
if msg.out then
return
end
-- Allowed only our ID's
if (msg.from.print_name == USER_ALLOWED) then
if (msg.text=='foto') then
os.execute('lua5.2 ' .. SCRIPTS_FOLDER .. 'foto.lua')
send_photo(msg.from.print_name, TOSEND_FOLDER.. 'foto.jpg', ok_cb, false)
end
if (msg.text=='gif') then
os.execute('lua5.2 ' .. SCRIPTS_FOLDER .. 'gif.lua')
send_video(msg.from.print_name, TOSEND_FOLDER..'gif.gif', ok_cb, false)
end
if (msg.text=='video') then
os.execute('lua5.2 ' .. SCRIPTS_FOLDER .. 'video.lua')
send_video(msg.from.print_name, TOSEND_FOLDER..'video.mp4', ok_cb, false)
end
end
end
function on_our_id (id)
end
function on_secret_chat_created (peer)
end
function on_user_update (user)
end
function on_chat_update (user)
end
function on_get_difference_end ()
end
function on_binlog_replay_end ()
end
function ok_cb(extra, success, result)
end
FOLDER = "/home/pi/workspace/tg/media/"
TOSEND_FOLDER = "/home/pi/workspace/tg/toSend/"
--Quality 0 - 100
QUALITY = 5
name_folder = os.date("%H_%M_%S_%m_%d_%Y")
name_picture= os.date("%H_%M_%S_%m_%d_%Y")
os.execute('mkdir '..FOLDER..name_folder)
os.execute('raspistill -o ' .. FOLDER .. name_folder ..'/' ..name_picture..'.jpg -t 1 -q '.. QUALITY)
os.execute('cp ' .. FOLDER .. name_folder ..'/' ..name_picture..'.jpg ' .. TOSEND_FOLDER ..'/foto.jpg')
FOLDER = "/home/pi/workspace/tg/media/"
TOSEND_FOLDER = "/home/pi/workspace/tg/toSend/"
--Quality 0 - 100
QUALITY = 5
TIME_EACH_PHOTO = 3
NUMBER_OF_PICTURES = 4
name_folder = os.date("%H_%M_%S_%m_%d_%Y")
os.execute('mkdir '..FOLDER..name_folder)
for i = 1, NUMBER_OF_PICTURES do
name_picture= os.date("%H_%M_%S_%m_%d_%Y")
os.execute('raspistill -o ' .. FOLDER .. name_folder ..'/' ..name_picture..'.jpg -t 1 -q '..QUALITY..' -h 600 -w 900')
os.execute('sleep '..TIME_EACH_PHOTO)
end
os.execute('convert -delay 100 '.. FOLDER .. name_folder .. '/* -loop 0 ' ..FOLDER..name_folder..'/'..name_picture..'.gif' )
os.execute('cp ' .. FOLDER .. name_folder ..'/' ..name_picture..'.gif ' .. TOSEND_FOLDER ..'/gif.gif')
FOLDER = "/home/pi/workspace/tg/media/"
TOSEND_FOLDER = "/home/pi/workspace/tg/toSend/"
TIME = 3000
HEIGHT = 600
WIDTH = 900
name_folder = os.date("%H_%M_%S_%m_%d_%Y")
os.execute('mkdir '..FOLDER..name_folder)
name_video= os.date("%H_%M_%S_%m_%d_%Y")
os.execute('raspivid -o ' .. FOLDER .. name_folder ..'/' ..name_video..'.h264 -t '..TIME..' -h '..HEIGHT..' -w '..WIDTH..'')
os.execute('cp ' .. FOLDER .. name_folder ..'/'..name_video..'.h264 ' .. TOSEND_FOLDER ..'/video.mp4')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment