Skip to content

Commit c8661e6

Browse files
committed
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 <[email protected]> Date: Wed Aug 3 17:58:37 2016 -0400 motd: Refactor inner conditions commit ac28c8cb4e8dc2a0d23abe3dcf52b69175cde51b Author: Aaron <[email protected]> Date: Tue Aug 2 09:38:36 2016 +0300 Fix small issues with the help message commit a80ae77e1d691a4ec7125be5441d4f6eea767a75 Author: Aaron <[email protected]> Date: Tue Aug 2 09:30:21 2016 +0300 Print the motd if no parameters are passed commit 2db1b3c123661cdbd622d5ba2ff81ede8cb8a951 Author: Aaron <[email protected]> Date: Tue Aug 2 09:29:41 2016 +0300 Update the motd command's description
1 parent 13ea34b commit c8661e6

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

host.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,21 @@ func (h *Host) InitCommands(c *chat.Commands) {
425425
c.Add(chat.Command{
426426
Op: true,
427427
Prefix: "/motd",
428-
PrefixHelp: "MESSAGE",
429-
Help: "Set the MESSAGE of the day.",
428+
PrefixHelp: "[MESSAGE]",
429+
Help: "Set a new MESSAGE of the day, print the current motd without parameters.",
430430
Handler: func(room *chat.Room, msg message.CommandMsg) error {
431-
if !room.IsOp(msg.From()) {
432-
return errors.New("must be op")
431+
args := msg.Args()
432+
user := msg.From()
433+
motd := h.motd
434+
435+
if len(args) == 0 {
436+
room.Send(message.NewSystemMsg(motd, user))
437+
return nil
438+
}
439+
if !room.IsOp(user) {
440+
return errors.New("must be OP to modify the MOTD")
433441
}
434442

435-
motd := ""
436-
args := msg.Args()
437443
if len(args) > 0 {
438444
motd = strings.Join(args, " ")
439445
}
@@ -444,7 +450,6 @@ func (h *Host) InitCommands(c *chat.Commands) {
444450
if motd != "" {
445451
room.Send(message.NewAnnounceMsg(motd))
446452
}
447-
448453
return nil
449454
},
450455
})

identity.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func (i Identity) Whois() string {
4545
if i.PublicKey() != nil {
4646
fingerprint = sshd.Fingerprint(i.PublicKey())
4747
}
48+
// TODO: Include time joined, client, etc.
4849
return fmt.Sprintf("name: %s"+message.Newline+
4950
" > ip: %s"+message.Newline+
5051
" > fingerprint: %s", i.Name(), ip, fingerprint)

0 commit comments

Comments
 (0)