mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-12 23:27:17 +03:00
motd: Allow for reading the current motd when no additional args given.
Closes #155, merges #157 Squashed commit of the following: commit bcb0810637c99223753629a2e55169b07ee9fe51 Author: Andrey Petrov <andrey.petrov@shazow.net> Date: Wed Aug 3 17:58:37 2016 -0400 motd: Refactor inner conditions commit ac28c8cb4e8dc2a0d23abe3dcf52b69175cde51b Author: Aaron <aaron.ounn@gmail.com> Date: Tue Aug 2 09:38:36 2016 +0300 Fix small issues with the help message commit a80ae77e1d691a4ec7125be5441d4f6eea767a75 Author: Aaron <aaron.ounn@gmail.com> Date: Tue Aug 2 09:30:21 2016 +0300 Print the motd if no parameters are passed commit 2db1b3c123661cdbd622d5ba2ff81ede8cb8a951 Author: Aaron <aaron.ounn@gmail.com> Date: Tue Aug 2 09:29:41 2016 +0300 Update the motd command's description
This commit is contained in:
parent
13ea34b912
commit
c8661e6883
19
host.go
19
host.go
@ -425,15 +425,21 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
||||
c.Add(chat.Command{
|
||||
Op: true,
|
||||
Prefix: "/motd",
|
||||
PrefixHelp: "MESSAGE",
|
||||
Help: "Set the MESSAGE of the day.",
|
||||
PrefixHelp: "[MESSAGE]",
|
||||
Help: "Set a new MESSAGE of the day, print the current motd without parameters.",
|
||||
Handler: func(room *chat.Room, msg message.CommandMsg) error {
|
||||
if !room.IsOp(msg.From()) {
|
||||
return errors.New("must be op")
|
||||
args := msg.Args()
|
||||
user := msg.From()
|
||||
motd := h.motd
|
||||
|
||||
if len(args) == 0 {
|
||||
room.Send(message.NewSystemMsg(motd, user))
|
||||
return nil
|
||||
}
|
||||
if !room.IsOp(user) {
|
||||
return errors.New("must be OP to modify the MOTD")
|
||||
}
|
||||
|
||||
motd := ""
|
||||
args := msg.Args()
|
||||
if len(args) > 0 {
|
||||
motd = strings.Join(args, " ")
|
||||
}
|
||||
@ -444,7 +450,6 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
||||
if motd != "" {
|
||||
room.Send(message.NewAnnounceMsg(motd))
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
})
|
||||
|
@ -45,6 +45,7 @@ func (i Identity) Whois() string {
|
||||
if i.PublicKey() != nil {
|
||||
fingerprint = sshd.Fingerprint(i.PublicKey())
|
||||
}
|
||||
// TODO: Include time joined, client, etc.
|
||||
return fmt.Sprintf("name: %s"+message.Newline+
|
||||
" > ip: %s"+message.Newline+
|
||||
" > fingerprint: %s", i.Name(), ip, fingerprint)
|
||||
|
Loading…
x
Reference in New Issue
Block a user