예제 #1
0
async def firsthandle(bot: Bot, event: Event, state: dict):
    p = None
    _id = None
    ls = []
    try:
        ls = str(event.message).strip().split("-")
        _id = ls[0]
        _id = int(_id)
    except:
        await cat.finish("请输入正确格式的pid哦~~")
    try:
        p = ls[1]
        if p != "*":
            p = int(p)
            if p == 0:
                raise Exception
    except IndexError:
        pass
    except:
        await cat.finish("页码不对哦~~页码从0开始。。")
    await cat.send(cq.reply(event.id) + "尝试发送中,。,。,。")
    pics = await catPixiv(bot, _id, p)
    for ind, pic in enumerate(pics):
        if len(pic) > 0 and pic[0] == "h":
            try:
                pic = await getImage(bot.config.session, pic)
            except:
                await cat.send("第 {} 页发送失败了。。但是已经缓存。。尝试重发可能可行!".format(ind))
        await cat.send(pic)
    if len(pics) > 2:
        await cat.finish("发送完毕!")
예제 #2
0
async def _(bot: Bot, event: Event, state: dict):
    msg = str(event.message).strip()
    if msg:
        state["img"] = msg
    q = {"vid": state["vid"], "value": state["img"]}
    parm = {"username": bot.config.username, "password": bot.config.password}

    res = await auth(bot, state, params=q, json=parm)

    await login.send(cq.reply(event.id) + "正确!" if "ok" == res else res)
예제 #3
0
async def _(bot: Bot, event: Event, state: dict):
    if "pic" in state:
        res = await sauce(bot, state["pic"])
        logger.debug(unescape(res))
        await st.send(unescape(res))
        fd = re.search("[0-9]+\.[0-9]*%", res)
        per = float(res[fd.start():fd.end() - 1])
        ther = 70
        if per < ther:
            await st.send("相似度低于 {}% 正在使用 ascii2d 搜索!".format(ther))
            res = await ascii2d(bot, state["pic"])
            await st.finish(res)
    else:
        state["SanityLevel"] = 4
        res, _id = await searchPic(bot, state["keyword"], state["SanityLevel"])
        await st.send(
            (cq.reply(event.id) if event.detail_type != "private" else "") +
            res)
        state["id"] = _id
        if _id == -1:
            await st.finish("暂时没有搜索到关于 {} 的结果哦~~".format(state["keyword"]))
예제 #4
0
async def _(bot: Bot, event: Event, state: dict):
    if "pic" in state:
        pic, res = await sauce(bot, state["pic"])
        try:
            await st.send(unescape(pic + "\n" + res))
        except:
            await st.send("发送失败了。。。尝试不带缩略图的发送!")
            try:
                await st.send(res)
            except:
                await st.send("不带缩略图的也发送失败了。。。尝试使用ascii2d搜索!")
                res = await ascii2d(bot, state["pic"])
                try:
                    await st.send(res)
                except:
                    await st.finish("ascii2d 发送也失败了。。。尝试私聊搜图可能可行!")
                await st.finish()
        fd = re.search("[0-9]+\.[0-9]*%", res)
        per = float(res[fd.start():fd.end() - 1])
        ther = 70
        if per < ther:
            await st.send("相似度低于 {}% 正在使用 ascii2d 搜索!".format(ther))
            res = await ascii2d(bot, state["pic"])
            await st.finish(res)
    else:
        if event.group_id:
            safe = await cksafe(event.group_id)
        else:
            safe = False
        res, _id = await getSetuHigh(bot, not safe, state["keyword"])
        if res == None:
            res, _id = await searchPic(
                bot,
                state["keyword"],
            )
            if _id == -1:
                await st.finish("暂时没有搜索到关于 {} 的结果哦~~".format(state["keyword"]))
        await st.send(
            (cq.reply(event.id) if event.detail_type != "private" else "") +
            res)