package xibao

import (
	"git.lxtend.com/qqbot/handler"
	"git.lxtend.com/qqbot/model"
	"git.lxtend.com/qqbot/service/xibao"
)

func init() {
	handler.RegisterHandler("喜报", xiBao)
	handler.RegisterHandler("悲报", beiBao)
}

func xiBao(msg model.Message) (reply model.Reply) {
	xibao.GenerateCongratulationImage(msg.RawMsg[len("喜报 "):], "./resource/xibao_background.png", "./tmp/xibao.png", true)
	return model.Reply{
		ReplyMsg:       "[CQ:image,file=file:///root/qqbot/tmp/xibao.png]",
		ReferOriginMsg: true,
		FromMsg:        msg,
	}
}

func beiBao(msg model.Message) (reply model.Reply) {
	xibao.GenerateCongratulationImage(msg.RawMsg[len("悲报 "):], "./resource/beibao_background.png", "./tmp/beibao.png", false)
	return model.Reply{
		ReplyMsg:       "[CQ:image,file=file:///root/qqbot/tmp/beibao.png]",
		ReferOriginMsg: true,
		FromMsg:        msg,
	}
}
