Skip to main content

A python library that emulates the osu! stable client

Project description

osu.py

Python 3.9+ License

osu.py is a python library that emulates part of the online functionality of the osu! stable client.

IMPORTANT: Use this library at your own risk! I am not responsible for anything that can happen to your account. If you want to test it out on a private server, you can set the server attribute when initializing the client.

You can install this package with pip:

pip install osu

Or build it manually:

git clone https://github.com/Lekuruu/osu.py.git
cd osu.py
pip install setuptools
python setup.py install

Features

  • Receiving player stats
  • Sending/Receiving chat messages
  • Spectating
  • Avatars
  • Comments
  • Replays
  • Scores/Leaderboards
  • Tournament client behaviour
  • osu!direct
  • Documentation
  • Multiplayer

Example

Here is a small example of how to use this package:

from osu.bancho.constants import ServerPackets
from osu.objects import Player
from osu import Game
import logging

# Enable extended logging
logging.basicConfig(
    level=logging.INFO,
    format='[%(asctime)s] - <%(name)s> %(levelname)s: %(message)s'
)

# Initialize the game class
game = Game(
  USERNAME,
  PASSWORD
)

# Simple message handler
@game.events.register(ServerPackets.SEND_MESSAGE)
def on_message(sender: Player, message: str, target: Player):
  if message.startswith('!ping'):
    sender.send_message('pong!')

# Run the game
game.run()

You can also run tasks, independent of server actions:

# Example of a task, running every minute
@game.tasks.register(minutes=1, loop=True)
def example_task():
  ...

You can also run this project with asyncio:

pip install asyncio
import asyncio

game = Game(
  USERNAME,
  PASSWORD
)

# Run the game
asyncio.run(game.run_async())

For a more in-depth example, please view this project.


If you have any questions, feel free to contact me on discord: lekuru

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osu-1.4.7.tar.gz (33.2 kB view hashes)

Uploaded Source

Built Distribution

osu-1.4.7-py3-none-any.whl (39.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page