forked from slp/tg-notify
-
Notifications
You must be signed in to change notification settings - Fork 1
/
notify.lua
53 lines (40 loc) · 943 Bytes
/
notify.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
local icon_file = ""
our_id = 0
now = os.time()
--http://superuser.com/questions/114798/is-there-a-way-to-escape-single-quotes-in-the-shell#114844
function escape(unescaped_string)
return string.gsub(unescaped_string, "\'", "\'\\'\'")
end
function notify(summary, body)
local msg = "notify-send '" .. escape(summary) .. "' '" .. escape(body) .. "' -i " .. icon_file
io.popen (msg)
end
--print ("HI, this is lua script")
function on_msg_receive (msg)
if msg.date < now then
return
end
if msg.out then
return
end
if msg.text == nil then
return
end
if msg.unread == 0 then
return
end
notify("Message from " .. msg.from.print_name, msg.text)
end
function on_our_id (id)
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