mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
client: Add AWAYLEN
This commit is contained in:
parent
bc42960552
commit
0087de6092
@ -270,8 +270,8 @@ func (channel *Channel) SetTopic(client *Client, topic string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(topic) > client.server.limits.Topic {
|
if len(topic) > client.server.limits.TopicLen {
|
||||||
topic = topic[:client.server.limits.Topic]
|
topic = topic[:client.server.limits.TopicLen]
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.topic = topic
|
channel.topic = topic
|
||||||
@ -482,8 +482,8 @@ func (channel *Channel) Kick(client *Client, target *Client, comment string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(comment) > client.server.limits.Kick {
|
if len(comment) > client.server.limits.KickLen {
|
||||||
comment = comment[:client.server.limits.Kick]
|
comment = comment[:client.server.limits.KickLen]
|
||||||
}
|
}
|
||||||
|
|
||||||
for member := range channel.members {
|
for member := range channel.members {
|
||||||
|
@ -97,6 +97,7 @@ type Config struct {
|
|||||||
Limits struct {
|
Limits struct {
|
||||||
NickLen int `yaml:"nicklen"`
|
NickLen int `yaml:"nicklen"`
|
||||||
ChannelLen int `yaml:"channellen"`
|
ChannelLen int `yaml:"channellen"`
|
||||||
|
AwayLen int `yaml:"awaylen"`
|
||||||
KickLen int `yaml:"kicklen"`
|
KickLen int `yaml:"kicklen"`
|
||||||
TopicLen int `yaml:"topiclen"`
|
TopicLen int `yaml:"topiclen"`
|
||||||
WhowasEntries uint `yaml:"whowas-entries"`
|
WhowasEntries uint `yaml:"whowas-entries"`
|
||||||
@ -157,7 +158,7 @@ func LoadConfig(filename string) (config *Config, err error) {
|
|||||||
if len(config.Server.Listen) == 0 {
|
if len(config.Server.Listen) == 0 {
|
||||||
return nil, errors.New("Server listening addresses missing")
|
return nil, errors.New("Server listening addresses missing")
|
||||||
}
|
}
|
||||||
if config.Limits.NickLen < 1 || config.Limits.ChannelLen < 2 || config.Limits.TopicLen < 1 {
|
if config.Limits.NickLen < 1 || config.Limits.ChannelLen < 2 || config.Limits.AwayLen < 1 || config.Limits.TopicLen < 1 || config.Limits.TopicLen < 1 {
|
||||||
return nil, errors.New("Limits aren't setup properly, check them and make them sane")
|
return nil, errors.New("Limits aren't setup properly, check them and make them sane")
|
||||||
}
|
}
|
||||||
return config, nil
|
return config, nil
|
||||||
|
@ -28,8 +28,9 @@ import (
|
|||||||
|
|
||||||
// Limits holds the maximum limits for various things such as topic lengths
|
// Limits holds the maximum limits for various things such as topic lengths
|
||||||
type Limits struct {
|
type Limits struct {
|
||||||
Kick int
|
AwayLen int
|
||||||
Topic int
|
KickLen int
|
||||||
|
TopicLen int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
@ -81,8 +82,9 @@ func NewServer(config *Config) *Server {
|
|||||||
db: OpenDB(config.Datastore.SQLitePath),
|
db: OpenDB(config.Datastore.SQLitePath),
|
||||||
idle: make(chan *Client),
|
idle: make(chan *Client),
|
||||||
limits: Limits{
|
limits: Limits{
|
||||||
Kick: config.Limits.KickLen,
|
AwayLen: config.Limits.AwayLen,
|
||||||
Topic: config.Limits.TopicLen,
|
KickLen: config.Limits.KickLen,
|
||||||
|
TopicLen: config.Limits.TopicLen,
|
||||||
},
|
},
|
||||||
name: NewName(config.Server.Name),
|
name: NewName(config.Server.Name),
|
||||||
nameString: NewName(config.Server.Name).String(),
|
nameString: NewName(config.Server.Name).String(),
|
||||||
@ -169,13 +171,14 @@ func NewServer(config *Config) *Server {
|
|||||||
|
|
||||||
// add RPL_ISUPPORT tokens
|
// add RPL_ISUPPORT tokens
|
||||||
server.isupport = NewISupportList()
|
server.isupport = NewISupportList()
|
||||||
|
server.isupport.Add("AWAYLEN", strconv.Itoa(server.limits.AwayLen))
|
||||||
server.isupport.Add("CASEMAPPING", "ascii")
|
server.isupport.Add("CASEMAPPING", "ascii")
|
||||||
// server.isupport.Add("CHANMODES", "") //TODO(dan): Channel mode list here
|
// server.isupport.Add("CHANMODES", "") //TODO(dan): Channel mode list here
|
||||||
server.isupport.Add("CHANNELLEN", strconv.Itoa(config.Limits.ChannelLen))
|
server.isupport.Add("CHANNELLEN", strconv.Itoa(config.Limits.ChannelLen))
|
||||||
server.isupport.Add("CHANTYPES", "#")
|
server.isupport.Add("CHANTYPES", "#")
|
||||||
server.isupport.Add("EXCEPTS", "")
|
server.isupport.Add("EXCEPTS", "")
|
||||||
server.isupport.Add("INVEX", "")
|
server.isupport.Add("INVEX", "")
|
||||||
server.isupport.Add("KICKLEN", strconv.Itoa(server.limits.Kick))
|
server.isupport.Add("KICKLEN", strconv.Itoa(server.limits.KickLen))
|
||||||
// server.isupport.Add("MAXLIST", "") //TODO(dan): Support max list length?
|
// server.isupport.Add("MAXLIST", "") //TODO(dan): Support max list length?
|
||||||
// server.isupport.Add("MODES", "") //TODO(dan): Support max modes?
|
// server.isupport.Add("MODES", "") //TODO(dan): Support max modes?
|
||||||
server.isupport.Add("NETWORK", config.Network.Name)
|
server.isupport.Add("NETWORK", config.Network.Name)
|
||||||
@ -183,7 +186,7 @@ func NewServer(config *Config) *Server {
|
|||||||
server.isupport.Add("PREFIX", "(qaohv)~&@%+")
|
server.isupport.Add("PREFIX", "(qaohv)~&@%+")
|
||||||
// server.isupport.Add("STATUSMSG", "@+") //TODO(dan): Support STATUSMSG
|
// server.isupport.Add("STATUSMSG", "@+") //TODO(dan): Support STATUSMSG
|
||||||
// server.isupport.Add("TARGMAX", "") //TODO(dan): Support this
|
// server.isupport.Add("TARGMAX", "") //TODO(dan): Support this
|
||||||
server.isupport.Add("TOPICLEN", strconv.Itoa(server.limits.Topic))
|
server.isupport.Add("TOPICLEN", strconv.Itoa(server.limits.TopicLen))
|
||||||
|
|
||||||
// account registration
|
// account registration
|
||||||
if server.accountRegistration.Enabled {
|
if server.accountRegistration.Enabled {
|
||||||
@ -816,6 +819,9 @@ func awayHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
if len(msg.Params) > 0 {
|
if len(msg.Params) > 0 {
|
||||||
isAway = true
|
isAway = true
|
||||||
text = msg.Params[0]
|
text = msg.Params[0]
|
||||||
|
if len(text) > server.limits.AwayLen {
|
||||||
|
text = text[:server.limits.AwayLen]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if isAway {
|
if isAway {
|
||||||
|
@ -87,6 +87,9 @@ limits:
|
|||||||
# channellen is the max channel length allowed
|
# channellen is the max channel length allowed
|
||||||
channellen: 64
|
channellen: 64
|
||||||
|
|
||||||
|
# awaylen is the maximum length of an away message
|
||||||
|
awaylen: 200
|
||||||
|
|
||||||
# kicklen is the maximum length of a kick message
|
# kicklen is the maximum length of a kick message
|
||||||
kicklen: 390
|
kicklen: 390
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user