Skip to content

Commit

Permalink
motd: Allow for reading the current motd when no additional args given.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shazow committed Aug 3, 2016
1 parent 13ea34b commit c8661e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
19 changes: 12 additions & 7 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, " ")
}
Expand All @@ -444,7 +450,6 @@ func (h *Host) InitCommands(c *chat.Commands) {
if motd != "" {
room.Send(message.NewAnnounceMsg(motd))
}

return nil
},
})
Expand Down
1 change: 1 addition & 0 deletions identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c8661e6

Please sign in to comment.