diff --git a/cmd.go b/cmd.go index e244361..9a22209 100644 --- 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 index 4700054..0000000 --- a/command.go +++ /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 d3510e7..f2aa5f7 100644 --- 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 }, })