command_chat.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package client
  2. import (
  3. "encoding/json"
  4. _ "bet24.com/log"
  5. )
  6. // 发送聊天信息
  7. func SendChatMsg(channelID, userId, faceId, sex, vipLevel, recvID int,
  8. nickName, faceUrl, chatMsg, ipAddress string, msgType, vipExpire int) bool {
  9. msg := "SendChatMsg"
  10. var req Chat_req
  11. req.ChannelID = channelID
  12. req.SendUserID = userId
  13. req.Vip = vipLevel
  14. req.NickName = nickName
  15. req.FaceUrl = faceUrl
  16. req.FaceId = faceId
  17. req.Sex = sex
  18. req.RecvUserID = recvID
  19. req.ChatMsg = chatMsg
  20. req.IpAddress = ipAddress
  21. req.MsgType = msgType
  22. req.VipExpire = vipExpire
  23. d, _ := json.Marshal(req)
  24. resp := DoRequest(msg, string(d))
  25. return resp.RetCode == 1
  26. }
  27. // 获取聊天信息
  28. func GetChatMsg(userId, channelID int) string {
  29. msg := "GetChatMsg"
  30. var req Chat_Msg_req
  31. req.UserId = userId
  32. req.ChannelID = channelID
  33. d, _ := json.Marshal(req)
  34. resp := DoRequest(msg, string(d))
  35. return resp.Data
  36. }
  37. func SendChannelChat(from, to int, message string, msgType int) string {
  38. msg := "SendChannelChat"
  39. var req ChannelChat_req
  40. req.From = from
  41. req.To = to
  42. req.Message = message
  43. req.MsgType = msgType
  44. d, _ := json.Marshal(req)
  45. resp := DoRequest(msg, string(d))
  46. return resp.Data
  47. }
  48. func SendGiftMessage(from, to int, message string) string {
  49. msg := "SendGiftMessage"
  50. var req ChannelChat_req
  51. req.From = from
  52. req.To = to
  53. req.Message = message
  54. d, _ := json.Marshal(req)
  55. resp := DoRequest(msg, string(d))
  56. return resp.Data
  57. }
  58. func GetChannelChat(channelKey string, userId int) string {
  59. msg := "GetChannelChat"
  60. var req GetChannelChat_req
  61. req.UserId = userId
  62. req.ChannelKey = channelKey
  63. d, _ := json.Marshal(req)
  64. resp := DoRequest(msg, string(d))
  65. return resp.Data
  66. }
  67. func GetChannelInfo(channelKey string) string {
  68. msg := "GetChannelInfo"
  69. var req GetChannelChat_req
  70. req.ChannelKey = channelKey
  71. d, _ := json.Marshal(req)
  72. resp := DoRequest(msg, string(d))
  73. return resp.Data
  74. }
  75. func ClearChannelHistory(channelKey string, userId int) {
  76. msg := "ClearChannelHistory"
  77. var req GetChannelChat_req
  78. req.ChannelKey = channelKey
  79. req.UserId = userId
  80. d, _ := json.Marshal(req)
  81. DoRequest(msg, string(d))
  82. }
  83. func RemoveChannelChat(userId1, userId2 int) {
  84. msg := "RemoveChannelChat"
  85. var req GetChannelChat_req
  86. req.UserId = userId1
  87. req.UserId2 = userId2
  88. d, _ := json.Marshal(req)
  89. DoRequest(msg, string(d))
  90. }
  91. // 获取机器人聊天列表
  92. func GetRobotChatList() Response {
  93. msg := "GetRobotChatList"
  94. return DoRequest(msg, "")
  95. }
  96. // 获取机器人聊天信息
  97. func GetRobotChatInfo(userId int) Response {
  98. msg := "GetRobotChatInfo"
  99. var req Request_base
  100. req.UserId = userId
  101. d, _ := json.Marshal(req)
  102. return DoRequest(msg, string(d))
  103. }
  104. // 添加机器人聊天信息
  105. func AddRobotChatInfo(userId int, chatMsg string, seconds int, beginTime, endTime string) Response {
  106. msg := "AddRobotChatInfo"
  107. var req RobotChat_req
  108. req.UserId = userId
  109. req.Msg = chatMsg
  110. req.Seconds = seconds
  111. req.BeginTime = beginTime
  112. req.EndTime = endTime
  113. d, _ := json.Marshal(req)
  114. return DoRequest(msg, string(d))
  115. }
  116. // 修改机器人聊天信息
  117. func UpdateRobotChatInfo(userId int, chatMsg string, seconds int, beginTime, endTime string) Response {
  118. msg := "UpdateRobotChatInfo"
  119. var req RobotChat_req
  120. req.UserId = userId
  121. req.Msg = chatMsg
  122. req.Seconds = seconds
  123. req.BeginTime = beginTime
  124. req.EndTime = endTime
  125. d, _ := json.Marshal(req)
  126. return DoRequest(msg, string(d))
  127. }
  128. // 删除机器人聊天信息
  129. func DelRobotChatInfo(userId int) Response {
  130. msg := "DelRobotChatInfo"
  131. var req Request_base
  132. req.UserId = userId
  133. d, _ := json.Marshal(req)
  134. return DoRequest(msg, string(d))
  135. }