def getMessage(self, email_id): if self.email == None or self.email == '': raise EmailNotSetError() if email_id == None or email_id == '': raise IDNotSetError() resp = self.sess.get(self.mainurl.replace('index', 'email') + 'id/' + str(email_id)).text return resp[1:]
def getMessages(self): if self.email == None or self.email == '': raise EmailNotSetError() resp = self.sess.post(self.mainurl + 'refresh', headers={'X-Requested-With': 'XMLHttpRequest'}).text resp = json.loads(resp[1:]) self.messinfo = [] for info in resp: self.messinfo.append([info['id'], re.findall('<(.*?)>', info['od'])[0], info['predmet']]) #Regex used to get only the email address return [self.messinfo, len(self.messinfo)]
def getMessage(self, email_id): if self.email == None or self.email == '': raise EmailNotSetError() if email_id == None or email_id == '': raise IDNotSetError() resp = self.sess.get(self.mainurl + 'messages/' + email_id).json() if 'error' in resp: return 'ERROR|' + resp['error'] return [resp['html'], resp['text']]
def getMessages(self): if self.email == None or self.email == '': raise EmailNotSetError() resp = self.sess.get(self.mainurl + 'inboxes/' + self.email).json() if 'error' in resp: return 'ERROR|' + resp['error'] self.messinfo = [] for info in resp['msgs']: self.messinfo.append([info['uid'], info['fe'], info['s']]) return [self.messinfo, len(self.messinfo)]
def getMessage(self, email_subj): if self.email == None or self.email == '': raise EmailNotSetError() if email_subj == None or email_subj == '': raise IDNotSetError() retvalue = None for message in self.messcontent: if message[0].replace(' ', '').lower() == email_subj.replace(' ', '').lower(): #Match passed subject with subject in the content-list retvalue = message[1] break return retvalue
def getMessage(self, email_id): #Get message body if self.email == None or self.email == '': raise EmailNotSetError() if email_id == None or email_id == '': raise IDNotSetError() retvalue = None for message in self.messcontent: if message[0] == email_id: retvalue = [message[1], message[2] ] #Return content of the message with specified id break return retvalue
def getMessages(self): if self.email == None or self.email == '': raise EmailNotSetError() resp = self.sess.get(self.mainurl + 'mail.php?unseen=0').text.replace('\n', '').replace(' ', '') #Returns html, must be parsed with regex self.messinfo = [] self.messcontent = [] counter = 0 for info in re.findall('class=\"subject\">(.*?)</div>', resp): self.messinfo.append([info, re.findall('class=\"tmail-email-sender float-left\">(.*?)</div>', resp)[counter]]) self.messcontent.append([info, re.findall('class=\"body\">(.*?)</div>', resp)[counter]]) counter+=1 return [self.messinfo, len(self.messinfo)]
def setEmail(self, email): #Set custom email name if email == None or email == '': raise EmailNotSetError() self.sess = r.Session() self.email = None self.messinfo = [] if '@' in email: email = email.split('@')[0] #Split email by @ and only use the first part resp = self.sess.post(self.mainurl + 'new-email', data={'emailInput': email}, headers={'X-Requested-With': 'XMLHttpRequest'}).text if 'ok' in resp: self.email = email + '@aallaa.org' else: return 'ERROR|' + resp
def setEmail(self, email, domain=None): self.sess = r.Session() self.email = None self.messinfo = [] if email == None or email == '': raise EmailNotSetError() if domain != None and 0 <= domain <= 11: if '@' in email: email = email.split('@')[0] self.email = email + '@' + self.domains[domain] else: if '@' in email: email = email.split('@')[0] self.email = email + '@' + random.choice(self.domains)
def getMessages(self): #Get new messages if self.email == None or self.email == '': raise EmailNotSetError() resp = self.sess.get( self.mainurl.replace('session', 'messages') + 'messagesAfter/0').json() self.messinfo = [] #New messages self.messcontent = [] for info in resp: self.messinfo.append([info['id'], info['sender'], info['subject']]) #Append new message self.messcontent.append( [info['id'], info['bodyPlainText'], info['bodyHtmlContent']]) #Append message id and its content return [self.messinfo, len(self.messinfo)]
def setEmail(self, email): #Set custom email name if self.sid_token == None: return 'ERROR|TOKEN_NOT_SET' if email == None or email == '': raise EmailNotSetError() if '@' in email: email = email.split('@')[ 0] #Split email by @ and only use the first part resp = self.sess.post(self.mainurl, data={ 'f': 'set_email_user', 'sid_token': self.sid_token, 'email_user': email }).json() if 'error' in resp: return 'ERROR|' + resp['error'] self.email = resp['email_addr'] self.sid_token = resp['sid_token']
def getData(self): #Get email data if self.sid_token == None or self.sid_token == '': return 'ERROR|TOKEN_NOT_SET' if self.email == None or self.email == '': raise EmailNotSetError() return [self.email, self.sid_token]
def getData(self): if self.key == None or self.key == '': raise KeyNotSetError() if self.email == None or self.email == '': raise EmailNotSetError() return [self.email, self.key]
def getData(self): if self.email == None or self.email == '': raise EmailNotSetError() return self.email
def getAll(self): if self.email == None or self.email == '': raise EmailNotSetError() return [self.messinfo, len(self.messinfo)]
def resetTime(self): #Add 10 minutes if self.email == None or self.email == '': raise EmailNotSetError() self.sess.get(self.mainurl.replace('index', 'expirace/600'))
def deleteEmail(self): if self.email == None or self.email == '': raise EmailNotSetError() self.sess.get(self.mainurl.replace('index', 'delete'))
def resetTime(self): if self.email == None or self.email == '': raise EmailNotSetError() self.sess.get(self.mainurl + 'reset')