def update_mailbox(): #this function updates data about recived messages | no arguments, no returns if os.path.isdir("messages"): for file in os.listdir("messages"): os.remove(f"messages/{file}") os.rmdir("messages") if not os.path.isdir("messages"): os.makedirs("messages") with open("cert.json") as f: certificate = json.load(f) client = Vulcan(certificate) for msg in client.get_messages(): teacher = msg.sender content = change_this(msg.content) title = change_this(msg.title) date = str(msg.sent_date) + " " + str(msg.sent_time).replace( ":", ".", 3) try: teacher_name = change_this(teacher.first_name) + " " + change_this( teacher.last_name) except AttributeError: continue path = "messages/" + date + ".txt" file = open(path, "a") try: file.write(f"'{title}'\nOd: {teacher_name}\n{date}\n\n{content}") except UnicodeEncodeError: continue file.close()
def getMessages(certificate): UnreadMessages = [] client = Vulcan(certificate) for message in client.get_messages(): if (str(message.read_date) == 'None'): UnreadMessages.append(message.sender.name) return UnreadMessages