chat.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package chat
  2. import "bet24.com/log"
  3. var mgr *chatmgr
  4. var chMgr *channelMgr
  5. func Run() {
  6. log.Debug("chat running")
  7. mgr = newChatMgr()
  8. chMgr = newChannelMgr()
  9. }
  10. func OnUserEnter(userId int) {
  11. chMgr.onUserEnter(userId)
  12. }
  13. func OnUserExit(userId int) {
  14. chMgr.onUserExit(userId)
  15. }
  16. func GetChatMsg(userId, channelID int) string {
  17. return mgr.getChatMsg(userId, channelID)
  18. }
  19. func SendChatMsg(channelID, userId, faceId, sex, vipLevel, recvID int,
  20. nickName, faceUrl, chatMsg, ipAddress string, messageType, vipExpire int) bool {
  21. return mgr.sendChatMsg(channelID, userId, faceId, sex, vipLevel, recvID, nickName, faceUrl, chatMsg, ipAddress, false, messageType, vipExpire)
  22. }
  23. func Dump(param1, param2 string) {
  24. if param1 == "world" {
  25. mgr.dump(param2)
  26. return
  27. }
  28. chMgr.dump(param1, param2)
  29. }
  30. func SendChannelChat(from, to int, msg string, msgType int) string {
  31. return chMgr.sendChat(from, to, msg, msgType)
  32. }
  33. func GetChannelChat(channelKey string, userId int) string {
  34. return chMgr.getChat(channelKey, userId)
  35. }
  36. func GetChannelInfo(channelKey string) string {
  37. return chMgr.getChannelInfo(channelKey)
  38. }
  39. func ClearChannelHistory(channelKey string, userId int) {
  40. chMgr.userClear(channelKey, userId)
  41. }
  42. // 获取机器人聊天列表
  43. func GetRobotChatList() []robot_chat {
  44. return mgr.getRobotChatList()
  45. }
  46. // 获取机器人聊天信息
  47. func GetRobotChatInfo(userId int) robot_chat {
  48. return mgr.getRobotChatInfo(userId)
  49. }
  50. // 添加机器人聊天信息
  51. func AddRobotChatInfo(userId int, msg string, seconds int, beginTime, endTime string) bool {
  52. return mgr.addRobotChat(userId, msg, seconds, beginTime, endTime)
  53. }
  54. // 修改机器人聊天信息
  55. func UpdateRobotChatInfo(userId int, msg string, seconds int, beginTime, endTime string) bool {
  56. return mgr.updateRobotChat(userId, msg, seconds, beginTime, endTime)
  57. }
  58. // 删除机器人聊天信息
  59. func DelRobotChatInfo(userId int) bool {
  60. return mgr.delRobotChat(userId)
  61. }
  62. func SendGiftMessage(from, to int, msg string) string {
  63. return chMgr.sendGiftMsg(from, to, msg)
  64. }
  65. func RemoveChannel(userId1, userId2 int) {
  66. chMgr.removeChannel(userId1, userId2)
  67. }