mirror of
https://github.com/deavmi/birchwood
synced 2024-09-20 15:22:53 +02:00
Merge branch 'master' into rfc2812
This commit is contained in:
commit
a0acaccdec
@ -71,23 +71,19 @@ public class Client : Thread
|
|||||||
//TODO: Do something here, tare downs
|
//TODO: Do something here, tare downs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Investigate
|
||||||
public ConnectionInfo getConnInfo()
|
public ConnectionInfo getConnInfo()
|
||||||
{
|
{
|
||||||
return connInfo;
|
return connInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User overridable handler functions below
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: comment
|
|
||||||
/**
|
/**
|
||||||
|
* Called on reception of a channel message
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* fullMessage =
|
* fullMessage = the channel message in its entirety
|
||||||
* channel =
|
* channel = the channel
|
||||||
* msgBody =
|
* msgBody = the body of the message
|
||||||
*/
|
*/
|
||||||
public void onChannelMessage(Message fullMessage, string channel, string msgBody)
|
public void onChannelMessage(Message fullMessage, string channel, string msgBody)
|
||||||
{
|
{
|
||||||
@ -95,14 +91,13 @@ public class Client : Thread
|
|||||||
logger.log("Channel("~channel~"): "~msgBody);
|
logger.log("Channel("~channel~"): "~msgBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: comment
|
|
||||||
/**
|
/**
|
||||||
|
* Called on reception of a direct message
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* fullMessage =
|
* fullMessage = the direct message in its entirety
|
||||||
* nickname =
|
* nickname = the sender
|
||||||
* msgBody =
|
* msgBody = the body of the message
|
||||||
* message =
|
|
||||||
*/
|
*/
|
||||||
public void onDirectMessage(Message fullMessage, string nickname, string msgBody)
|
public void onDirectMessage(Message fullMessage, string nickname, string msgBody)
|
||||||
{
|
{
|
||||||
@ -110,12 +105,11 @@ public class Client : Thread
|
|||||||
logger.log("DirectMessage("~nickname~"): "~msgBody);
|
logger.log("DirectMessage("~nickname~"): "~msgBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: comment
|
|
||||||
/**
|
/**
|
||||||
|
* Called on generic commands
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* message =
|
* commandReply = the generic message
|
||||||
* commandReply =
|
|
||||||
*/
|
*/
|
||||||
public void onGenericCommand(Message message)
|
public void onGenericCommand(Message message)
|
||||||
{
|
{
|
||||||
@ -128,9 +122,10 @@ public class Client : Thread
|
|||||||
// ... for things that the client can learn from
|
// ... for things that the client can learn from
|
||||||
// TODO: comment
|
// TODO: comment
|
||||||
/**
|
/**
|
||||||
|
* Called on command replies
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* commandReply =
|
* commandReply = the command's reply
|
||||||
*/
|
*/
|
||||||
public void onCommandReply(Message commandReply)
|
public void onCommandReply(Message commandReply)
|
||||||
{
|
{
|
||||||
@ -152,8 +147,6 @@ public class Client : Thread
|
|||||||
* User operations (request-response type)
|
* User operations (request-response type)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: Add joinChannels(strung[])
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Joins the requested channel
|
* Joins the requested channel
|
||||||
*
|
*
|
||||||
@ -185,6 +178,75 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Joins the requested channels
|
||||||
|
*
|
||||||
|
* Params:
|
||||||
|
* channels = the channels to join
|
||||||
|
* Throws:
|
||||||
|
* BirchwoodException on invalid channel name
|
||||||
|
*/
|
||||||
|
public void joinChannel(string[] channels)
|
||||||
|
{
|
||||||
|
/* If single channel */
|
||||||
|
if(channels.length == 1)
|
||||||
|
{
|
||||||
|
/* Join the channel */
|
||||||
|
joinChannel(channels[0]);
|
||||||
|
}
|
||||||
|
/* If multiple channels */
|
||||||
|
else if(channels.length > 1)
|
||||||
|
{
|
||||||
|
string channelLine = channels[0];
|
||||||
|
|
||||||
|
/* Ensure valid characters in first channel */
|
||||||
|
if(isValidText(channelLine))
|
||||||
|
{
|
||||||
|
//TODO: Add check for #
|
||||||
|
|
||||||
|
/* Append on a trailing `,` */
|
||||||
|
channelLine ~= ",";
|
||||||
|
|
||||||
|
for(ulong i = 1; i < channels.length; i++)
|
||||||
|
{
|
||||||
|
string currentChannel = channels[i];
|
||||||
|
|
||||||
|
/* Ensure the character channel is valid */
|
||||||
|
if(isValidText(currentChannel))
|
||||||
|
{
|
||||||
|
//TODO: Add check for #
|
||||||
|
|
||||||
|
if(i == channels.length-1)
|
||||||
|
{
|
||||||
|
channelLine~=currentChannel;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
channelLine~=currentChannel~",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new BirchwoodException(BirchwoodException.ErrorType.ILLEGAL_CHARACTERS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Join multiple channels */
|
||||||
|
Message joinMessage = new Message("", "JOIN", channelLine);
|
||||||
|
sendMessage(joinMessage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new BirchwoodException(BirchwoodException.ErrorType.ILLEGAL_CHARACTERS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* If no channels provided at all (error) */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new BirchwoodException(BirchwoodException.ErrorType.EMPTY_PARAMS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parts from a list of channel(s) in one go
|
* Parts from a list of channel(s) in one go
|
||||||
*
|
*
|
||||||
@ -950,9 +1012,11 @@ public class Client : Thread
|
|||||||
client.joinChannel("#birchwood");
|
client.joinChannel("#birchwood");
|
||||||
// TODO: Add a joinChannels(string[])
|
// TODO: Add a joinChannels(string[])
|
||||||
client.joinChannel("#birchwood2");
|
client.joinChannel("#birchwood2");
|
||||||
client.joinChannel("#birchwoodLeave1");
|
|
||||||
client.joinChannel("#birchwoodLeave2");
|
client.joinChannel(["#birchwoodLeave1", "#birchwoodLeave2", "#birchwoodLeave3"]);
|
||||||
client.joinChannel("#birchwoodLeave3");
|
// client.joinChannel("#birchwoodLeave1");
|
||||||
|
// client.joinChannel("#birchwoodLeave2");
|
||||||
|
// client.joinChannel("#birchwoodLeave3");
|
||||||
|
|
||||||
Thread.sleep(dur!("seconds")(2));
|
Thread.sleep(dur!("seconds")(2));
|
||||||
client.command(new Message("", "NAMES", "")); // TODO: add names commdn
|
client.command(new Message("", "NAMES", "")); // TODO: add names commdn
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
module birchwood.protocol;
|
module birchwood.protocol;
|
||||||
|
|
||||||
public import birchwood.protocol.messages : Message;
|
public import birchwood.protocol.messages : Message;
|
||||||
|
public import birchwood.protocol.constants : ReplyType;
|
||||||
|
|
||||||
// TODO: Look how to neaten up (if any)
|
// TODO: Look how to neaten up (if any)
|
||||||
public import birchwood.protocol.formatting;
|
public import birchwood.protocol.formatting;
|
Loading…
Reference in New Issue
Block a user