Exemple #1
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    global ban_temp_list
    msg = str(event.message)
    user = str(event.user_id)

    # 检查是否满足条件
    if countX(ban_temp_list,
              user) == Textcheck().get_times(str(Textcheck().check(msg))):
        ban_temp_list = list(set(ban_temp_list))
        ban(user)

        delta = timedelta(minutes=Textcheck().get_ban_time(msg))
        trigger = DateTrigger(run_date=datetime.now() + delta)
        scheduler.add_job(func=unban,
                          trigger=trigger,
                          args=(user, ),
                          misfire_grace_time=60)

        await publicOpinion.finish(Textcheck().check(msg))

    if Textcheck().check(msg) == "False":
        return

    if Textcheck().check(msg):
        if user in master:
            await publicOpinion.finish("主人你给我注意点阿?!你这可是在死亡边缘试探呢!!")

        ban_temp_list.append(int(user))

        await publicOpinion.finish(Textcheck().check(msg))
Exemple #2
0
 def enable_cache(self) -> None:
     """开启定时缓存任务"""
     self._cache_job = scheduler.add_job(
         self.cache_data,
         "cron",
         hour=plugin_config.fflogs_cache_hour,
         minute=plugin_config.fflogs_cache_minute,
         second=plugin_config.fflogs_cache_second,
         id="fflogs_cache",
     )
     plugin_config.fflogs_enable_cache = True
     logger.info(
         f"开启定时缓存,执行时间为每天 {plugin_config.fflogs_cache_hour}:{plugin_config.fflogs_cache_minute}:{plugin_config.fflogs_cache_second}"
     )
Exemple #3
0
    print(event)
    if event:
        await bot.send(event, message=Message(f"[CQ:at,qq={account_json['admin']}]\n{reply}"))
    elif reply:
        await bot.send_group_msg(
            group_id=account_json["group_id"], message=Message(f"[CQ:at,qq={account_json['admin']}]\n{reply}")
        )
        # await bot.send_group_msg(group_id=618773789, message=f"[CQ:at,qq={account_json['admin']}]\n{reply}")
    await invite_auto()
    return remind_list


on_command("equip check", handlers=[check])


scheduler.add_job(check, "interval", hours=1)


async def invite_auto(ev: Event = {}):
    bot = get_bots()[config.bot_id]
    msg = ""
    with open(os.path.join(plugin_path, "account.json")) as fp:
        config_json = json.load(fp)
    white_list = config_json["white_list"]
    while client.shouldLogin:
        await client.login()
    if os.path.exists(plugin_path + "/data.json"):
        with open(plugin_path + "/data.json", "rb") as f:
            data_save = json.loads(f.read())
    else:
        data_save = ""
Exemple #4
0
    for dynamic in dynamics[4::-1]:  # 从旧到新取最近5条动态
        dynamic = Dynamic(dynamic)
        if (dynamic.time > last_time[uid] and dynamic.time >
                datetime.now().timestamp() - timedelta(minutes=10).seconds):
            msg = await dynamic.format_msg()
            if msg:
                await send_dynamic_msg(uid, msg)
            last_time[uid] = dynamic.time


async def dynamic_monitor():
    uids = get_sub_uids()
    for uid in uids:
        await check_dynamic(uid)


blive_config = Config.parse_obj(get_driver().config.dict())
dynamic_cron = blive_config.bilibili_dynamic_cron

