def main(argv=None): mobile_no = raw_input(toEcho("手机号:")) passwd = getpass(toEcho("口 令:")) phone = PyFetion(mobile_no, passwd, "TCP", debug="FILE") try: t = progressBar() t.start() #可以在这里选择登录的方式[隐身 在线 忙碌 离开] ret = phone.login(FetionOnline) except PyFetionSupportError, e: printl("手机号未开通飞信") return 1
def login(): '''登录设置''' global mobile_no if len(sys.argv) > 3: print u'参数错误' elif len(sys.argv) == 3: mobile_no = sys.argv[1] passwd = sys.argv[2] else: if len(sys.argv) == 2: mobile_no = sys.argv[1] elif len(sys.argv) == 1: try: confile = open(config_file, 'r') lines = confile.readlines() for line in lines: if line.startswith("#"): continue if line.startswith("tel"): mobile_no = line.split("=")[1][:-1] elif line.startswith("password"): passwd = line.split("=")[1] phone = PyFetion(mobile_no, passwd, "TCP", debug="FILE") return phone except: mobile_no = raw_input(toEcho("手机号:")) passwd = getpass(toEcho("口 令:")) save = raw_input(toEcho("是否保存手机号和密码以便下次自动登录(y/n)?")) if save == 'y': confile = open(config_file, 'w') content = "#该文件由pyfetion生成,请勿随意修改\n" content = content + "tel=" + mobile_no content = content + "\npassword="******"TCP", debug="FILE") return phone