def local_contents2message_chain(contents): msg = [] for item in contents: for typ, cont in item.items(): if typ == "Plain": msg.append(Plain(text=cont)) elif typ == "Image": msg.append(Image.fromBase64(cont)) return msg
async def quote(app: Mirai, group: Group, message: MessageChain, member: Member, source: Source): if message.toString().find("骂我") != -1: txt1 = requests.get(url1) await app.sendGroupMessage( group, [At(member.id), Plain(text=txt1.text)], quoteSource=source) return True if message.toString().find("夸我") != -1: txt2 = requests.get(url2) await app.sendGroupMessage( group, [At(member.id), Plain(text=txt2.text)], quoteSource=source) return True if message.toString().find("tu") != -1: pic = picbase() print(pic) await app.sendGroupMessage(group, [Image.fromBase64(pic)]) return True