Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function vardump(value, depth, key)
- local linePrefix = ""
- local spaces = ""
- if key ~= nil then
- linePrefix = "["..key.."] = "
- end
- if depth == nil then
- depth = 0
- else
- depth = depth + 1
- for i=1, depth do spaces = spaces .. " " end
- end
- if type(value) == 'table' then
- mTable = getmetatable(value)
- if mTable == nil then
- print(spaces ..linePrefix.."(table) ")
- else
- print(spaces .."(metatable) ")
- value = mTable
- end
- for tableKey, tableValue in pairs(value) do
- vardump(tableValue, depth, tableKey)
- end
- elseif type(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
- local lgi = require ('lgi')
- local notify = lgi.require('Notify')
- notify.init ("Telegram updates")
- chats = {}
- function do_notify (user, msg)
- --local n = notify.Notification.new("message", "<span font=\"Inconsolata 40\">" .. user .. "<br>".. msg .. "</span>")
- local n = notify.Notification.new(user, msg)
- n:show ()
- end
- function dl_cb (arg, data)
- end
- function tdcli_update_callback (data)
- if (data.ID == "UpdateNewMessage") then
- local msg = data.message_
- local d = data.disable_notification_
- local chat = chats[msg.chat_id_]
- if ((not d) and chat) then
- if msg.content_.ID == "MessageText" then
- do_notify (chat.title_, msg.content_.text_)
- else
- do_notify (chat.title_, msg.content_.ID)
- end
- end
- if msg.content_.ID == "MessageText" and msg.content_.text_ == "ping" then
- tdcli_function ({ID="SendMessage", chat_id_=msg.chat_id_, reply_to_message_id_=msg.id_, disable_notification_=0, from_background_=1, reply_markup_=nil, input_message_content_={ID="InputMessageText", text_="pong", disable_web_page_preview_=1, clear_draft_=0, entities_={}}}, dl_cb, nil)
- end
- elseif (data.ID == "UpdateChat") then
- chat = data.chat_
- chats[chat.id_] = chat
- elseif (data.ID == "UpdateOption" and data.name_ == "my_id") then
- tdcli_function ({ID="GetChats", offset_order_="9223372036854775807", offset_chat_id_=0, limit_=20}, dl_cb, nil)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement