mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-13 15:47: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{
|
c.Add(chat.Command{
|
||||||
Op: true,
|
Op: true,
|
||||||
Prefix: "/motd",
|
Prefix: "/motd",
|
||||||
PrefixHelp: "MESSAGE",
|
PrefixHelp: "[MESSAGE]",
|
||||||
Help: "Set the MESSAGE of the day.",
|
Help: "Set a new MESSAGE of the day, print the current motd without parameters.",
|
||||||
Handler: func(room *chat.Room, msg message.CommandMsg) error {
|
Handler: func(room *chat.Room, msg message.CommandMsg) error {
|
||||||
if !room.IsOp(msg.From()) {
|
args := msg.Args()
|
||||||
return errors.New("must be op")
|
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 {
|
if len(args) > 0 {
|
||||||
motd = strings.Join(args, " ")
|
motd = strings.Join(args, " ")
|
||||||
}
|
}
|
||||||
@ -444,7 +450,6 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
|||||||
if motd != "" {
|
if motd != "" {
|
||||||
room.Send(message.NewAnnounceMsg(motd))
|
room.Send(message.NewAnnounceMsg(motd))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -45,6 +45,7 @@ func (i Identity) Whois() string {
|
|||||||
if i.PublicKey() != nil {
|
if i.PublicKey() != nil {
|
||||||
fingerprint = sshd.Fingerprint(i.PublicKey())
|
fingerprint = sshd.Fingerprint(i.PublicKey())
|
||||||
}
|
}
|
||||||
|
// TODO: Include time joined, client, etc.
|
||||||
return fmt.Sprintf("name: %s"+message.Newline+
|
return fmt.Sprintf("name: %s"+message.Newline+
|
||||||
" > ip: %s"+message.Newline+
|
" > ip: %s"+message.Newline+
|
||||||
" > fingerprint: %s", i.Name(), ip, fingerprint)
|
" > fingerprint: %s", i.Name(), ip, fingerprint)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user