Uh oh!
There was an error while loading. Please reload this page.
forked from ModernTechnologyPlayers01/tg
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.lua
More file actions
Latest commit
126 lines (106 loc) · 2.51 KB
/
Copy pathtest.lua
File metadata and controls
126 lines (106 loc) · 2.51 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
started=0
our_id=0
functionvardump(value, depth, key)
locallinePrefix=""
localspaces=""
ifkey~=nilthen
linePrefix="["..key.."] = "
end
ifdepth==nilthen
depth=0
else
depth=depth+1
fori=1, depthdospaces=spaces.."" end
end
iftype(value) =='table' then
mTable=getmetatable(value)
ifmTable==nilthen
print(spaces..linePrefix.."(table) ")
else
print(spaces.."(metatable) ")
value=mTable
end
fortableKey, tableValueinpairs(value) do
vardump(tableValue, depth, tableKey)
end
elseiftype(value) =='function' or
type(value) =='thread' or
type(value) =='userdata' or
value==nil
then
print(spaces..tostring(value))
else
print(spaces..linePrefix.."("..type(value)..") "..tostring(value))
end
end
print ("HI, this is lua script")
functionok_cb(extra, success, result)
end
-- Notification code {{{
functionget_title (P, Q)
if (Q.type=='user') then
returnP.first_name.."" ..P.last_name
elseif (Q.type=='chat') then
returnQ.title
elseif (Q.type=='encr_chat') then
return'Secret chat with ' ..P.first_name..'' ..P.last_name
else
return''
end
end
locallgi=require ('lgi')
localnotify=lgi.require('Notify')
notify.init ("Telegram updates")
localicon=os.getenv("HOME") .."/.telegram-cli/telegram-pics/telegram_64.png"
functiondo_notify (user, msg)
localn=notify.Notification.new(user, msg, icon)
n:show ()
end
-- }}}
functionon_msg_receive (msg)
ifstarted==0then
return
end
ifmsg.outthen
return
end
do_notify (get_title (msg.from, msg.to), msg.text)
if (msg.text=='ping') then
if (msg.to.id==our_id) then
send_msg (msg.from.print_name, 'pong', ok_cb, false)
else
send_msg (msg.to.print_name, 'pong', ok_cb, false)
end
return
end
if (msg.text=='PING') then
if (msg.to.id==our_id) then
fwd_msg (msg.from.print_name, msg.id, ok_cb, false)
else
fwd_msg (msg.to.print_name, msg.id, ok_cb, false)
end
return
end
end
functionon_our_id (id)
our_id=id
end
functionon_user_update (user, what)
--vardump (user)
end
functionon_chat_update (chat, what)
--vardump (chat)
end
functionon_secret_chat_update (schat, what)
--vardump (schat)
end
functionon_get_difference_end ()
end
functioncron()
-- do something
postpone (cron, false, 1.0)
end
functionon_binlog_replay_end ()
started=1
postpone (cron, false, 1.0)
end