2015-02-26 12:46:38 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2015-03-12 22:42:24 +01:00
|
|
|
import os
|
|
|
|
import io
|
|
|
|
import struct
|
|
|
|
# Deal with py2 and py3 differences
|
2015-03-16 12:38:12 +01:00
|
|
|
try: # this only works in py2.7
|
2015-03-12 22:42:24 +01:00
|
|
|
import configparser
|
|
|
|
except ImportError:
|
|
|
|
import ConfigParser as configparser
|
2015-03-16 15:22:18 +01:00
|
|
|
import mtproto
|
2015-03-17 00:02:01 +01:00
|
|
|
|
2015-03-16 15:22:18 +01:00
|
|
|
|
2015-03-11 23:52:26 +01:00
|
|
|
|
|
|
|
config = configparser.ConfigParser()
|
2015-03-12 22:42:24 +01:00
|
|
|
# Check if credentials is correctly loaded (when it doesn't read anything it returns [])
|
|
|
|
if not config.read('credentials'):
|
|
|
|
print("File 'credentials' seems to not exist.")
|
|
|
|
exit(-1)
|
|
|
|
ip = config.get('App data', 'ip_address')
|
|
|
|
port = config.getint('App data', 'port')
|
2015-02-26 12:46:38 +01:00
|
|
|
|
2015-03-17 17:28:24 +01:00
|
|
|
Session = mtproto.Session(ip, port)
|
|
|
|
Session.create_auth_key()
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
while True:
|
|
|
|
f = Session.method_call('ping', ping_id=i)
|
|
|
|
print(f)
|
|
|
|
i += 1
|