我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用itchat.login()。
def __init__(self): ''' init is the only method defined in core.py alive is value showing whether core is running - you should call logout method to change it - after logout, a core object can login again storageClass only uses basic python types - so for advanced uses, inherit it yourself receivingRetryCount is for receiving loop retry - it's 5 now, but actually even 1 is enough - failing is failing ''' self.alive = False self.storageClass = storage.Storage() self.memberList = self.storageClass.memberList self.mpList = self.storageClass.mpList self.chatroomList = self.storageClass.chatroomList self.msgList = self.storageClass.msgList self.loginInfo = {} self.s = requests.Session() self.uuid = None self.functionDict = {'FriendChat': {}, 'GroupChat': {}, 'MpChat': {}} self.useHotReload, self.hotReloadDir = False, 'itchat.pkl' self.receivingRetryCount = 5
def check_login(self, uuid=None): ''' check login status for options: - uuid: if uuid is not set, latest uuid you fetched will be used for return values: - a string will be returned - for meaning of return values - 200: log in successfully - 201: waiting for press confirm - 408: uuid timed out - 0 : unknown error for processing: - syncUrl and fileUrl is set - BaseRequest is set blocks until reaches any of above status it is defined in components/login.py ''' raise NotImplementedError()
def __init__(self): ''' init is the only method defined in core.py alive is value showing whether core is running - you should call logout method to change it - after logout, a core object can login again storageClass only uses basic python types - so for advanced uses, inherit it yourself receivingRetryCount is for receiving loop retry - it's 5 now, but actually even 1 is enough - failing is failing ''' self.alive, self.isLogging = False, False self.storageClass = storage.Storage(self) self.memberList = self.storageClass.memberList self.mpList = self.storageClass.mpList self.chatroomList = self.storageClass.chatroomList self.msgList = self.storageClass.msgList self.loginInfo = {} self.s = requests.Session() self.uuid = None self.functionDict = {'FriendChat': {}, 'GroupChat': {}, 'MpChat': {}} self.useHotReload, self.hotReloadDir = False, 'itchat.pkl' self.receivingRetryCount = 5
def __init__(self): ''' init is the only method defined in core.py alive is value showing whether core is running - you should call logout method to change it - after logout, a core object can login again storageClass only uses basic python types - so for advanced uses, inherit it yourself receivingRetryCount is for receiving loop retry - it's 5 now, but actually even 1 is enough - failing is failing ''' self.alive, self.isLogging = False, False self.storageClass = storage.Storage() self.memberList = self.storageClass.memberList self.mpList = self.storageClass.mpList self.chatroomList = self.storageClass.chatroomList self.msgList = self.storageClass.msgList self.loginInfo = {} self.s = requests.Session() self.uuid = None self.functionDict = {'FriendChat': {}, 'GroupChat': {}, 'MpChat': {}} self.useHotReload, self.hotReloadDir = False, 'itchat.pkl' self.receivingRetryCount = 5
def login(self, enableCmdQR=False, picDir=None, qrCallback=None, loginCallback=None, exitCallback=None): ''' log in like web wechat does for log in - a QR code will be downloaded and opened - then scanning status is logged, it paused for you confirm - finally it logged in and show your nickName for options - enableCmdQR: show qrcode in command line - integers can be used to fit strange char length - picDir: place for storing qrcode - qrCallback: method that should accept uuid, status, qrcode - loginCallback: callback after successfully logged in - if not set, screen is cleared and qrcode is deleted - exitCallback: callback after logged out - it contains calling of logout for usage ..code::python import itchat itchat.login() it is defined in components/login.py and of course every single move in login can be called outside - you may scan source code to see how - and modified according to your own demond ''' raise NotImplementedError()
def get_QRuuid(self): ''' get uuid for qrcode uuid is the symbol of qrcode - for logging in, you need to get a uuid first - for downloading qrcode, you need to pass uuid to it - for checking login status, uuid is also required if uuid has timed out, just get another it is defined in components/login.py ''' raise NotImplementedError()
def get_QR(self, uuid=None, enableCmdQR=False, picDir=None, qrCallback=None): ''' download and show qrcode for options - uuid: if uuid is not set, latest uuid you fetched will be used - enableCmdQR: show qrcode in cmd - picDir: where to store qrcode - qrCallback: method that should accept uuid, status, qrcode it is defined in components/login.py ''' raise NotImplementedError()
def show_mobile_login(self): ''' show web wechat login sign the sign is on the top of mobile phone wechat sign will be added after sometime even without calling this function it is defined in components/login.py ''' raise NotImplementedError()
def start_receiving(self, exitCallback=None, getReceivingFnOnly=False): ''' open a thread for heart loop and receiving messages for options: - exitCallback: callback after logged out - it contains calling of logout - getReceivingFnOnly: if True thread will not be created and started. Instead, receive fn will be returned. for processing: - messages: msgs are formatted and passed on to registered fns - contact : chatrooms are updated when related info is received it is defined in components/login.py ''' raise NotImplementedError()
def get_msg(self): ''' fetch messages for fetching - method blocks for sometime util - new messages are to be received - or anytime they like - synckey is updated with returned synccheckkey it is defined in components/login.py ''' raise NotImplementedError()
def logout(self): ''' logout if core is now alive logout will tell wechat backstage to logout and core gets ready for another login it is defined in components/login.py ''' raise NotImplementedError()
def dump_login_status(self, fileDir=None): ''' dump login status to a specific file for option - fileDir: dir for dumping login status it is defined in components/hotreload.py ''' raise NotImplementedError()
def auto_login(self, hotReload=False, statusStorageDir='itchat.pkl', enableCmdQR=False, picDir=None, qrCallback=None, loginCallback=None, exitCallback=None): ''' log in like web wechat does for log in - a QR code will be downloaded and opened - then scanning status is logged, it paused for you confirm - finally it logged in and show your nickName for options - hotReload: enable hot reload - statusStorageDir: dir for storing log in status - enableCmdQR: show qrcode in command line - integers can be used to fit strange char length - picDir: place for storing qrcode - loginCallback: callback after successfully logged in - if not set, screen is cleared and qrcode is deleted - exitCallback: callback after logged out - it contains calling of logout - qrCallback: method that should accept uuid, status, qrcode for usage ..code::python import itchat itchat.auto_login() it is defined in components/register.py and of course every single move in login can be called outside - you may scan source code to see how - and modified according to your own demond ''' raise NotImplementedError()
def login(self, enableCmdQR=False, picDir=None, qrCallback=None, loginCallback=None, exitCallback=None): ''' log in like web wechat does for log in - a QR code will be downloaded and opened - then scanning status is logged, it paused for you confirm - finally it logged in and show your nickName for options - enableCmdQR: show qrcode in command line - integers can be used to fit strange char length - picDir: place for storing qrcode - qrCallback: method that should accept uuid, status, qrcode - loginCallback: callback after successfully logged in - if not set, screen is cleared and qrcode is deleted - exitCallback: callback after logged out - it contains calling of logout for usage ..code::python import itchat itchat.login() it is defined in components/login.py and of course every single move in login can be called outside - you may scan source code to see how - and modified according to your own demand ''' raise NotImplementedError()