testing.py now shares Telepy class with TelepyShell
This commit is contained in:
parent
06c90ba9ab
commit
9f7f51a6d0
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
class Chat():
|
class Chat():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
self._users = [] # users in this chatroom
|
||||||
pass
|
def add_user(self, user):
|
||||||
|
self._users += user
|
|
@ -1,6 +1,6 @@
|
||||||
import os, cmd
|
import os, cmd
|
||||||
|
|
||||||
class telepyShell(cmd.Cmd):
|
class TelepyShell(cmd.Cmd):
|
||||||
intro='Welcome to telepy interactive shell. Type help or ? for help.\n'
|
intro='Welcome to telepy interactive shell. Type help or ? for help.\n'
|
||||||
prompt='>'
|
prompt='>'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
|
|
||||||
|
|
||||||
class User():
|
class User():
|
||||||
|
me = None
|
||||||
|
''' current connected user '''
|
||||||
|
|
||||||
|
friends = []
|
||||||
|
''' current connected user's friends '''
|
||||||
|
|
||||||
def __init__(self, uid):
|
def __init__(self, uid):
|
||||||
self.uid = uid
|
self.uid = uid
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#CLI like interface
|
#CLI like interface
|
||||||
|
|
||||||
import argparse, getopt, os, io, struct, mtproto
|
import argparse, getopt, os, io, struct, mtproto
|
||||||
from classes.shell import telepyShell
|
from classes.shell import TelepyShell
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser('telepy',description='Python implementation of telegram API.')
|
parser = argparse.ArgumentParser('telepy',description='Python implementation of telegram API.')
|
||||||
|
@ -14,4 +14,4 @@ if __name__ == '__main__':
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.command is None:
|
if args.command is None:
|
||||||
telepyShell().cmdloop()
|
TelepyShell().cmdloop()
|
27
testing.py
27
testing.py
|
@ -1,25 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
from classes.telepy import Telepy
|
||||||
import io
|
|
||||||
import struct
|
|
||||||
# Deal with py2 and py3 differences
|
|
||||||
try: # this only works in py2.7
|
|
||||||
import configparser
|
|
||||||
except ImportError:
|
|
||||||
import ConfigParser as configparser
|
|
||||||
import mtproto
|
|
||||||
|
|
||||||
|
telepy = Telepy()
|
||||||
|
|
||||||
|
# telepy._config #it's 'private' but can be accessed. Python's intelligent-programmer way. lol. Besides, we're in testing.py!
|
||||||
config = configparser.ConfigParser()
|
# telepy._session
|
||||||
# Check if credentials is correctly loaded (when it doesn't read anything it returns [])
|
# telepy._salt
|
||||||
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')
|
|
||||||
|
|
||||||
Session = mtproto.Session(ip, port)
|
|
||||||
Session.create_auth_key()
|
|
||||||
|
|
||||||
future_salts = Session.method_call('get_future_salts', num=3)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user