Giter VIP home page Giter VIP logo

osu.py's Introduction

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 any unexpected behavior of the client or anything that can happen to your account. If you want to test it out on a custom 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
  • Direct Search
  • Direct Download
  • Multiplayer
  • Documentation

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

osu.py's People

Contributors

dependabot[bot] avatar lekuruu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

kanaarima

osu.py's Issues

Can't connect to akatsuki!

Using server="akatsuki.gg" when initialising game client, I get this:

Error on login: NOT_FOUND
Ignoring...
Login error: AUTHENTICATION_ERROR
Authentication failed. Please check your username/password!
Exiting...

User/password is correct, any idea?

Events seems to not fire after a few reconnects

I'm not sure if this only applies to send message packets (so maybe its not joining channels), after a few disconnects (due to server crashing, no "bancho is restarting" messages), once it succeeds to connect it won't fire send messages event anymore.
Server is akatsuki.gg using a bot account (which is just a regular one basically), osu.py (version 1.1.2) is running under debian 11 and python 3.9.2 (from debian repo)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.