Пример #1
0
async def main():
    log.info("Initializing client")
    client = tibiapy.Client()
    try:
        log.info("Fetching world list...")
        response = await client.fetch_world_list()
        assert isinstance(response, tibiapy.TibiaResponse)
        assert isinstance(response.data, tibiapy.WorldOverview)
        log.info(f"{len(response.data.worlds)} worlds found.")
        assert isinstance(response.data.record_count, int)
        assert response.data.record_count > 0
        assert isinstance(response.data.record_date, datetime.datetime)

        selected = random.choice(response.data.regular_worlds)
        assert isinstance(selected, tibiapy.WorldEntry)
        log.info(
            f"World {selected.name} selected: {selected.online_count} online | {selected.pvp_type}"
            f" | {selected.location}")
        assert isinstance(selected.pvp_type, tibiapy.PvpType)
        assert isinstance(selected.location, tibiapy.WorldLocation)
        log.info("Fetching world...")
        response = await client.fetch_world(selected.name)
        assert isinstance(response.data, tibiapy.World)

    finally:
        await client.session.close()
Пример #2
0
async def init_client(app):
    app["tibiapy"] = tibiapy.Client(proxy_url='socks5://127.0.0.1:7744')
Пример #3
0
async def init_client(app):
    app["tibiapy"] = tibiapy.Client()