Browse Source

add channel autojoin feature

See discussion on #2077
tags/v2.12.0-rc1
Shivaram Lingamneni 10 months ago
parent
commit
75bd63d0bc
4 changed files with 29 additions and 2 deletions
  1. 7
    1
      default.yaml
  2. 1
    0
      irc/config.go
  3. 14
    0
      irc/server.go
  4. 7
    1
      traditional.yaml

+ 7
- 1
default.yaml View File

@@ -364,7 +364,7 @@ server:
364 364
     # in a "closed-loop" system where you control the server and all the clients,
365 365
     # you may want to increase the maximum (non-tag) length of an IRC line from
366 366
     # the default value of 512. DO NOT change this on a public server:
367
-    # max-line-len: 512
367
+    #max-line-len: 512
368 368
 
369 369
     # send all 0's as the LUSERS (user counts) output to non-operators; potentially useful
370 370
     # if you don't want to publicize how popular the server is
@@ -615,6 +615,12 @@ channels:
615 615
     # (0 or omit for no expiration):
616 616
     invite-expiration: 24h
617 617
 
618
+    # channels that new clients will automatically join. this should be used with
619
+    # caution, since traditional IRC users will likely view it as an antifeature.
620
+    # it may be useful in small community networks that have a single "primary" channel:
621
+    #auto-join:
622
+    #    - "#lounge"
623
+
618 624
 # operator classes:
619 625
 # an operator has a single "class" (defining a privilege level), which can include
620 626
 # multiple "capabilities" (defining privileged actions they can take). all

+ 1
- 0
irc/config.go View File

@@ -644,6 +644,7 @@ type Config struct {
644 644
 		}
645 645
 		ListDelay        time.Duration    `yaml:"list-delay"`
646 646
 		InviteExpiration custime.Duration `yaml:"invite-expiration"`
647
+		AutoJoin         []string         `yaml:"auto-join"`
647 648
 	}
648 649
 
649 650
 	OperClasses map[string]*OperClassConfig `yaml:"oper-classes"`

+ 14
- 0
irc/server.go View File

@@ -394,6 +394,12 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
394 394
 	}
395 395
 
396 396
 	server.playRegistrationBurst(session)
397
+
398
+	if len(config.Channels.AutoJoin) > 0 {
399
+		// only applicable to new clients, not reattaches:
400
+		server.handleAutojoins(session, config.Channels.AutoJoin)
401
+	}
402
+
397 403
 	return false
398 404
 }
399 405
 
@@ -502,6 +508,14 @@ func (server *Server) MOTD(client *Client, rb *ResponseBuffer) {
502 508
 	rb.Add(nil, server.name, RPL_ENDOFMOTD, client.nick, client.t("End of MOTD command"))
503 509
 }
504 510
 
511
+func (server *Server) handleAutojoins(session *Session, channelNames []string) {
512
+	rb := NewResponseBuffer(session)
513
+	for _, chname := range channelNames {
514
+		server.channels.Join(session.client, chname, "", false, rb)
515
+	}
516
+	rb.Send(true)
517
+}
518
+
505 519
 func (client *Client) whoisChannelsNames(target *Client, multiPrefix bool, hasPrivs bool) []string {
506 520
 	var chstrs []string
507 521
 	targetInvis := target.HasMode(modes.Invisible)

+ 7
- 1
traditional.yaml View File

@@ -337,7 +337,7 @@ server:
337 337
     # in a "closed-loop" system where you control the server and all the clients,
338 338
     # you may want to increase the maximum (non-tag) length of an IRC line from
339 339
     # the default value of 512. DO NOT change this on a public server:
340
-    # max-line-len: 512
340
+    #max-line-len: 512
341 341
 
342 342
     # send all 0's as the LUSERS (user counts) output to non-operators; potentially useful
343 343
     # if you don't want to publicize how popular the server is
@@ -587,6 +587,12 @@ channels:
587 587
     # (0 or omit for no expiration):
588 588
     invite-expiration: 24h
589 589
 
590
+    # channels that new clients will automatically join. this should be used with
591
+    # caution, since traditional IRC users will likely view it as an antifeature.
592
+    # it may be useful in small community networks that have a single "primary" channel:
593
+    #auto-join:
594
+    #    - "#lounge"
595
+
590 596
 # operator classes:
591 597
 # an operator has a single "class" (defining a privilege level), which can include
592 598
 # multiple "capabilities" (defining privileged actions they can take). all

Loading…
Cancel
Save