Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tgl
- import pprint
- from functools import partial
- pp = pprint.PrettyPrinter(indent=4)
- def on_binlog_replay_end():
- tgl.get_contact_list(contact_list_cb)
- def contact_list_cb(success, peer_list):
- if not success:
- return
- for peer in peer_list:
- if peer.name == "Username":
- peer.history(0, HISTORY_QUERY_SIZE, partial(history_cb, peer))
- HISTORY_QUERY_SIZE = 100
- parsed_count = 0
- def history_cb(peer, success, msgs):
- global parsed_count
- if not success:
- print("ERROR")
- return
- #for msg in msgs:
- #if msg.media:
- #msg.load_document(file_cb)
- size = len(msgs)
- parsed_count += size
- print("parsed %d messages" % parsed_count)
- if size == HISTORY_QUERY_SIZE:
- peer.history(parsed_count, HISTORY_QUERY_SIZE, partial(history_cb, peer));
- def file_cb(success, path):
- if success:
- print(path)
- def on_secret_chat_update(peer, types):
- pass
- def on_user_update(a, b):
- pass
- def on_chat_update(a, b):
- pass
- def on_msg_receive(msg):
- pass
- def on_get_difference_end():
- pass
- def on_our_id(id):
- pass
- tgl.set_on_binlog_replay_end(on_binlog_replay_end)
- tgl.set_on_get_difference_end(on_get_difference_end)
- tgl.set_on_our_id(on_our_id)
- tgl.set_on_msg_receive(on_msg_receive)
- tgl.set_on_secret_chat_update(on_secret_chat_update)
- tgl.set_on_user_update(on_user_update)
- tgl.set_on_chat_update(on_chat_update)
Advertisement
Add Comment
Please, Sign In to add comment