Add mode +D delaying user count updates, add modes table to README
parent
24fc8f9ef5
commit
75ec0e11bf
|
@ -7,3 +7,12 @@ AnonIRCd is an anonymous IRC daemon. All messages appear to be written by **Ano
|
|||
Connect to [**z.1chan.us:6667**](irc://z.1chan.us:6667) or [**:6697 (SSL)**](ircs://z.1chan.us:6697).
|
||||
|
||||
All new clients auto-join a channel named `#`. `/list` to see all non-secret channels. `/join #anonirc` if you'd like to discuss the daemon.
|
||||
|
||||
## Modes
|
||||
|
||||
Mode | Type | Description
|
||||
--- | --- | ---
|
||||
c | User & Channel | Hide user count (always set to 1)
|
||||
D | User & Channel | Delay user count updates (joins/parts) until someone speaks
|
||||
k *key* | Channel | Set channel key (password) required to join
|
||||
l *limit* | Channel | Set user limit
|
||||
|
|
|
@ -14,8 +14,8 @@ const ENTITY_CHANNEL = 1
|
|||
const ENTITY_STATE_TERMINATING = 0
|
||||
const ENTITY_STATE_NORMAL = 1
|
||||
|
||||
const CLIENT_MODES = "c"
|
||||
const CHANNEL_MODES = "cipstz"
|
||||
const CLIENT_MODES = "cD"
|
||||
const CHANNEL_MODES = "cDipstz"
|
||||
const CHANNEL_MODES_ARG = "kl"
|
||||
|
||||
type Entity struct {
|
||||
|
|
22
server.go
22
server.go
|
@ -127,7 +127,7 @@ func (s *Server) joinChannel(channel string, client string) {
|
|||
cl.write(&irc.Message{cl.getPrefix(), irc.JOIN, []string{channel}})
|
||||
|
||||
s.sendNames(channel, client)
|
||||
s.updateClientCount(channel)
|
||||
s.updateClientCount(channel, client)
|
||||
s.sendTopic(channel, client, false)
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ func (s *Server) partChannel(channel string, client string, reason string) {
|
|||
cl.write(&irc.Message{cl.getPrefix(), irc.PART, []string{channel, reason}})
|
||||
ch.clients.Remove(client)
|
||||
|
||||
s.updateClientCount(channel)
|
||||
s.updateClientCount(channel, client)
|
||||
}
|
||||
|
||||
func (s *Server) partAllChannels(client string) {
|
||||
|
@ -180,7 +180,7 @@ func (s *Server) getClientCount(channel string, client string) int {
|
|||
return ccount
|
||||
}
|
||||
|
||||
func (s *Server) updateClientCount(channel string) {
|
||||
func (s *Server) updateClientCount(channel string, client string) {
|
||||
ch := s.getChannel(channel)
|
||||
|
||||
if ch == nil {
|
||||
|
@ -191,6 +191,10 @@ func (s *Server) updateClientCount(channel string) {
|
|||
cclient := cls.Key
|
||||
ccount := cls.Val.(int)
|
||||
|
||||
if client != "" && ch.hasMode("D") && cclient != client {
|
||||
continue
|
||||
}
|
||||
|
||||
cl := s.getClient(cclient)
|
||||
|
||||
if cl == nil {
|
||||
|
@ -340,6 +344,9 @@ func (s *Server) handleMode(c *Client, params []string) {
|
|||
if _, ok := removedmodes["c"]; ok {
|
||||
resendusercount = true
|
||||
}
|
||||
if _, ok := removedmodes["D"]; ok {
|
||||
resendusercount = true
|
||||
}
|
||||
|
||||
if len(addedmodes) == 0 && len(removedmodes) == 0 {
|
||||
addedmodes = c.getModes()
|
||||
|
@ -354,7 +361,7 @@ func (s *Server) handleMode(c *Client, params []string) {
|
|||
}
|
||||
|
||||
if resendusercount {
|
||||
s.updateClientCount(params[0])
|
||||
s.updateClientCount(params[0], c.identifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -384,6 +391,9 @@ func (s *Server) handleMode(c *Client, params []string) {
|
|||
if _, ok := removedmodes["c"]; ok {
|
||||
resendusercount = true
|
||||
}
|
||||
if _, ok := removedmodes["D"]; ok {
|
||||
resendusercount = true
|
||||
}
|
||||
|
||||
if len(addedmodes) == 0 && len(removedmodes) == 0 {
|
||||
addedmodes = c.getModes()
|
||||
|
@ -393,7 +403,7 @@ func (s *Server) handleMode(c *Client, params []string) {
|
|||
|
||||
if resendusercount {
|
||||
for ch := range s.getChannels(c.identifier) {
|
||||
s.updateClientCount(ch)
|
||||
s.updateClientCount(ch, c.identifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -411,6 +421,8 @@ func (s *Server) handlePrivmsg(channel string, client string, message string) {
|
|||
return
|
||||
}
|
||||
|
||||
s.updateClientCount(channel, "")
|
||||
|
||||
for cls := range ch.clients.IterBuffered() {
|
||||
ccl := s.getClient(cls.Key)
|
||||
|
||||
|
|
Loading…
Reference in New Issue