package getweb

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

func init() {
	handler.RegisterHandler("getweb", getweb)
}

func getweb(msg model.Message) (reply model.Reply) {
	if len(msg.Msg) <= len("getweb ") {
		return model.Reply{}
	}
	url := msg.Msg[len("getweb "):]
	if err := util.ScreenshotURL(url, "./tmp/getweb/url.png", 1920, 1080, 0, 0, 0, 0, ""); err != nil {
		return model.Reply{
			ReplyMsg:       err.Error(),
			ReferOriginMsg: true,
			FromMsg:        msg,
		}
	}
	return model.Reply{
		ReplyMsg:       "[CQ:image,file=file:///root/qqbot/tmp/getweb/url.png]",
		ReferOriginMsg: true,
		FromMsg:        msg,
	}
}
