Changeset 636 in code for trunk/irc.go


Ignore:
Timestamp:
Oct 13, 2021, 8:58:34 AM (4 years ago)
Author:
contact
Message:

Add bouncer MOTD

Closes: https://todo.sr.ht/~emersion/soju/137

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/irc.go

    r516 r636  
    380380}
    381381
     382func generateMOTD(prefix *irc.Prefix, nick string, motd string) []*irc.Message {
     383        var msgs []*irc.Message
     384        msgs = append(msgs, &irc.Message{
     385                Prefix:  prefix,
     386                Command: irc.RPL_MOTDSTART,
     387                Params:  []string{nick, fmt.Sprintf("- Message of the Day -")},
     388        })
     389
     390        for _, l := range strings.Split(motd, "\n") {
     391                msgs = append(msgs, &irc.Message{
     392                        Prefix:  prefix,
     393                        Command: irc.RPL_MOTD,
     394                        Params:  []string{nick, l},
     395                })
     396        }
     397
     398        msgs = append(msgs, &irc.Message{
     399                Prefix:  prefix,
     400                Command: irc.RPL_ENDOFMOTD,
     401                Params:  []string{nick, "End of /MOTD command."},
     402        })
     403
     404        return msgs
     405}
     406
    382407type joinSorter struct {
    383408        channels []string
Note: See TracChangeset for help on using the changeset viewer.