Beispiel #1
0
async def mcv_jira_rss_dungeons(app):
    @scheduler.schedule(every_minute())
    async def bedrock_dungeons():
        url = 'https://bugs.mojang.com/rest/api/2/project/11901/versions'
        try:
            version_file = os.path.abspath(
                './assets/mcversion_jira-dungeons.txt')
            logger_info('Checking Jira mcv-bedrock...')
            verlist = getfileversions(version_file)
            file = await get_data(url, 'json')
            release = []
            for v in file:
                if not v['archived']:
                    release.append(v['name'])
            for x in release:
                if x not in verlist:
                    logger_info(f'huh, we find {x}.')
                    for qqgroup in check_enable_modules_all(
                            'group_permission', 'mcv_jira_rss'):
                        try:
                            await app.sendGroupMessage(
                                int(qqgroup),
                                MessageChain.create([
                                    Plain(
                                        f'Jira已更新Dungeons {x}。\n(Jira上的信息仅作版本号预览用,不代表商店已更新此版本)'
                                    )
                                ]))
                            await asyncio.sleep(0.5)
                        except Exception:
                            traceback.print_exc()
                    for qqfriend in check_enable_modules_all(
                            'friend_permission', 'mcv_jira_rss'):
                        try:
                            await app.sendFriendMessage(
                                int(qqfriend),
                                MessageChain.create([
                                    Plain(
                                        f'Jira已更新Dungeons {x}。\n(Jira上的信息仅作版本号预览用,不代表启动器已更新此版本)'
                                    )
                                ]))
                            await asyncio.sleep(0.5)
                        except Exception:
                            traceback.print_exc()
                    addversion = open(version_file, 'a')
                    addversion.write('\n' + x)
                    addversion.close()
            logger_info('jira mcv-dungeons checked.')
        except Exception:
            traceback.print_exc()
Beispiel #2
0
async def start_check_news(app):
    @scheduler.schedule(every_minute())
    async def check_news():
        logger_info('Checking Minecraft news...')
        baseurl = 'https://www.minecraft.net'
        url = 'https://www.minecraft.net/content/minecraft-net/_jcr_content.articles.grid?tileselection=auto&tagsPath=minecraft:article/news,minecraft:article/insider,minecraft:article/culture,minecraft:article/merch,minecraft:stockholm/news,minecraft:stockholm/guides,minecraft:stockholm/deep-dives,minecraft:stockholm/merch,minecraft:stockholm/events,minecraft:stockholm/minecraft-builds,minecraft:stockholm/marketplace&offset=0&count=500&pageSize=10'
        async with aiohttp.ClientSession() as session:
            async with session.get(url) as resp:
                status = resp.status
                if status == 200:
                    nws = json.loads(await resp.read())['article_grid']
                    for article in nws:
                        default_tile = article['default_tile']
                        title = default_tile['title']
                        image = baseurl + default_tile['image']['imageURL']
                        desc = default_tile['sub_header']
                        link = baseurl + article['article_url']
                        date = article['publish_date']
                        q = database.check_exist(title)
                        if not q:
                            database.add_news(title, link, desc, image, date)
                            articletext = f'Minecraft官网发布了新的文章:\n{title}\n{link}\n{desc}\n'
                            msgchain = MessageChain.create([
                                Plain(articletext),
                                Image.fromNetworkAddress(image)
                            ])
                            for qqgroup in check_enable_modules_all(
                                    'group_permission', 'minecraft_news'):
                                try:
                                    await app.sendGroupMessage(
                                        int(qqgroup), msgchain)
                                    await asyncio.sleep(0.5)
                                except Exception:
                                    traceback.print_exc()
                            for qqfriend in check_enable_modules_all(
                                    'friend_permission', 'minecraft_news'):
                                try:
                                    await app.sendFriendMessage(
                                        int(qqfriend), msgchain)
                                    await asyncio.sleep(0.5)
                                except Exception:
                                    traceback.print_exc()
                            logger_info(articletext)
                    logger_info('Minecraft news checked.')
                else:
                    logger_info('Check minecraft news failed:' + status)
Beispiel #3
0
                                pass
                self.__is_running = False
            else:
                if manual:
                    return MessageItem(
                        MessageChain.create([Plain(text="Github 订阅插件已关闭。")]),
                        QuoteSource())
        except Exception as e:
            logger.error(e)
            self.__is_running = False


gw = GithubWatcher()


@channel.use(SchedulerSchema(timer=timers.every_minute()))
async def github_schedule(app: Ariadne):
    try:
        await gw.github_schedule(app=app, manual=False)
    except:
        pass


twilight = Twilight([
    FullMatch("/github-watch "),
    UnionMatch("disable", "add", "remove", "check", "cache"),
    WildcardMatch()
])


@channel.use(
Beispiel #4
0
async def mcv_rss(app):
    @scheduler.schedule(every_minute())
    async def java_main():
        url = 'http://launchermeta.mojang.com/mc/game/version_manifest.json'
        try:
            version_file = os.path.abspath('./assets/mcversion.txt')
            logger_info('Checking mcv...')
            verlist = getfileversions(version_file)
            file = await get_data(url, 'json')
            release = file['latest']['release']
            snapshot = file['latest']['snapshot']
            if release not in verlist:
                logger_info(f'huh, we find {release}.')
                for qqgroup in check_enable_modules_all(
                        'group_permission', 'mcv_rss'):
                    try:
                        await app.sendGroupMessage(
                            int(qqgroup),
                            MessageChain.create([
                                Plain('启动器已更新' + file['latest']['release'] +
                                      '正式版。')
                            ]))
                        await asyncio.sleep(0.5)
                    except Exception:
                        traceback.print_exc()
                for qqfriend in check_enable_modules_all(
                        'friend_permission', 'mcv_rss'):
                    try:
                        await app.sendFriendMessage(
                            int(qqfriend),
                            MessageChain.create([
                                Plain('启动器已更新' + file['latest']['release'] +
                                      '正式版。')
                            ]))
                        await asyncio.sleep(0.5)
                    except Exception:
                        traceback.print_exc()
                addversion = open(version_file, 'a')
                addversion.write('\n' + release)
                addversion.close()
                verlist = getfileversions(version_file)
            if snapshot not in verlist:
                logger_info(f'huh, we find {snapshot}.')
                for qqgroup in check_enable_modules_all(
                        'group_permission', 'mcv_rss'):
                    try:
                        await app.sendGroupMessage(
                            int(qqgroup),
                            MessageChain.create([
                                Plain('启动器已更新' + file['latest']['snapshot'] +
                                      '快照。')
                            ]))
                        await asyncio.sleep(0.5)
                    except Exception:
                        traceback.print_exc()
                for qqfriend in check_enable_modules_all(
                        'friend_permission', 'mcv_rss'):
                    try:
                        await app.sendFriendMessage(
                            int(qqfriend),
                            MessageChain.create([
                                Plain('启动器已更新' + file['latest']['snapshot'] +
                                      '快照。')
                            ]))
                        await asyncio.sleep(0.5)
                    except Exception:
                        traceback.print_exc()
                addversion = open('./assets/mcversion.txt', 'a')
                addversion.write('\n' + snapshot)
                addversion.close()
            logger_info('mcv checked.')
        except Exception:
            traceback.print_exc()