from qqbot import _bot as bot def main(bot): with open('./qq.txt','r') as fr: qqGroup=fr.readline().strip() qqBuddy=fr.readline().strip() qqGroupList=qqGroup.split(',') qqBuddyList=qqBuddy.split(',') return qqBuddyList,qqGroupList if __name__=='__main__': bot.Login(['-q', '3264749998']) #qqBuddyList, qqGroupList = main(bot) #print(type(qqGroupList),qqBuddyList[0],len(qqBuddyList)) fout = open("C:\\Users\\Administrator\\PycharmProjects\\q\\buddyname\\buddy1.txt", 'a') while 1: message = bot.poll() if message[0] == 'group': #如果是群信息的话 #print(message) #根据群号不同写入不同的文件,内容合适为 【用户名】:信息内容 filename = "C:\\Users\\Administrator\\PycharmProjects\\q\\groupname\\" + message[1] + ".txt" f = open(filename,'a',encoding='utf-8') if message[3] == '': pass else: f.write('[' + message[2]+ ']' + ':' + message[3] + '\n') else: if message[3] == '': pass else: fout.write('[' + message[1]+ ']' + ':' + message[3] + '\n')