mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-23 03:02:48 +01:00
channels: send RPL_CHANNELCREATED and RPL_TOPICTIME
This commit is contained in:
parent
34a099b61a
commit
bded3202c2
@ -8,6 +8,7 @@ package irc
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Channel struct {
|
type Channel struct {
|
||||||
@ -18,7 +19,10 @@ type Channel struct {
|
|||||||
name Name
|
name Name
|
||||||
nameString string
|
nameString string
|
||||||
server *Server
|
server *Server
|
||||||
|
createdTime time.Time
|
||||||
topic string
|
topic string
|
||||||
|
topicSetBy string
|
||||||
|
topicSetTime time.Time
|
||||||
userLimit uint64
|
userLimit uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,6 +209,7 @@ func (channel *Channel) Join(client *Client, key string) {
|
|||||||
client.channels.Add(channel)
|
client.channels.Add(channel)
|
||||||
channel.members.Add(client)
|
channel.members.Add(client)
|
||||||
if !channel.flags[Persistent] && (len(channel.members) == 1) {
|
if !channel.flags[Persistent] && (len(channel.members) == 1) {
|
||||||
|
channel.createdTime = time.Now()
|
||||||
channel.members[client][ChannelFounder] = true
|
channel.members[client][ChannelFounder] = true
|
||||||
channel.members[client][ChannelOperator] = true
|
channel.members[client][ChannelOperator] = true
|
||||||
}
|
}
|
||||||
@ -238,7 +243,7 @@ func (channel *Channel) GetTopic(client *Client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.Send(nil, client.server.nameString, RPL_TOPIC, client.nickString, channel.nameString, channel.topic)
|
client.Send(nil, client.server.nameString, RPL_TOPIC, client.nickString, channel.nameString, channel.topic)
|
||||||
//TODO(dan): show topic time and setter here too
|
client.Send(nil, client.server.nameString, RPL_TOPICTIME, client.nickString, channel.nameString, channel.topicSetBy, strconv.FormatInt(channel.topicSetTime.Unix(), 10))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) SetTopic(client *Client, topic string) {
|
func (channel *Channel) SetTopic(client *Client, topic string) {
|
||||||
@ -253,6 +258,8 @@ func (channel *Channel) SetTopic(client *Client, topic string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
channel.topic = topic
|
channel.topic = topic
|
||||||
|
channel.topicSetBy = client.nickString
|
||||||
|
channel.topicSetTime = time.Now()
|
||||||
|
|
||||||
for member := range channel.members {
|
for member := range channel.members {
|
||||||
member.Send(nil, client.nickMaskString, "TOPIC", channel.nameString, channel.topic)
|
member.Send(nil, client.nickMaskString, "TOPIC", channel.nameString, channel.topic)
|
||||||
@ -404,6 +411,7 @@ func (channel *Channel) applyModeMask(client *Client, mode ChannelMode, op ModeO
|
|||||||
|
|
||||||
func (channel *Channel) Persist() (err error) {
|
func (channel *Channel) Persist() (err error) {
|
||||||
if channel.flags[Persistent] {
|
if channel.flags[Persistent] {
|
||||||
|
//TODO(dan): Save topicSetBy/topicSetTime and createdTime
|
||||||
_, err = channel.server.db.Exec(`
|
_, err = channel.server.db.Exec(`
|
||||||
INSERT OR REPLACE INTO channel
|
INSERT OR REPLACE INTO channel
|
||||||
(name, flags, key, topic, user_limit, ban_list, except_list,
|
(name, flags, key, topic, user_limit, ban_list, except_list,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package irc
|
package irc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/DanielOaks/girc-go/ircmsg"
|
"github.com/DanielOaks/girc-go/ircmsg"
|
||||||
@ -371,6 +372,7 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
//TODO(dan): we should just make ModeString return a slice here
|
//TODO(dan): we should just make ModeString return a slice here
|
||||||
args := append([]string{client.nickString, channel.nameString}, strings.Split(channel.ModeString(client), " ")...)
|
args := append([]string{client.nickString, channel.nameString}, strings.Split(channel.ModeString(client), " ")...)
|
||||||
client.Send(nil, client.nickMaskString, RPL_CHANNELMODEIS, args...)
|
client.Send(nil, client.nickMaskString, RPL_CHANNELMODEIS, args...)
|
||||||
|
client.Send(nil, client.nickMaskString, RPL_CHANNELCREATED, client.nickString, channel.nameString, strconv.FormatInt(channel.createdTime.Unix(), 10))
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,10 @@ const (
|
|||||||
RPL_LISTEND = "323"
|
RPL_LISTEND = "323"
|
||||||
RPL_CHANNELMODEIS = "324"
|
RPL_CHANNELMODEIS = "324"
|
||||||
RPL_UNIQOPIS = "325"
|
RPL_UNIQOPIS = "325"
|
||||||
RPL_CREATIONTIME = "329"
|
RPL_CHANNELCREATED = "329"
|
||||||
RPL_NOTOPIC = "331"
|
RPL_NOTOPIC = "331"
|
||||||
RPL_TOPIC = "332"
|
RPL_TOPIC = "332"
|
||||||
|
RPL_TOPICTIME = "333"
|
||||||
RPL_INVITING = "341"
|
RPL_INVITING = "341"
|
||||||
RPL_SUMMONING = "342"
|
RPL_SUMMONING = "342"
|
||||||
RPL_INVITELIST = "346"
|
RPL_INVITELIST = "346"
|
||||||
|
Loading…
Reference in New Issue
Block a user