Skip to content

消息

因为有些动态字段需要使用power.HashMap来描述,本质上和gin.H{}这类对象是一样的。

import "github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/power"

文本消息

messages.NewText(ctx,"[content]")

微信官方文档

图片消息

messages.NewImage(ctx,"[mediaID]", &power.HashMap{})

微信官方文档

视频消息

messages.NewVideo(ctx,"[mediaID]", &power.HashMap{
  "title": "test title",
  "description": "test desc...",
  "thumb_media_id": "test thumb media id",
})

微信官方文档

声音消息

messages.NewVoice(ctx,mediaID, &power.HashMap{})

微信官方文档

链接消息

messages.NewLink(ctx,&power.HashMap{
  ctx,
  "title":       "ArtisanCloud",
  "description": "desc...",
  "url":         "https://www.artisan-cloud.com",
  "picurl":      "https://powerwechat.artisan-cloud.com/images/icons/favicon-32x32.png",
})

微信官方文档

原始消息

原始消息PowerWeChat这边会原样转发给微信,所以请注意保证字符串json是合法的。

openID := ""
content := ""
messages.NewRaw(`
  {
    "touser":"` + openID + `",
    "msgtype":"text",
    "text":{"content":"` + content + `"}"}}
`)

微信官方文档

消息 has loaded