80 lines
2.5 KiB
Go
80 lines
2.5 KiB
Go
|
package wxhelper
|
||
|
|
||
|
// WeChatVersion 微信版本
|
||
|
type WeChatVersion int
|
||
|
|
||
|
// 微信版本
|
||
|
const (
|
||
|
WechatVersion39223 WeChatVersion = 39223
|
||
|
WechatVersion39581 WeChatVersion = 39581
|
||
|
WechatVersion39825 WeChatVersion = 39825
|
||
|
)
|
||
|
|
||
|
// 接口映射
|
||
|
var apiMap = map[WeChatVersion]map[string]string{
|
||
|
WechatVersion39223: v39223ApiMap,
|
||
|
WechatVersion39581: v39581ApiMap,
|
||
|
WechatVersion39825: v39581ApiMap,
|
||
|
}
|
||
|
|
||
|
var v39223ApiMap = map[string]string{
|
||
|
"CheckLogin": "/api/?type=0",
|
||
|
"UserInfo": "/api/?type=1",
|
||
|
"SendTextMsg": "/api/?type=2",
|
||
|
"SendAtTest": "/api/?type=3",
|
||
|
"SendFileMsg": "/api/?type=6",
|
||
|
"SendImagesMsg": "/api/?type=5",
|
||
|
"SendCustomEmotionMsg": "",
|
||
|
"GetContactList": "/api/?type=46",
|
||
|
"GetChatRoomDetailInfo": "/api/?type=47",
|
||
|
"AddMemberToChatRoom": "/api/?type=28",
|
||
|
"DelMemberFromChatRoom": "/api/?type=27",
|
||
|
"GetMemberFromChatRoom": "/api/?type=25",
|
||
|
"GetContactProfile": "/api/?type=25",
|
||
|
"InviteMemberToChatRoom": "",
|
||
|
"ModifyChatRoomNickname": "/api/?type=31",
|
||
|
"StartHook": "/api/?type=9",
|
||
|
"StopHook": "/api/?type=10",
|
||
|
"DownloadAttach": "/api/?type=56",
|
||
|
"DecodeImage": "/api/?type=48",
|
||
|
}
|
||
|
|
||
|
var v39581ApiMap = map[string]string{
|
||
|
"CheckLogin": "/api/checkLogin",
|
||
|
"UserInfo": "/api/userInfo",
|
||
|
"SendTextMsg": "/api/sendTextMsg",
|
||
|
"SendAtTest": "/api/sendAtText",
|
||
|
"SendFileMsg": "/api/sendFileMsg",
|
||
|
"SendImagesMsg": "/api/sendImagesMsg",
|
||
|
"SendCustomEmotionMsg": "/api/sendCustomEmotion",
|
||
|
"GetContactList": "/api/getContactList",
|
||
|
"GetChatRoomDetailInfo": "/api/getChatRoomDetailInfo",
|
||
|
"AddMemberToChatRoom": "/api/addMemberToChatRoom",
|
||
|
"DelMemberFromChatRoom": "/api/delMemberFromChatRoom",
|
||
|
"GetMemberFromChatRoom": "/api/getMemberFromChatRoom",
|
||
|
"GetContactProfile": "/api/getContactProfile",
|
||
|
"InviteMemberToChatRoom": "/api/InviteMemberToChatRoom",
|
||
|
"ModifyChatRoomNickname": "/api/modifyNickname",
|
||
|
"QuitChatRoom": "/api/quitChatRoom",
|
||
|
"StartHook": "/api/hookSyncMsg",
|
||
|
"StopHook": "/api/unhookSyncMsg",
|
||
|
"DownloadAttach": "/api/downloadAttach",
|
||
|
"DecodeImage": "/api/decodeImage",
|
||
|
}
|
||
|
|
||
|
// GetApi
|
||
|
// @description: 获取接口地址
|
||
|
// @receiver v
|
||
|
// @return string
|
||
|
func (v WeChatVersion) GetApi(code string) (api string, ok bool) {
|
||
|
var am map[string]string
|
||
|
// 判断版本是否支持
|
||
|
if am, ok = apiMap[v]; !ok {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// 获取接口
|
||
|
api, ok = am[code]
|
||
|
return
|
||
|
}
|