diff --git a/BitBayUpdateWin.zip b/BitBayUpdateWin.zip deleted file mode 100644 index 5a0da54..0000000 Binary files a/BitBayUpdateWin.zip and /dev/null differ diff --git a/BitBayWin.zip b/BitBayWin.zip deleted file mode 100644 index 7fcc640..0000000 Binary files a/BitBayWin.zip and /dev/null differ diff --git a/BitMHalo.py b/BitMHalo.py index 50d4c6f..528d3e2 100644 --- a/BitMHalo.py +++ b/BitMHalo.py @@ -145,6 +145,7 @@ def parse_list_response(line): ch="" path=os.path.join(application_path,"BitTMP.dat") outpath=os.path.join(application_path,"Outbox.dat") + mailpath=os.path.join(application_path,"MailCache.dat") data=[] data.append("0") data.append("0") @@ -161,6 +162,14 @@ def parse_list_response(line): f.flush() os.fsync(f) f.close() + with open(mailpath,'a+') as f: + f.close() + if os.stat(mailpath)[6]==0: + with open(mailpath,'w') as f: + f.write("{}") + f.flush() + os.fsync(f) + f.close() ticker=0 ticker2=22 ticker3=0 @@ -485,6 +494,17 @@ def parse_list_response(line): connection.login(dat['Email Address'], dat['Password']) typ, mailbox_data = connection.list() inbox = [] + try: + with open(mailpath,'r') as f: + mailbox=f.readline() + f.close() + mailbox=ast.literal_eval(mailbox) + if mailbox=="": + float('a') + if dat['Email Address'] not in mailbox: + mailbox[dat['Email Address']]={} + except: + mailbox={str(dat['Email Address']):{}} for line in mailbox_data: try: flags, delimiter, mailbox_name = parse_list_response(line) @@ -515,7 +535,7 @@ def parse_list_response(line): orduid=elem.split("#")[0] mydict2[orduid]=ordnum except: - mydict2[elem]='' + mydict2[elem]='' for msg_id in msg_ids: if 'uids' in dat:#If they ask to skip any messages we do so if msg_id in mydict2: @@ -528,105 +548,121 @@ def parse_list_response(line): continue sys.stderr.write("\n\n"+str(msg_id)+"\n\n") mymessage={} - try: - if systemexit==1:#Attempt a clean exit when possible - systemexit=2 - sys.stderr.write(str("Closing Bitmessage...")) - sys.exit() - sys.stderr.write(str("\n\nFETCHING...\n\n")) - #This is to prevent dropped connections, for now only on fetching - timeresult = False - try:#Let Halo know through RPC we started to download - myrpc.MessageStatus("1","password") - except Exception, e: - pass - @stopit.threading_timeoutable(timeout_param='my_timeout') - def timethis():#If we get dropped, we can time out - global timeresult, typ, msg_data, connection - typ, msg_data = connection.uid('fetch', msg_id, '(RFC822)') #connection.fetch(msg_id, '(RFC822)') - timeresult = True - timethis(my_timeout=600)#10 minutes is very generous - if timeresult==False: - float("A") - try:#Let Halo know through RPC we finished - myrpc.MessageStatus("0","password") - except Exception, e: - pass - sys.stderr.write(str("\n\nFETCHED!!\n\n")) - #readmessages.append(msg_id) - except: - connection.close() - sys.stderr.write(str("FETCH ERROR")) - if systemexit==2: - sys.exit() - continue - body = "" - try: - for part in msg_data: - if isinstance(part, tuple): - msg = email.message_from_string(part[1]) - try: - src = (msg['from'].split('<')[1].split('>')[0]).strip() - except: - src = msg['from'].strip() - try: - src1 = (msg['to'].split('<')[1].split('>')[0]).strip() - except: - src1 = msg['to'].strip() - try: - if msg.is_multipart(): - for msub in msg.get_payload(): - body = msub.get_payload(decode = True).decode(msub.get_content_charset()) - break - else: - body = msg.get_payload(decode = True).decode(msg.get_content_charset()) - except: + if msg_id in mailbox[str(dat['Email Address'])]: + try: + mymessage['toAddress']=mailbox[str(dat['Email Address'])][msg_id]['toAddress'] + mymessage['fromAddress']=mailbox[str(dat['Email Address'])][msg_id]['fromAddress'] + mymessage['body']=mailbox[str(dat['Email Address'])][msg_id]['body'] + mymessage['uid']=mailbox[str(dat['Email Address'])][msg_id]['uid'] + body=mymessage['body'] + except: + body="" + mymessage={} + sys.stderr.write("\n\nMessage reading error!\n\n") + else: + try: + if systemexit==1:#Attempt a clean exit when possible + systemexit=2 + sys.stderr.write(str("Closing Bitmessage...")) + sys.exit() + sys.stderr.write(str("\n\nFETCHING...\n\n")) + #This is to prevent dropped connections, for now only on fetching + timeresult = False + try:#Let Halo know through RPC we started to download + myrpc.MessageStatus("1","password") + except Exception, e: + pass + @stopit.threading_timeoutable(timeout_param='my_timeout') + def timethis():#If we get dropped, we can time out + global timeresult, typ, msg_data, connection + typ, msg_data = connection.uid('fetch', msg_id, '(RFC822)') #connection.fetch(msg_id, '(RFC822)') + timeresult = True + timethis(my_timeout=600)#10 minutes is very generous + if timeresult==False: + float("A") + try:#Let Halo know through RPC we finished + myrpc.MessageStatus("0","password") + except Exception, e: + pass + sys.stderr.write(str("\n\nFETCHED!!\n\n")) + #readmessages.append(msg_id) + except: + connection.close() + sys.stderr.write(str("FETCH ERROR")) + if systemexit==2: + sys.exit() + continue + body = "" + try: + for part in msg_data: + if isinstance(part, tuple): + msg = email.message_from_string(part[1]) + try: + src = (msg['from'].split('<')[1].split('>')[0]).strip() + except: + src = msg['from'].strip() + try: + src1 = (msg['to'].split('<')[1].split('>')[0]).strip() + except: + src1 = msg['to'].strip() try: - body=str(msg.encode('utf8')) + if msg.is_multipart(): + for msub in msg.get_payload(): + body = msub.get_payload(decode = True).decode(msub.get_content_charset()) + break + else: + body = msg.get_payload(decode = True).decode(msg.get_content_charset()) except: - body=str(msg) - except Exception, e: - sys.stderr.write(str("MESSAGE ERROR ")) - sys.stderr.write(str(e)) - mymessage['toAddress']=str(src1) - mymessage['fromAddress']=str(src) - try: - body=str(body.encode('utf8')) - except: - sys.stderr.write(str("Not encoded")) - try: - body = body.split('****')[1].split('****')[0] - except: + try: + body=str(msg.encode('utf8')) + except: + body=str(msg) + except Exception, e: + sys.stderr.write(str("MESSAGE ERROR ")) + sys.stderr.write(str(e)) + mymessage['toAddress']=str(src1) + mymessage['fromAddress']=str(src) try: - if 'You have received a payment of ' not in str(body): - body="" - else: - #I'm hoping email providers will not change this as identifying the full base64 string would be challenging. - #Any added padding gets changed when uploading the base64 image with the pyzmail library, although the bitmap is lossless - body = body.split('\nContent-Disposition: inline\n\n')[1].split('\n--=========')[0] - body="PAY TO EMAIL BASE64 IMAGE:"+body - except:#Okay they changed it we can try something else + body=str(body.encode('utf8')) + except: + sys.stderr.write(str("Not encoded")) + try: + body = body.split('****')[1].split('****')[0] + except: try: - bodymsg = email.message_from_string(str(body)) - x=0 - posx=0 - while x\nContent-Disposition: inline\n\n')[1].split('\n--=========')[0] + body="PAY TO EMAIL BASE64 IMAGE:"+body + except:#Okay they changed it we can try something else + try: + bodymsg = email.message_from_string(str(body)) + x=0 + posx=0 + while x