forked from lesderid/salty-ircd
Implement TIME
This commit is contained in:
parent
cfc1345682
commit
ffa830cf04
|
@ -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";
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue