testing.py now shares Telepy class with TelepyShell

This commit is contained in:
chidea 2015-03-23 03:08:49 +09:00
parent 06c90ba9ab
commit 9f7f51a6d0
5 changed files with 17 additions and 27 deletions

View File

@ -1,5 +1,6 @@
class Chat():
def __init__(self):
pass
pass
self._users = [] # users in this chatroom
def add_user(self, user):
self._users += user

View File

@ -1,6 +1,6 @@
import os, cmd
class telepyShell(cmd.Cmd):
class TelepyShell(cmd.Cmd):
intro='Welcome to telepy interactive shell. Type help or ? for help.\n'
prompt='>'

View File

@ -1,5 +1,11 @@
class User():
me = None
''' current connected user '''
friends = []
''' current connected user's friends '''
def __init__(self, uid):
self.uid = uid

View File

@ -1,7 +1,7 @@
#CLI like interface
import argparse, getopt, os, io, struct, mtproto
from classes.shell import telepyShell
from classes.shell import TelepyShell
if __name__ == '__main__':
parser = argparse.ArgumentParser('telepy',description='Python implementation of telegram API.')
@ -14,4 +14,4 @@ if __name__ == '__main__':
args = parser.parse_args()
if args.command is None:
telepyShell().cmdloop()
TelepyShell().cmdloop()

View File

@ -1,25 +1,8 @@
# -*- coding: utf-8 -*-
import os
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
from classes.telepy import Telepy
telepy = Telepy()
config = configparser.ConfigParser()
# 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')
Session = mtproto.Session(ip, port)
Session.create_auth_key()
future_salts = Session.method_call('get_future_salts', num=3)
# telepy._config #it's 'private' but can be accessed. Python's intelligent-programmer way. lol. Besides, we're in testing.py!
# telepy._session
# telepy._salt