File tree Expand file tree Collapse file tree 4 files changed +11
-4
lines changed Expand file tree Collapse file tree 4 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,15 @@ func (c *client) readInput() {
20
20
if err != nil {
21
21
return
22
22
}
23
-
24
23
msg = strings .Trim (msg , "\r \n " )
25
-
26
24
args := strings .Split (msg , " " )
27
25
cmd := strings .TrimSpace (args [0 ])
28
-
26
+ //make sure that the length of the input is at least 1
27
+ if len (args ) == 1 && args [0 ] != "/help" && args [0 ] != "/rooms" {
28
+ c .err (fmt .Errorf ("Cannot pass empty characters after the commands except the help command.\n " +
29
+ "Example of a valid Command: /msg Once upon a time in a far far away galaxy" +
30
+ "\n " ))
31
+ }
29
32
switch cmd {
30
33
case "/nick" :
31
34
c .commands <- command {
Original file line number Diff line number Diff line change @@ -50,7 +50,11 @@ func (s *server) newClient(conn net.Conn) {
50
50
}
51
51
52
52
func (s * server ) nick (c * client , nick string ) {
53
- c .nick = nick
53
+ if nick != "" {
54
+ c .nick = nick
55
+ } else {
56
+ log .Printf ("Bc error hogga\n " )
57
+ }
54
58
c .msg (fmt .Sprintf ("all right, I will call you %s" , nick ))
55
59
}
56
60
You can’t perform that action at this time.
0 commit comments