Bugfixen.

This commit is contained in:
Andrey Petrov 2015-01-10 19:48:17 -08:00
parent e626eab624
commit 723313bcb2
3 changed files with 4 additions and 43 deletions

2
cmd.go
View File

@ -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]

View File

@ -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
},
})
}

View File

@ -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
},
})