Example #1
0
func (mcs *mcStatus) Topic(ctx *bot.Context) {
	ch := mcConf.String(mcChan)
	if ctx.Args[1] != ch {
		return
	}
	topic := ctx.Text()
	if idx := strings.Index(topic, " || "); idx == -1 {
		topic = ""
	} else {
		topic = topic[idx:]
	}
	players := ""
	if len(mcs.players) > 0 {
		players = ": " + strings.Join(mcs.players, ", ")
	}
	topic = fmt.Sprintf("%s %s v%s [%s/%s%s]%s", mcs.motd,
		mcConf.String(mcServer), mcs.version, mcs.nump, mcs.maxp, players, topic)
	if topic != ctx.Text() {
		ctx.Topic(ch, topic)
	}
}