1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package hook
- import "fmt"
- // 开启/关闭实时消息接收功能
- func (h *Hook) ConfigureMsgRecive(isEnable string, url string) (err error) {
- resp, err := h.Client.R().SetBody(&ConfigureMsgReciveReq{
- IsEnable: isEnable,
- URL: url,
- }).Post("http://" + h.ServerIp + ":" + h.WxPort + "/ConfigureMsgRecive")
- if err != nil {
- return
- }
- if !resp.IsSuccessState() {
- err = fmt.Errorf("ConfigureMsgRecive failed with status code %d", resp.StatusCode)
- return
- }
- return
- }
- // 发送微信文本消息
- func (h *Hook) SendTextMsg(wxid, msg string) (err error) {
- resp, err := h.Client.R().SetBody(&SendTextMsgReq{
- Wxid: wxid,
- Msg: msg,
- }).Post("http://" + h.ServerIp + ":" + h.WxPort + "/SendTextMsg")
- if err != nil {
- return
- }
- if !resp.IsSuccessState() {
- err = fmt.Errorf("SendTextMsg failed with status code %d", resp.StatusCode)
- return
- }
- return
- }
- // 发送微信图片
- func (h *Hook) SendPicMsg(wxid, picpath, diyfilename string) (err error) {
- resp, err := h.Client.R().SetBody(&SendPicMsgReq{
- Wxid: wxid,
- Picpath: picpath,
- Diyfilename: diyfilename,
- }).Post("http://" + h.ServerIp + ":" + h.WxPort + "/SendPicMsg")
- if err != nil {
- return
- }
- if !resp.IsSuccessState() {
- err = fmt.Errorf("SendPicMsg failed with status code %d", resp.StatusCode)
- return
- }
- return
- }
- // 发送微信图片(本地测试)
- func (h *Hook) SendPicMsgLocal(wxid, picpath string) (err error) {
- resp, err := h.Client.R().SetBody(&SendPicMsgLocalReq{
- Wxid: wxid,
- Picpath: picpath,
- }).Post("http://" + h.ServerIp + ":" + h.WxPort + "/SendPicMsg")
- if err != nil {
- return
- }
- if !resp.IsSuccessState() {
- err = fmt.Errorf("SendPicMsgLocal failed with status code %d", resp.StatusCode)
- return
- }
- return
- }
|