scheduler.add_job(
    dynamic_monitor,
    "cron",
    second=dynamic_cron[0],
    minute=dynamic_cron[1],
    hour=dynamic_cron[2],
    day=dynamic_cron[3],
    month=dynamic_cron[4],
    year=dynamic_cron[5],
    id="bilibili_dynamic_cron",
)
Exemple #5
0
async def mimikko_sign_in_auto():
    bot = get_bots()[config.bot_id]
    sign_data, energy_info_data, energy_reward_data, sign_info, sign_history = mimikko(app_id, authorization)
    res = "Sign Data:\n"
    res += f"获得成长值Reward:{sign_data['body']['Reward']}\n"
    res += f"获得硬币GetCoin:{sign_data['body']['GetCoin']}\n"
    if sign_data["code"] == "0":
        res += f"[CQ:image,file=file:///{drawSigncard(sign_data)}]\n"
    res += "================\nSign History:\n"
    day_list = []
    for item in sign_history["body"]["signLogs"]:
        rex_data = re.search("(?P<月>.*)月(?P<日>.*)日", timeStamp2time(item["signDate"]))
        if rex_data.group("月") == re.search(
            "(?P<月>.*)月(?P<日>.*)日", timeStamp2time(sign_history["body"]["startTime"])
        ).group("月"):
            day_list.append(rex_data.group("日"))
    img_path = drawMonth(datetime.datetime.now().month, day_list, plugin_path)
    res += f"[CQ:image,file=file:///{plugin_path}/{img_path}]"
    await bot.send_group_msg(group_id=group_id, message=Message(res))


