更正了对2009中现有记录的处理 完成一个号码中所有好友记录的批量导入 修正了某条消息超过128字的bug 增加了装QQ在c盘e盘的选择 代码如下: #Encoding:UTF-8 #FileName:QQMsgAssistant.py #Version:0.1 #Date:2009_10_22 #批量导入手机QQ2008聊天记录到2009中,并把2009中现有记录与2008中记录按时间排序 #更正了装C:盘E:盘的选择,解决了某条消息超过128字的BUG。 #如有错误或者建议,请联系:wenwu500@qq.com from os import listdir,makedirs from os.path import isfile from appuifw import query,note from time import mktime def de8(s): return s.decode("UTF-8") def de16(s): return s.decode("UTF-16") def Win(n): n="%x" %n l=len(n) re="" if 0!=l%2 : n="0"+n l+=1 i=0 while i*2<l : re+=chr(eval("0x"+n[i*2:i*2+2])) i+=1 del i,l,n return re global ni,re ni=re=None def patch(): if query(de8("你的手机QQ2008装在C:/盘吗?"),"query") : path08="c:/data/" w=3 else : path08="e:/" w=2 if query(de8("你的QQ2009装在C:/盘吗?"),"query") : path09="c:/system/data/tencent/QQ/" else : path09="e:/system/data/tencent/QQ/" note(de8("请选择你的QQ号码")) note(de8("确定键 进入文件夹/n/n右键 选定"),"error") dir=manager().AskUser(path08,find="dir") if dir and -1!=dir.find("QQ") : dir=dir+"msg//" filespath=[dir+i for i in listdir(dir)] del dir for f in filespath : temp=f.split("//") to=path09+temp[w]+"/"+temp[-1][:-6]+"/msg.info" del temp insert(f,to) del to print "-"*38 print "-"*38 del filespath else : note(de8("选择错误"),"error") del dir,path08,path09,w def buildtime(s): s=de16(s) x="%x" %long(mktime((int("20"+s[:2]),int(s[3:5]),int(s[6:8]),int(s[9:11]),int(s[12:14]),int(s[15:17]),5,290,-1))) t=chr(eval("0x"+x[0:2]))+chr(eval("0x"+x[2:4]))+chr(eval("0x"+x[4:6]))+chr(eval("0x"+x[6:8])) del x return t def insert(fin,fout): f=file(fin) if isfile(fout) : T=file(fout) new=T.read() T.close() try : T=file(fout,"w") except : makedirs(fout[:-8]) T=file(fout,"a") global ni global re if not ni : ni,re=getName(f) f.seek(0) mark2008=f.read(2) blank="/x00"*6 while 1: c=f.read(8) if not c : del c break del c time=f.read(34) f.read(2) name=f.read(32).replace("/x00/x00","") if (ni and re)==name : flag="/x80" else : flag="/x00" data="" i=43006 while 1 : c=f.read(2) i+=2 mark=Win(i) if not c : T.write(mark+buildtime(time)+blank+flag+data+mark) print de16(name),de16(time) print de16(data) del c,name,data,time,i,flag,mark break elif mark2008!=c : data+=c elif mark2008==c : T.write(mark+buildtime(time)+blank+flag+data+mark) print de16(name),de16(time) print de16(data) del c,name,data,time,i,flag,mark break try : T.write(new) del new except : pass T.close() f.close() del f,T,mark2008,blank def getName(f): f.read(46) re=f.read(32).replace("/x00/x00","") return query(de16(re)+de8(" 是你的昵称吗?"),"query"),re class manager: #copy the powlite_fm __module__ = __name__ def __s2d(s, x): res = '' x = x.lower() for i in range(len(x)): ind = s.alphabet.find(x[i]) if (ind == -1): res += '1' else: res += s.numaplhabet[ind] return res def ru(s, x): return x.decode('utf-8') def ur(s, x): return x.encode('utf-8') def __init__(s): import appuifw import os import e32 (s.appuifw, s.os, s.e32,) = (appuifw, os, e32) s.lock = s.e32.Ao_lock() s.curdir = None s.marknum = 0 s.selectfile = [] s.txt = '' s.alphabet = s.ru('abcdefghijklmnopqrstuvwxyz/xd0/xb0/xd0/xb1/xd0/xb2/xd0/xb3/xd0/xb4/xd0/xb5/xd1/x91/xd0/xb6/xd0/xb7/xd0/xb8/xd0/xb9/xd0/xba/xd0/xbb/xd0/xbc/xd0/xbd/xd0/xbe/xd0/xbf/xd1/x80/xd1/x81/xd1/x82/xd1/x83/xd1/x84/xd1/x85/xd1/x86/xd1/x87/xd1/x88/xd1/x89/xd1/x8c/xd1/x8b/xd1/x8a/xd1/x8d/xd1/x8e/xd1/x8f1234567890 ') s.numaplhabet = u'2223334445556667777888999922223333344445555666677778888999912345678900' def AskUser(s, path = None, find = 'file', ext = [], soundmod = False, markmod = False): s.soundmod = soundmod s.markmod = markmod if s.soundmod: import audio import keycapture (s.audio, s.keycapture,) = (audio, keycapture) s.capturer = s.keycapture.KeyCapturer(s.keycap) s.capturer.forwarding = 0 s.capturer.keys = s.keycapture.all_keys s.workitem = s.ru('/xe8/xaf/xb7/xe7/xa8/x8d/xe5/x80/x99...') s.backitem = u'<<<' if ((path == None) and ((s.curdir != None) and (s.curdir != u'root'))): path = s.os.path.split(s.curdir)[0] if