mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-18 17:57:41 +03:00
Bugfixen.
This commit is contained in:
parent
e626eab624
commit
723313bcb2
2
cmd.go
2
cmd.go
@ -60,7 +60,7 @@ func main() {
|
|||||||
// Figure out the log level
|
// Figure out the log level
|
||||||
numVerbose := len(options.Verbose)
|
numVerbose := len(options.Verbose)
|
||||||
if numVerbose > len(logLevels) {
|
if numVerbose > len(logLevels) {
|
||||||
numVerbose = len(logLevels)
|
numVerbose = len(logLevels) - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
logLevel := logLevels[numVerbose]
|
logLevel := logLevels[numVerbose]
|
||||||
|
39
command.go
39
command.go
@ -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
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
6
host.go
6
host.go
@ -94,7 +94,7 @@ func (h *Host) Connect(term *sshd.Terminal) {
|
|||||||
term.SetPrompt(GetPrompt(user))
|
term.SetPrompt(GetPrompt(user))
|
||||||
h.count++
|
h.count++
|
||||||
|
|
||||||
// Should the user be op'd?
|
// Should the user be op'd on join?
|
||||||
member.Op = h.isOp(term.Conn)
|
member.Op = h.isOp(term.Conn)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -191,7 +191,7 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
|||||||
return errors.New("user not found")
|
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)
|
channel.Send(m)
|
||||||
return nil
|
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())
|
body := fmt.Sprintf("%s was kicked by %s.", member.Name(), msg.From().Name())
|
||||||
channel.Send(chat.NewAnnounceMsg(body))
|
channel.Send(chat.NewAnnounceMsg(body))
|
||||||
member.User.Close()
|
member.Close()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user