浏览代码

add channel autojoin feature

See discussion on #2077
tags/v2.12.0-rc1
Shivaram Lingamneni 11 个月前
父节点
当前提交
75bd63d0bc
共有 4 个文件被更改,包括 29 次插入2 次删除
  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 查看文件

364
     # in a "closed-loop" system where you control the server and all the clients,
364
     # in a "closed-loop" system where you control the server and all the clients,
365
     # you may want to increase the maximum (non-tag) length of an IRC line from
365
     # you may want to increase the maximum (non-tag) length of an IRC line from
366
     # the default value of 512. DO NOT change this on a public server:
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
     # send all 0's as the LUSERS (user counts) output to non-operators; potentially useful
369
     # send all 0's as the LUSERS (user counts) output to non-operators; potentially useful
370
     # if you don't want to publicize how popular the server is
370
     # if you don't want to publicize how popular the server is
615
     # (0 or omit for no expiration):
615
     # (0 or omit for no expiration):
616
     invite-expiration: 24h
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
 # operator classes:
624
 # operator classes:
619
 # an operator has a single "class" (defining a privilege level), which can include
625
 # an operator has a single "class" (defining a privilege level), which can include
620
 # multiple "capabilities" (defining privileged actions they can take). all
626
 # multiple "capabilities" (defining privileged actions they can take). all

+ 1
- 0
irc/config.go 查看文件

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

+ 14
- 0
irc/server.go 查看文件

394
 	}
394
 	}
395
 
395
 
396
 	server.playRegistrationBurst(session)
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
 	return false
403
 	return false
398
 }
404
 }
399
 
405
 
502
 	rb.Add(nil, server.name, RPL_ENDOFMOTD, client.nick, client.t("End of MOTD command"))
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
 func (client *Client) whoisChannelsNames(target *Client, multiPrefix bool, hasPrivs bool) []string {
519
 func (client *Client) whoisChannelsNames(target *Client, multiPrefix bool, hasPrivs bool) []string {
506
 	var chstrs []string
520
 	var chstrs []string
507
 	targetInvis := target.HasMode(modes.Invisible)
521
 	targetInvis := target.HasMode(modes.Invisible)

+ 7
- 1
traditional.yaml 查看文件

337
     # in a "closed-loop" system where you control the server and all the clients,
337
     # in a "closed-loop" system where you control the server and all the clients,
338
     # you may want to increase the maximum (non-tag) length of an IRC line from
338
     # you may want to increase the maximum (non-tag) length of an IRC line from
339
     # the default value of 512. DO NOT change this on a public server:
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
     # send all 0's as the LUSERS (user counts) output to non-operators; potentially useful
342
     # send all 0's as the LUSERS (user counts) output to non-operators; potentially useful
343
     # if you don't want to publicize how popular the server is
343
     # if you don't want to publicize how popular the server is
587
     # (0 or omit for no expiration):
587
     # (0 or omit for no expiration):
588
     invite-expiration: 24h
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
 # operator classes:
596
 # operator classes:
591
 # an operator has a single "class" (defining a privilege level), which can include
597
 # an operator has a single "class" (defining a privilege level), which can include
592
 # multiple "capabilities" (defining privileged actions they can take). all
598
 # multiple "capabilities" (defining privileged actions they can take). all

正在加载...
取消
保存