- [+] add AppMsgTypes

This commit is contained in:
Tong Sun 2021-07-31 22:55:53 -04:00
parent 1d0d2a1e2f
commit a132af0075
2 changed files with 87 additions and 2 deletions

62
appmessagetype_string.go Normal file
View File

@ -0,0 +1,62 @@
// Code generated by "stringer -type=AppMessageType -linecomment=true"; DO NOT EDIT.
package openwechat
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[AppMsgTypeText-1]
_ = x[AppMsgTypeImg-2]
_ = x[AppMsgTypeAudio-3]
_ = x[AppMsgTypeVideo-4]
_ = x[AppMsgTypeUrl-5]
_ = x[AppMsgTypeAttach-6]
_ = x[AppMsgTypeOpen-7]
_ = x[AppMsgTypeEmoji-8]
_ = x[AppMsgTypeVoiceRemind-9]
_ = x[AppMsgTypeScanGood-10]
_ = x[AppMsgTypeGood-13]
_ = x[AppMsgTypeEmotion-15]
_ = x[AppMsgTypeCardTicket-16]
_ = x[AppMsgTypeRealtimeShareLocation-17]
_ = x[AppMsgTypeTransfers-2000]
_ = x[AppMsgTypeRedEnvelopes-2001]
_ = x[AppMsgTypeReaderType-100001]
}
const (
_AppMessageType_name_0 = "文本消息图片消息语音消息视频消息文章消息附件消息Open表情消息VoiceRemindScanGood"
_AppMessageType_name_1 = "Good"
_AppMessageType_name_2 = "Emotion名片消息地理位置消息"
_AppMessageType_name_3 = "转账消息红包消息"
_AppMessageType_name_4 = "自定义的消息"
)
var (
_AppMessageType_index_0 = [...]uint8{0, 12, 24, 36, 48, 60, 72, 76, 88, 99, 107}
_AppMessageType_index_2 = [...]uint8{0, 7, 19, 37}
_AppMessageType_index_3 = [...]uint8{0, 12, 24}
)
func (i AppMessageType) String() string {
switch {
case 1 <= i && i <= 10:
i -= 1
return _AppMessageType_name_0[_AppMessageType_index_0[i]:_AppMessageType_index_0[i+1]]
case i == 13:
return _AppMessageType_name_1
case 15 <= i && i <= 17:
i -= 15
return _AppMessageType_name_2[_AppMessageType_index_2[i]:_AppMessageType_index_2[i+1]]
case 2000 <= i && i <= 2001:
i -= 2000
return _AppMessageType_name_3[_AppMessageType_index_3[i]:_AppMessageType_index_3[i+1]]
case i == 100001:
return _AppMessageType_name_4
default:
return "AppMessageType(" + strconv.FormatInt(int64(i), 10) + ")"
}
}

View File

@ -44,7 +44,11 @@ const (
// 详见 message_test.go
type MessageType int
// AppMessageType以Go惯用形式定义了PC微信所有的官方App消息类型。
type AppMessageType int
//go:generate stringer -type=MessageType -linecomment=true
//go:generate stringer -type=AppMessageType -linecomment=true
// https://res.wx.qq.com/a/wx_fed/webwx/res/static/js/index_c7d281c.js
// MSGTYPE_TEXT
@ -63,8 +67,6 @@ type MessageType int
// MSGTYPE_MICROVIDEO
// MSGTYPE_SYS
// MSGTYPE_RECALLED
// varcaser.Caser{
// From: varcaser.ScreamingSnakeCase, To: varcaser.UpperCamelCaseKeepCaps}
const (
MsgTypeText MessageType = 1 // 文本消息
@ -85,6 +87,27 @@ const (
MsgTypeRecalled MessageType = 10002 // 消息撤回
)
const (
AppMsgTypeText AppMessageType = 1 // 文本消息
AppMsgTypeImg AppMessageType = 2 // 图片消息
AppMsgTypeAudio AppMessageType = 3 // 语音消息
AppMsgTypeVideo AppMessageType = 4 // 视频消息
AppMsgTypeUrl AppMessageType = 5 // 文章消息
AppMsgTypeAttach AppMessageType = 6 // 附件消息
AppMsgTypeOpen AppMessageType = 7 // Open
AppMsgTypeEmoji AppMessageType = 8 // 表情消息
AppMsgTypeVoiceRemind AppMessageType = 9 // VoiceRemind
AppMsgTypeScanGood AppMessageType = 10 // ScanGood
AppMsgTypeGood AppMessageType = 13 // Good
AppMsgTypeEmotion AppMessageType = 15 // Emotion
AppMsgTypeCardTicket AppMessageType = 16 // 名片消息
AppMsgTypeRealtimeShareLocation AppMessageType = 17 // 地理位置消息
AppMsgTypeTransfers AppMessageType = 2000 // 转账消息
AppMsgTypeRedEnvelopes AppMessageType = 2001 // 红包消息
AppMsgTypeReaderType AppMessageType = 100001 //自定义的消息
)
// 登录状态
const (
statusSuccess = "200"