Exemplo n.º 1
0
def receive_group_msg(ctx: GroupMsg):
    at_data = gp.at(ctx, clean=False)
    if at_data is None:
        return
    if "rua" in at_data.Content.strip():
        user = at_data.UserExt[0].QQUid
        content = httpx.get(f"http://q1.qlogo.cn/g?b=qq&nk={user}&s=160",
                            timeout=20).content
        avatar = Image.open(BytesIO(content))
        Picture(pic_base64=generate_gif(str(frame_dir), avatar))
Exemplo n.º 2
0
def receive_group_msg(ctx: GroupMsg):
    if "撕" not in ctx.Content:
        return
    if ctx.MsgType == MsgTypes.PicMsg:
        pic = gp.pic(ctx)
        if not pic:
            return
        user = pic.GroupPic[0].Url
    elif ctx.MsgType == MsgTypes.AtMsg:
        at = gp.at(ctx)
        if not at:
            return
        user = at.UserExt[0].QQUid
    else:
        return

    S.bind(ctx).image(rip(user))
Exemplo n.º 3
0
def receive_group_msg(ctx: GroupMsg):
    o = t = None

    if ctx.MsgType == "PicMsg":
        pic = gp.pic(ctx)
        if not pic:
            return
        if not "kiss" in pic.Content:
            return
        # 2 张图
        if len(pic.GroupPic) >= 2:
            o, t = pic.GroupPic[0].Url, pic.GroupPic[1].Url
        # 1张图,没有at就是发送人
        else:
            t = pic.GroupPic[0].Url
            # 有at
            if pic.UserExt:
                o = pic.UserExt[0].QQUid
            # 无 at
            else:
                o = ctx.FromUserId
        if "kissR" in pic.Content:
            o, t = t, o
    elif ctx.MsgType == "AtMsg":
        at = gp.at(ctx)
        if not at:
            return
        if not "kiss" in at.Content:
            return
        # at 两个人
        if len(at.UserID) >= 2:
            o, t = at.UserID[:2]
        else:
            # at 一个人
            o = ctx.FromUserId
            t = at.UserID[0]

        if "kissR" in at.Content:
            o, t = t, o

    if o and t:
        S.bind(ctx).image(kiss(o, t))
Exemplo n.º 4
0
def receive_group_msg(ctx: GroupMsg):

    at_data = gp.at(ctx)
    if at_data:
        user = at_data.UserID[0]
    else:
        user = ctx.FromUserId

    avatar = get_avator(user)
    if not avatar:
        return

    if avatar.mode != "RGBA":
        avatar = avatar.convert("RGBA")
    avatar_width, avatar_height = avatar.size

    try:
        num = int(ctx._match.group(1))
    except Exception:
        num = random.randint(1, 6)

    if num < 0:
        S.text("sb")
        return
    if num > 119:
        S.text("强子过多, 呼叫119吧")
        return

    小强们 = [来只小强() for _ in range(num)]
    for 一只小强 in 小强们:
        x_offset, y_offset = int(一只小强.width * 0.3), int(一只小强.height * 0.3)
        x, y = random.randint(1, avatar_width - x_offset), random.randint(
            1, avatar_height - y_offset
        )
        avatar.paste(一只小强, (x, y), 一只小强)

    buf = BytesIO()
    avatar.save(buf, "png")
    S.image(buf)
    avatar.close()
Exemplo n.º 5
0
def receive_group_msg(ctx: GroupMsg):
    data = gp.at(ctx)
    if data is not None:
        if "nb" in data.Content:
            Text(get_niubi(data.UserExt[0].QQNick))