Bugfixen.
authorAndrey Petrov <andrey.petrov@shazow.net>
Sun, 11 Jan 2015 03:48:17 +0000 (19:48 -0800)
committerAndrey Petrov <andrey.petrov@shazow.net>
Sun, 11 Jan 2015 03:48:17 +0000 (19:48 -0800)
cmd.go
command.go [deleted file]
host.go

diff --git a/cmd.go b/cmd.go
index e24436125903fe90c338b31e0d9b1b0c1f7c6ff1..9a222092eda75fb98dd3e48aa2ea383e18ba624a 100644 (file)
--- a/cmd.go
+++ b/cmd.go
@@ -60,7 +60,7 @@ func main() {
        // Figure out the log level
        numVerbose := len(options.Verbose)
        if numVerbose > len(logLevels) {
-               numVerbose = len(logLevels)
+               numVerbose = len(logLevels) - 1
        }
 
        logLevel := logLevels[numVerbose]
diff --git a/command.go b/command.go
deleted file mode 100644 (file)
index 4700054..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-package main
-
-import (
-       "errors"
-
-       "github.com/shazow/ssh-chat/chat"
-)
-
-// InitCommands adds host-specific commands to a Commands container.
-func InitCommands(h *Host, c *chat.Commands) {
-       c.Add(chat.Command{
-               Op:         true,
-               Prefix:     "/msg",
-               PrefixHelp: "USER MESSAGE",
-               Help:       "Send MESSAGE to USER.",
-               Handler: func(channel *chat.Channel, msg chat.CommandMsg) error {
-                       if !channel.IsOp(msg.From()) {
-                               return errors.New("must be op")
-                       }
-
-                       args := msg.Args()
-                       switch len(args) {
-                       case 0:
-                               return errors.New("must specify user")
-                       case 1:
-                               return errors.New("must specify message")
-                       }
-
-                       member, ok := channel.MemberById(chat.Id(args[0]))
-                       if !ok {
-                               return errors.New("user not found")
-                       }
-
-                       m := chat.NewPrivateMsg("hello", msg.From(), member.User)
-                       channel.Send(m)
-                       return nil
-               },
-       })
-}
diff --git a/host.go b/host.go
index d3510e712ec96b9e16371f7cc6debf1bed93761a..f2aa5f7198f6bb6d6a0817a9586c1802378d62b5 100644 (file)
--- a/host.go
+++ b/host.go
@@ -94,7 +94,7 @@ func (h *Host) Connect(term *sshd.Terminal) {
        term.SetPrompt(GetPrompt(user))
        h.count++
 
-       // Should the user be op'd?
+       // Should the user be op'd on join?
        member.Op = h.isOp(term.Conn)
 
        for {
@@ -191,7 +191,7 @@ func (h *Host) InitCommands(c *chat.Commands) {
                                return errors.New("user not found")
                        }
 
-                       m := chat.NewPrivateMsg(strings.Join(args[2:], " "), msg.From(), member.User)
+                       m := chat.NewPrivateMsg(strings.Join(args[1:], " "), msg.From(), member.User)
                        channel.Send(m)
                        return nil
                },
@@ -220,7 +220,7 @@ func (h *Host) InitCommands(c *chat.Commands) {
 
                        body := fmt.Sprintf("%s was kicked by %s.", member.Name(), msg.From().Name())
                        channel.Send(chat.NewAnnounceMsg(body))
-                       member.User.Close()
+                       member.Close()
                        return nil
                },
        })