Skip to content

Instantly share code, notes, and snippets.

@Goty
Last active July 19, 2016 13:55
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/05e790f5f425144633117635560a21e6 to your computer and use it in GitHub Desktop.
Save Goty/05e790f5f425144633117635560a21e6 to your computer and use it in GitHub Desktop.
local allowed_users_id = {id1,id2}
local command = 'Download'
---------------------------------------------------
started = 0
our_id = 0
print ("HI, this is lua script")
function ok_cb(extra, success, result)
end
command_before = ''
function on_msg_receive (msg)
if started == 0 then
return
end
if msg.out then
return
end
print('Id de ' ..msg.from.print_name.. ' : '..msg.from.peer_id)
for _,v in pairs(allowed_users_id) do
if v == msg.from.peer_id then
if command_before == command then
if msg.text then
if string.find(msg.text, "magnet") then
os.execute('transmission-cli '..msg.text)
end
end
if msg.media then
if msg.media.type == 'document' then
load_document(msg.id, cb_ok, msg.id)
end
if msg.media.type == 'photo' then
load_photo(msg.id, cb_ok, msg.id)
end
if msg.media.type == 'video' then
load_video(msg.id, cb_ok, msg.id)
end
if msg.media.type == 'audio' then
load_audio(msg.id, cb_ok, msg.id)
end
end
command_before = msg.text
print (command_before)
break
end
end
command_before = msg.text
print(command_before)
end
end
function on_our_id (id)
our_id = id
end
function on_user_update (user, what)
--vardump (user)
end
function on_chat_update (chat, what)
--vardump (chat)
end
function on_secret_chat_update (schat, what)
--vardump (schat)
end
function on_get_difference_end ()
end
function cron()
-- do something
postpone (cron, false, 1.0)
end
function on_binlog_replay_end ()
started = 1
postpone (cron, false, 1.0)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment