Bladeren bron

Enable chanmode +r, fix bug with registering channels

tags/v0.7.1
Daniel Oaks 7 jaren geleden
bovenliggende
commit
0046025d60
5 gewijzigde bestanden met toevoegingen van 27 en 15 verwijderingen
  1. 3
    0
      irc/channel.go
  2. 1
    1
      irc/chanserv.go
  3. 9
    13
      irc/help.go
  4. 2
    1
      irc/modes.go
  5. 12
    0
      irc/server.go

+ 3
- 0
irc/channel.go Bestand weergeven

@@ -425,6 +425,9 @@ func (channel *Channel) CanSpeak(client *Client) bool {
425 425
 	if channel.flags[Moderated] && !channel.clientIsAtLeastNoMutex(client, Voice) {
426 426
 		return false
427 427
 	}
428
+	if channel.flags[RegisteredOnly] && client.account == &NoAccount {
429
+		return false
430
+	}
428 431
 	return true
429 432
 }
430 433
 

+ 1
- 1
irc/chanserv.go Bestand weergeven

@@ -83,7 +83,7 @@ func (server *Server) chanservReceivePrivmsg(client *Client, message string) {
83 83
 			}
84 84
 
85 85
 			account := client.account
86
-			if account == nil {
86
+			if account == &NoAccount {
87 87
 				client.ChanServNotice("You must be logged in to register a channel")
88 88
 				return nil
89 89
 			}

+ 9
- 13
irc/help.go Bestand weergeven

@@ -21,25 +21,18 @@ var (
21 21
 
22 22
 Oragono supports the following channel modes:
23 23
 
24
-= Type A - list modes =
25
-
26
-  +b  |  Client masks that are banned from the channel.
24
+  +b  |  Client masks that are banned from the channel (e.g. *!*@127.0.0.1)
27 25
   +e  |  Client masks that are exempted from bans.
28 26
   +I  |  Client masks that are exempted from the invite-only flag.
29
-
30
-= Type C - setting modes with a parameter =
31
-
32
-  +l  |  Client join limit for the channel.
33
-  +k  |  Key required when joining the channel.
34
-
35
-= Type D - flag modes =
36
-
37 27
   +i  |  Invite-only mode, only invited clients can join the channel.
28
+  +k  |  Key required when joining the channel.
29
+  +l  |  Client join limit for the channel.
38 30
   +m  |  Moderated mode, only privileged clients can talk on the channel.
39 31
   +n  |  No-outside-messages mode, only users that are on the channel can send
40 32
       |  messages to it.
41
-  +t  |  Only channel opers can modify the topic.
33
+  +r  |  Only registered users can talk in the channel.
42 34
   +s  |  Secret mode, channel won't show up in /LIST or whois replies.
35
+  +t  |  Only channel opers can modify the topic.
43 36
 
44 37
 = Prefixes =
45 38
 
@@ -210,7 +203,7 @@ command is processed by that server.`,
210 203
 		text: `MODE <target> [<modestring> [<mode arguments>...]]
211 204
 
212 205
 Sets and removes modes from the given target. For more specific information on
213
-mode characters, see the help for "cmode" and "umode".`,
206
+mode characters, see the help for "modes".`,
214 207
 	},
215 208
 	"monitor": {
216 209
 		text: `MONITOR <subcmd>
@@ -417,6 +410,9 @@ Returns historical information on the last user with the given nickname.`,
417 410
 	},
418 411
 
419 412
 	// Informational
413
+	"modes": {
414
+		text: cmodeHelpText + "\n\n" + umodeHelpText,
415
+	},
420 416
 	"cmode": {
421 417
 		text: cmodeHelpText,
422 418
 	},

+ 2
- 1
irc/modes.go Bestand weergeven

@@ -122,6 +122,7 @@ const (
122 122
 	Moderated       Mode = 'm' // flag
123 123
 	NoOutside       Mode = 'n' // flag
124 124
 	OpOnlyTopic     Mode = 't' // flag
125
+	RegisteredOnly  Mode = 'r' // flag
125 126
 	Secret          Mode = 's' // flag
126 127
 	UserLimit       Mode = 'l' // flag arg
127 128
 )
@@ -455,7 +456,7 @@ func ApplyChannelModeChanges(channel *Channel, client *Client, isSamode bool, ch
455 456
 			}
456 457
 			applied = append(applied, change)
457 458
 
458
-		case InviteOnly, Moderated, NoOutside, OpOnlyTopic, Secret, ChanRoleplaying:
459
+		case InviteOnly, Moderated, NoOutside, OpOnlyTopic, RegisteredOnly, Secret, ChanRoleplaying:
459 460
 			switch change.op {
460 461
 			case Add:
461 462
 				if channel.flags[change.mode] {

+ 12
- 0
irc/server.go Bestand weergeven

@@ -952,6 +952,10 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
952 952
 				client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel")
953 953
 				continue
954 954
 			}
955
+			if !channel.CanSpeak(client) {
956
+				client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel")
957
+				continue
958
+			}
955 959
 			msgid := server.generateMessageID()
956 960
 			channel.SplitPrivMsg(msgid, lowestPrefix, clientOnlyTags, client, splitMsg)
957 961
 		} else {
@@ -1017,6 +1021,10 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
1017 1021
 				client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel")
1018 1022
 				continue
1019 1023
 			}
1024
+			if !channel.CanSpeak(client) {
1025
+				client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel")
1026
+				continue
1027
+			}
1020 1028
 			msgid := server.generateMessageID()
1021 1029
 
1022 1030
 			channel.TagMsg(msgid, lowestPrefix, clientOnlyTags, client)
@@ -1610,6 +1618,10 @@ func noticeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
1610 1618
 				// errors silently ignored with NOTICE as per RFC
1611 1619
 				continue
1612 1620
 			}
1621
+			if !channel.CanSpeak(client) {
1622
+				// errors silently ignored with NOTICE as per RFC
1623
+				continue
1624
+			}
1613 1625
 			msgid := server.generateMessageID()
1614 1626
 			channel.SplitNotice(msgid, lowestPrefix, clientOnlyTags, client, splitMsg)
1615 1627
 		} else {

Laden…
Annuleren
Opslaan