3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 03:49:27 +01:00

server ctime

This commit is contained in:
Jeremy Latt 2012-04-17 22:21:41 -07:00
parent 4cee1ef909
commit 259fd40916
3 changed files with 7 additions and 3 deletions

View File

@ -65,7 +65,7 @@ func tryRegister(s *Server, c *Client) {
c.registered = true
c.send <- ReplyWelcome(c)
c.send <- ReplyYourHost(c.Nick(), s.name)
c.send <- ReplyCreated(c.Nick(), "2012/04/07")
c.send <- ReplyCreated(c.Nick(), s.ctime)
c.send <- ReplyMyInfo(c.Nick(), s.name)
}
}

View File

@ -2,6 +2,7 @@ package irc
import (
"fmt"
"time"
)
func ReplyNick(oldNick string, c *Client) string {
@ -16,8 +17,8 @@ func ReplyYourHost(nick string, server string) string {
return fmt.Sprintf("%s %s Your host is %s, running version %s", RPL_YOURHOST, nick, server, VERSION)
}
func ReplyCreated(nick string, created string) string {
return fmt.Sprintf("%s %s This server was created %s", RPL_CREATED, nick, created)
func ReplyCreated(nick string, ctime time.Time) string {
return fmt.Sprintf("%s %s This server was created %s", RPL_CREATED, nick, ctime.Format(time.RFC1123))
}
func ReplyMyInfo(nick string, servername string) string {

View File

@ -3,9 +3,11 @@ package irc
import (
"log"
"net"
"time"
)
type Server struct {
ctime time.Time
name string
ch chan *ClientMessage
nicks map[string]*Client
@ -18,6 +20,7 @@ type ClientMessage struct {
func NewServer(name string) *Server {
server := new(Server)
server.ctime = time.Now()
server.name = name
server.ch = make(chan *ClientMessage)
server.nicks = make(map[string]*Client)