BanchoBot

Represents a Bancho IRC connection.

class BanchoBot {}

Constructors

this
this(string username, string password, string host, ushort port)

Prepares a bancho IRC connection with username & password (can be obtained from https://osu.ppy.sh/p/irc)

Destructor

~this
~this()
Undocumented in source.

Members

Functions

clear
void clear()

Clears all logs, called by connect

clearMessageLog
void clearMessageLog()
clearQuitLog
void clearQuitLog()
clearTopicLog
void clearTopicLog()

Clears all backlog & removes all event listeners for the object type.

connect
void connect()

Connects to this.host:this.port (irc.ppy.sh:6667) and authenticates with username & password. Blocks and processes all messages sent by the TCP socket. Recommended to be called in runTask. Cleans up on exit properly and is safe to be called again once returned.

createRoom
OsuRoom createRoom(string title)

Creates a new managed room with a title and returns it. Automatically gets room ID & game ID.

disconnect
void disconnect()

Disconnects & closes the TCP socket.

fetchOldMessageLog
Message[] fetchOldMessageLog(bool delegate(Message) check, bool returnIt)
fetchOldQuitLog
Quit[] fetchOldQuitLog(bool delegate(Quit) check, bool returnIt)
fetchOldTopicLog
TopicChange[] fetchOldTopicLog(bool delegate(TopicChange) check, bool returnIt)

Goes through the backlog and removes and optionally returns all matching objects.

fromUnmanaged
OsuRoom fromUnmanaged(string room, string game)

Joins a room in IRC and creates the room object from it.

preProcessMessage
void preProcessMessage(Message message)

Processes messages meant for mutliplayer rooms to update their state. called by mixin template

processMessage
void processMessage(Message message)

Calls all event subscribers to try to match this object, otherwise replace the oldest element in the backlog with this.

processNumeric
void processNumeric(int num, string line, string relevantPart)
Undocumented in source. Be warned that the author may not have intended to support it.
processQuit
void processQuit(Quit quit)
processTopic
void processTopic(TopicChange change)

Calls all event subscribers to try to match this object, otherwise replace the oldest element in the backlog with this.

sendMessage
void sendMessage(string channel, char[] message)

Sends a message to a username or channel (#channel).

unmanageRoom
void unmanageRoom(OsuRoom room)

internal function to remove a room from the managed rooms list

waitForMessage
Message waitForMessage(bool delegate(Message) check, Duration timeout)

Waits for an event or returns one which is in the backlog already. Removes matching backlog entries.

waitForMessageBunch
Message[] waitForMessageBunch(bool delegate(Message) check, Duration timeout, Duration totalTimeout, Duration inbetweenTimeout)

Waits for multiple messages sent at once and returns them.

waitForQuit
Quit waitForQuit(bool delegate(Quit) check, Duration timeout)
waitForTopic
TopicChange waitForTopic(bool delegate(TopicChange) check, Duration timeout)

Waits for an event or returns one which is in the backlog already. Removes matching backlog entries.

Mixins

__anonymous
mixin Processor!("Message", Message, 256)
Undocumented in source.
__anonymous
mixin Processor!("Quit", Quit, 256)
Undocumented in source.
__anonymous
mixin Processor!("Topic", TopicChange, 8)
Undocumented in source.

Variables

backlogsMessage
Message[256] backlogsMessage;
backlogsQuit
Quit[256] backlogsQuit;
backlogsTopic
TopicChange[8] backlogsTopic;

list of backlog which hasn't been handled by any event subscribers, oldest one will always be replaced on new ones.

client
TCPConnection client;
host
string host;

IRC host to connect to.

onDirectMessage
Event!Message onDirectMessage;

Event emitted on a private message to the bot.

password
string password;

Credentials to use for authentication when connecting.

port
ushort port;

IRC port to use to connect.

processorsMessage
bool delegate(Message)[] processorsMessage;
processorsQuit
bool delegate(Quit)[] processorsQuit;
processorsTopic
bool delegate(TopicChange)[] processorsTopic;

list of event subscribers. Gets removed automatically when called and returns true, otherwise caller has to remove it.

rooms
OsuRoom[] rooms;
username
string username;

Credentials to use for authentication when connecting.

Examples

BanchoBot bot = new BanchoBot("User", "hunter2");
runTask({
  while (true)
  {
    bot.connect();
    logDiagnostic("Got disconnected from bancho...");
    sleep(2.seconds);
  }
});

Meta