Browse Source

Enable chanmode +r, fix bug with registering channels

tags/v0.7.1
Daniel Oaks 7 years ago
parent
commit
0046025d60
5 changed files with 27 additions and 15 deletions
  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 View File

425
 	if channel.flags[Moderated] && !channel.clientIsAtLeastNoMutex(client, Voice) {
425
 	if channel.flags[Moderated] && !channel.clientIsAtLeastNoMutex(client, Voice) {
426
 		return false
426
 		return false
427
 	}
427
 	}
428
+	if channel.flags[RegisteredOnly] && client.account == &NoAccount {
429
+		return false
430
+	}
428
 	return true
431
 	return true
429
 }
432
 }
430
 
433
 

+ 1
- 1
irc/chanserv.go View File

83
 			}
83
 			}
84
 
84
 
85
 			account := client.account
85
 			account := client.account
86
-			if account == nil {
86
+			if account == &NoAccount {
87
 				client.ChanServNotice("You must be logged in to register a channel")
87
 				client.ChanServNotice("You must be logged in to register a channel")
88
 				return nil
88
 				return nil
89
 			}
89
 			}

+ 9
- 13
irc/help.go View File

21
 
21
 
22
 Oragono supports the following channel modes:
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
   +e  |  Client masks that are exempted from bans.
25
   +e  |  Client masks that are exempted from bans.
28
   +I  |  Client masks that are exempted from the invite-only flag.
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
   +i  |  Invite-only mode, only invited clients can join the channel.
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
   +m  |  Moderated mode, only privileged clients can talk on the channel.
30
   +m  |  Moderated mode, only privileged clients can talk on the channel.
39
   +n  |  No-outside-messages mode, only users that are on the channel can send
31
   +n  |  No-outside-messages mode, only users that are on the channel can send
40
       |  messages to it.
32
       |  messages to it.
41
-  +t  |  Only channel opers can modify the topic.
33
+  +r  |  Only registered users can talk in the channel.
42
   +s  |  Secret mode, channel won't show up in /LIST or whois replies.
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
 = Prefixes =
37
 = Prefixes =
45
 
38
 
210
 		text: `MODE <target> [<modestring> [<mode arguments>...]]
203
 		text: `MODE <target> [<modestring> [<mode arguments>...]]
211
 
204
 
212
 Sets and removes modes from the given target. For more specific information on
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
 	"monitor": {
208
 	"monitor": {
216
 		text: `MONITOR <subcmd>
209
 		text: `MONITOR <subcmd>
417
 	},
410
 	},
418
 
411
 
419
 	// Informational
412
 	// Informational
413
+	"modes": {
414
+		text: cmodeHelpText + "\n\n" + umodeHelpText,
415
+	},
420
 	"cmode": {
416
 	"cmode": {
421
 		text: cmodeHelpText,
417
 		text: cmodeHelpText,
422
 	},
418
 	},

+ 2
- 1
irc/modes.go View File

122
 	Moderated       Mode = 'm' // flag
122
 	Moderated       Mode = 'm' // flag
123
 	NoOutside       Mode = 'n' // flag
123
 	NoOutside       Mode = 'n' // flag
124
 	OpOnlyTopic     Mode = 't' // flag
124
 	OpOnlyTopic     Mode = 't' // flag
125
+	RegisteredOnly  Mode = 'r' // flag
125
 	Secret          Mode = 's' // flag
126
 	Secret          Mode = 's' // flag
126
 	UserLimit       Mode = 'l' // flag arg
127
 	UserLimit       Mode = 'l' // flag arg
127
 )
128
 )
455
 			}
456
 			}
456
 			applied = append(applied, change)
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
 			switch change.op {
460
 			switch change.op {
460
 			case Add:
461
 			case Add:
461
 				if channel.flags[change.mode] {
462
 				if channel.flags[change.mode] {

+ 12
- 0
irc/server.go View File

952
 				client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel")
952
 				client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel")
953
 				continue
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
 			msgid := server.generateMessageID()
959
 			msgid := server.generateMessageID()
956
 			channel.SplitPrivMsg(msgid, lowestPrefix, clientOnlyTags, client, splitMsg)
960
 			channel.SplitPrivMsg(msgid, lowestPrefix, clientOnlyTags, client, splitMsg)
957
 		} else {
961
 		} else {
1017
 				client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel")
1021
 				client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel")
1018
 				continue
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
 			msgid := server.generateMessageID()
1028
 			msgid := server.generateMessageID()
1021
 
1029
 
1022
 			channel.TagMsg(msgid, lowestPrefix, clientOnlyTags, client)
1030
 			channel.TagMsg(msgid, lowestPrefix, clientOnlyTags, client)
1610
 				// errors silently ignored with NOTICE as per RFC
1618
 				// errors silently ignored with NOTICE as per RFC
1611
 				continue
1619
 				continue
1612
 			}
1620
 			}
1621
+			if !channel.CanSpeak(client) {
1622
+				// errors silently ignored with NOTICE as per RFC
1623
+				continue
1624
+			}
1613
 			msgid := server.generateMessageID()
1625
 			msgid := server.generateMessageID()
1614
 			channel.SplitNotice(msgid, lowestPrefix, clientOnlyTags, client, splitMsg)
1626
 			channel.SplitNotice(msgid, lowestPrefix, clientOnlyTags, client, splitMsg)
1615
 		} else {
1627
 		} else {

Loading…
Cancel
Save