OsuRoom

Represents a multiplayer lobby in osu! Automatically does ratelimiting by not sending more than a message every 2 seconds.

All slot indices are 0 based.

@safe
class OsuRoom {}

Members

Aliases

sendMessage
deprecated alias sendMessage = sendImportantMessage
Undocumented in source.

Functions

abortMatch
bool abortMatch()

Aborts a running match

abortTimer
void abortTimer()

Aborts any running countdown

addRef
bool addRef(string player)

Adds a player as referee (can manage the room with !mp commands), also useful to allow room control to another bot.

addRefs
bool addRefs(string[] players)

Adds players to referees.

bancho
BanchoBot bancho()

Returns the BanchoBot instance used with this room.

channel
string channel()

Returns the channel name as on IRC

clearhost
void clearhost()

Makes nobody host (make it system/bot managed)

close
void close()

Closes the room and calls processClosed.

hasPlayer
bool hasPlayer(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
host
void host(string player)

Gives host to a player

invite
bool invite(string player)

Invites a player to the room

isOpen
bool isOpen()
kick
bool kick(string player)

Kicks a player from the room

listRefs
string[] listRefs()

Lists all match referees. Note that potentially this list might not be complete if a message packet gets lost.

locked
void locked(bool locked)

Property to lock slots (disallow changing slots & joining)

map
bool map(string id)

Changes the map to a beatmap ID (b/ url)

mapAndMode
bool mapAndMode(string id, GameMode mode)

Changes the map to a beatmap ID (b/ url) with gamemode

mods
void mods(Mod[] mods)

Changes the mods in this lobby (pass FreeMod first if you want FreeMod)

mods
void mods(ModNumber mods)

Changes the mods in this lobby with their enum value. Different mods are supported and FreeMod is not supported, but more combinations and other mods can be picked with this.

move
bool move(string player, int slot)

Moves a player to another slot

mpid
string mpid()

Returns the game ID as usable in osu://mp/ID urls

password
void password(string pw)

Sets the match password (password will be visible to existing players)

playerByName
Settings.Player playerByName(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
playerByName
Settings.Player playerByName(string name, size_t index)
Undocumented in source. Be warned that the author may not have intended to support it.
playerSlotByName
deprecated ubyte playerSlotByName(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
playerSlotIndexByName
ubyte playerSlotIndexByName(string name)

Returns the player slot for the given player username or ubyte.max if not found.

processClosed
void processClosed()

Processes a room closed event

processFinishPlaying
void processFinishPlaying(string player, long score, bool pass)

Processes a user finish playing event & updates the state

processHost
void processHost(string user)

Processes a user host event & updates the state

processHostClear
void processHostClear()

Processes a host clear event & updates the state

processJoin
void processJoin(string user, ubyte slot, Team team)

Processes a user join event & updates the state

processLeave
void processLeave(string user)

Processes a user leave event & updates the state

processMatchFinish
void processMatchFinish()

Processes a match end event & updates the state

processMove
void processMove(string user, ubyte slot)

Processes a user move event & updates the state

processSize
void processSize(ubyte numSlots)

Processes a room size change event & updates the state

processTeam
void processTeam(string user, Team team)

Processes a user team switch event & updates the state

ratelimit
void ratelimit(bool put)
ratelimitNothrow
bool ratelimitNothrow(bool put)

Manually wait until you can send a message again.

removeRef
bool removeRef(string player)

Removes a player from referees.

removeRefs
bool removeRefs(string[] players)

Removes players from referees.

repeatUntilResponded
void repeatUntilResponded(Callback cb, Duration idleTimeout, size_t retries)

Repeats the callback parameter until it doesn't throw NoServerResponseException or the room is closed.

repeatUntilRespondedOrFatalExit
void repeatUntilRespondedOrFatalExit(Callback cb, Duration idleTimeout, size_t retries, string file, size_t line)

Same as repeatUntilResponded but exits with an AssertError if the exception is anything else than NoServerResponseException or InterruptException.

room
string room()

Returns the room ID as usable in the mp history URL or IRC joinable via #mp_ID

sendImportantMessage
void sendImportantMessage(const(char)[] message)

Sends a message with a 2 second ratelimit

sendMessageForce
auto sendMessageForce(const(char)[] message)
Undocumented in source. Be warned that the author may not have intended to support it.
set
void set(TeamMode teammode, ScoreMode scoremode, ubyte size)

Sets up teammode, scoremode & lobby size

setTeam
bool setTeam(string user, Team team)

Changes a user's team

setTimer
void setTimer(Duration d)

Sets a timer using !mp timer

settings
Settings settings()

Returns the current mp settings

size
void size(ubyte slots)

Changes the slot limit of this lobby

slot
Settings.Player slot(int index)

Use slotsi for a nothrow overload

start
bool start(Duration after)

Starts a match after a specified amount of seconds. If after is <= 0 the game will be started immediately. The timeout can be canceled using abortTimer.

tryAbortTimer
bool tryAbortTimer()

Aborts any running countdown

tryListRefs
string[] tryListRefs()

Lists all match referees. Note that potentially this list might not be complete if a message packet gets lost.

trySendMessage
bool trySendMessage(const(char)[] message)

Sends a message with a 2 second ratelimit

trySetTimer
bool trySetTimer(Duration d)

Sets a timer using !mp timer

tryWaitForJoin
string tryWaitForJoin(Duration timeout)

Waits for a player to join the room & return the username or null if nobody joined within the timeout.

tryWaitForTimer
bool tryWaitForTimer(Duration timeout)

Waits for an existing timer/countdown to finish (wont start one)

waitForJoin
string waitForJoin(Duration timeout)

Waits for a player to join the room & return the username

waitForTimer
void waitForTimer(Duration timeout)

Waits for an existing timer/countdown to finish (wont start one)

Structs

Settings
struct Settings

Returned by !mp settings

Variables

inProgress
bool inProgress;
Undocumented in source.
onBeatmapChanged
NothrowEvent!BeatmapInfo onBeatmapChanged;

Host changed map

onBeatmapPending
NothrowEvent!() onBeatmapPending;

Host is changing beatmap

onClosed
NothrowEvent!() onClosed;

The room has been closed

onCountdownAborted
NothrowEvent!() onCountdownAborted;

A countdown was aborted

onCountdownFinished
NothrowEvent!() onCountdownFinished;

A timer finished

onHostCleared
NothrowEvent!() onHostCleared;
onMatchAborted
NothrowEvent!() onMatchAborted;

The match was started but now aborted

onMatchEnd
NothrowEvent!() onMatchEnd;

Match has ended (all players finished)

onMatchStart
NothrowEvent!() onMatchStart;

Match has started

onMessage
NothrowEvent!Message onMessage;

A message by anyone has been sent

onPlayerFinished
NothrowEvent!(string, long, bool) onPlayerFinished;

A user finished playing. username + score + passed

onPlayersReady
NothrowEvent!() onPlayersReady;

emitted when all players are ready

onUserHost
NothrowEvent!string onUserHost;

username as argument

onUserJoin
NothrowEvent!(string, ubyte, Team) onUserJoin;

username + slot (0 based) + team as argument

onUserLeave
NothrowEvent!string onUserLeave;

username as argument

onUserMove
NothrowEvent!(string, ubyte) onUserMove;

username + slot (0 based) as argument

onUserTeamChange
NothrowEvent!(string, Team) onUserTeamChange;

username & team as argument

slots
Settings.Player[16] slots;

Automatically managed state of player slots, empty slots are Player.init

timerIsStart
bool timerIsStart;
Undocumented in source.
timerRunning
bool timerRunning;
Undocumented in source.

Meta