# 1. mimikko sign: 梦梦奈签到
# 2. mimikko energy: 领取能量值
# 3. mimikko check: 检查签到状态
# 4. 自动签到任务
mimikko_com = CommandGroup("mimikko")
bots = mimikko_com.command("sign", handlers=[mimikko_sign])
matchers = mimikko_com.command("energy", handlers=[mimikko_energy])
event = mimikko_com.command("check", handlers=[mimikko_check])
scheduler.add_job(mimikko_sign_in_auto, "cron", hour="12")
Exemple #6
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    global SP_temp_list
    user = event.user_id
    group = event.group_id
    res = randint(1, 5)

    check_sepi()

    if countX(SP_temp_list, user) == 5:
        add_sepi(user)  # type: ignore
        SP_temp_list = list(set(SP_temp_list))
        delta = timedelta(hours=1)
        trigger = DateTrigger(run_date=datetime.now() + delta)
        scheduler.add_job(func=del_sepi,
                          trigger=trigger,
                          args=(user, ),
                          misfire_grace_time=60)
        return

    if setu_type == 1:

        DATA_PATH = Path(
            '.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / 'nearR18.db'

        if not DATA_PATH.is_file():
            await setu.finish("数据库...她是空的!!!")

        con = sqlite3.connect(DATA_PATH)
        cur = con.cursor()
        msg = cur.execute('SELECT * FROM nearR18 ORDER BY RANDOM() limit 1;')

        for i in msg:
            pid = i[0]
            title = i[1]
            img = i[7]

            msg0 = "setu info:\n"
            msg0 += f"Title: {title}\n"
            msg0 += f"Pid: {pid}\n"
            msg0 += f"[CQ:image,file=file:///{compress_image(await aio_download_pics(img))}]"

            if 1 <= res < 5:
                SP_temp_list.append(user)
                await setu.finish(msg0)

            elif res == 5:
                await bot.send(event, "我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆")

                for sup in config['bot']['superusers']:
                    await bot.send_private_msg(
                        user_id=sup,
                        message=
                        f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n[CQ:image,file=file:///{compress_image(await aio_download_pics(img))}]"
                    )

    else:
        params = {"apikey": key_LoliconAPI, "r18": "0", "num": "1"}

        data = {}

        try:
            data = json.loads(
                request_get('https://api.lolicon.app/setu/', params))
        except Exception:
            await setu.finish(errorRepo("请求数据失败,也可能为接口调用次数达上限"))

        msg0 = "setu info:\n"
        msg0 += f'Title: {data["data"][0]["title"]}\n'
        msg0 += f'Pid: {data["data"][0]["pid"]}\n'
        msg0 += f'[CQ:image,file=file:///{compress_image(await aio_download_pics(data["data"][0]["url"]))}]'

        if 1 <= res < 5:
            SP_temp_list.append(user)
            await setu.finish(msg0)

        elif res == 5:
            await bot.send(event, "我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆")

            for sup in config['bot']['superusers']:
                await bot.send_private_msg(
                    user_id=sup,
                    message=
                    f'主人,从群{group}来的涩图!热乎着!\nTitle: {data["data"][0]["title"]}\nPid: {data["data"][0]["pid"]}\n[CQ:image,file=file:///{compress_image(await aio_download_pics(data["data"][0]["url"]))}]'
                )
Exemple #7
0
    for user_id in user_ids:
        user_rss_list = get_rss_list(user_id)
        for rss in user_rss_list:
            entries = await update_rss(rss)
            for entry in entries:
                msg = await rss_to_msg(rss, entry)
                if not msg:
                    continue
                type, id = user_type(user_id)
                if type == "group":
                    await bot.send_group_msg(group_id=int(id), message=msg)
                elif type == "private":
                    await bot.send_private_msg(user_id=int(id), message=msg)
    dump_rss_list()


rss_cron = rss_config.rss_update_cron
scheduler.add_job(
    rss_monitor,
    "cron",
    second=rss_cron[0],
    minute=rss_cron[1],
    hour=rss_cron[2],
    day=rss_cron[3],
    month=rss_cron[4],
    year=rss_cron[5],
    id="rss_monitor",
    coalesce=True,
    misfire_grace_time=30,
)
Exemple #8
0
        if recorder.count < 30:
            continue
        else:
            recorder.count = 0
        msgs = []
        for chat in recorder.chats:
            name = chat["playerName"]
            name = etree.HTML(name,
                              etree.HTMLParser()).xpath("string(.)").strip()
            message = chat["message"]
            msgs.append(f"[dynmap] {name}: {message}")
        recorder.chats = []
        if msgs:
            msg = "\n".join(msgs)
            await send_bot_msg(user_id, msg)


dynmap_cron = mc_config.dynmap_cron
scheduler.add_job(
    dynmap_monitor,
    "cron",
    second=dynmap_cron[0],
    minute=dynmap_cron[1],
    hour=dynmap_cron[2],
    day=dynmap_cron[3],
    month=dynmap_cron[4],
    year=dynmap_cron[5],
    id="dynmap_monitor",
    coalesce=True,
)
Exemple #9
0
                auth_info = group_auth.get_auth_info(item)
                rest_day = cal_day(timeStamp2time(int(auth_info["auth_time"])),
                                   timeStamp2time(time.time())).days
                if rest_day <= 5:
                    if rest_day < 0:
                        msg += "Nia~ 还有人记得猫猫吗?猫猫不要和コッコロちゃん一样!"
                    elif rest_day <= 5:
                        msg += leave_msg[str(rest_day)]
                    msg += f"\n猫猫还会陪伴大家{cal_day(timeStamp2time(int(auth_info['auth_time'])),timeStamp2time(time.time())).days}天"
                    print(group_id, msg)
                    await bot.send_group_msg(group_id=group_id, message=msg)
            else:
                print(f"add new group_info: {item}")
                new_group_info = {
                    item: {
                        "name": GROUP_LIST[item],
                        "join_time": str(int(time.time())),
                        "auth_time": str(int(time.time()) + 7 * 24 * 3600),
                    }
                }
                print(new_group_info)
                group_auth.add_new_group(item, new_group_info)
    except Exception as e:
        await bot.send_group_msg(group_id="426770092",
                                 message=f"zfjbot-auth:{e}")


scheduler.add_job(check_auth, "cron", hour=18)
# test
# scheduler.add_job(check_auth, "interval", seconds=20)
Exemple #10
0
    bot_list = list(nonebot.get_bots().values())
    bot = bot_list[0] if bot_list else None
    to_send = await platform_manager[target_type].fetch_new_post(
        target, send_userinfo_list
    )
    for user, send_list in to_send:
        for send_post in send_list:
            logger.info("send to {}: {}".format(user, send_post))
            if not bot:
                logger.warning("no bot connected")
            else:
                await send_msgs(
                    bot, user.user, user.user_type, await send_post.generate_messages()
                )


for platform_name, platform in platform_manager.items():
    if platform.schedule_type in ["cron", "interval", "date"]:
        logger.info(
            f"start scheduler for {platform_name} with {platform.schedule_type} {platform.schedule_kw}"
        )
        scheduler.add_job(
            fetch_and_send,
            platform.schedule_type,
            **platform.schedule_kw,
            args=(platform_name,),
        )

if plugin_config.bison_use_queue:
    scheduler.add_job(do_send_msgs, "interval", seconds=0.3, coalesce=True)