Implement TIME

This commit is contained in:
Les De Ridder 2017-03-22 17:33:56 +01:00
parent cfc1345682
commit ffa830cf04
No known key found for this signature in database
GPG Key ID: 5EC132DFA85DB372
2 changed files with 21 additions and 0 deletions

View File

@ -169,6 +169,10 @@ class Connection
if(!registered) sendErrNotRegistered();
else onVersion(message);
break;
case "TIME":
if(!registered) sendErrNotRegistered();
else onTime(message);
break;
default:
writeln("unknown command '", message.command, "'");
send(Message(_server.name, "421", [nick, message.command, "Unknown command"]));
@ -583,6 +587,16 @@ class Connection
_server.sendVersion(this);
}
void onTime(Message message)
{
if(message.parameters.length > 0)
{
notImplemented("querying the time of another server");
return;
}
_server.sendTime(this);
}
void sendWhoReply(string channel, Connection user, uint hopCount)
{
auto flags = user.modes.canFind('a') ? "G" : "H";

View File

@ -6,6 +6,7 @@ import std.range;
import std.conv;
import std.socket;
import core.time;
import std.datetime;
import vibe.core.core;
@ -256,6 +257,12 @@ class Server
connection.send(Message(name, "351", [connection.nick, versionString ~ ".", name, ""], true));
}
void sendTime(Connection connection)
{
auto timeString = Clock.currTime.toISOExtString;
connection.send(Message(name, "391", [connection.nick, name, timeString], true));
}
void invite(Connection inviter, string target, string channelName)
{
auto user = connections.find!(c => c.nick = target)[0];