源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1664 lines
61 KiB

  1. ChatModel = ChatModel or BaseClass(BaseModel)
  2. ChatModel.SELECT_CHAT_VIEW_TARBAR = "SELECT_CHAT_VIEW_TARBAR"
  3. ChatModel.SELECT_FACE_ITEM = "SELECT_FACE_ITEM"
  4. ChatModel.SELECT_TEXT_FACE_ITEM = "SELECT_TEXT_FACE_ITEM"
  5. ChatModel.SELECT_HISTROY_ITEM = "SELECT_HISTROY_ITEM"
  6. ChatModel.SELECT_GOOD_ITEM = "SELECT_GOOD_ITEM"
  7. ChatModel.SELECT_PARTNER_ITEM = "SELECT_PARTNER_ITEM"
  8. ChatModel.SELECT_COORD_ITEM = "SELECT_COORD_ITEM"
  9. ChatModel.DELETE_CECRET_CHAT_ITEM = "DELETE_CECRET_CHAT_ITEM"
  10. ChatModel.SELECT_OTHER_PLAYER = "ChatModel.SELECT_OTHER_PLAYER" -- 算中其他玩家item
  11. ChatModel.SEND_MSG = "ChatModel.SEND_MSG" --发送消息
  12. ChatModel.ADD_NEW_MSG = "ADD_NEW_MSG"
  13. ChatModel.SHOW_TAB_RED_POINT = "ChatModel.SHOW_TAB_RED_POINT" -- 显示标签红点
  14. ChatModel.CHANGE_CHANNEL_SEND_INTERVAL = "ChatModel.CHANGE_CHANNEL_SEND_INTERVAL" -- 改变发送间隔
  15. ChatModel.UPDATE_SEND_TIME = "UPDATE_SEND_TIME"
  16. ChatModel.REFRESH_FRIEND = "REFRESH_FRIEND"
  17. ChatModel.REFRESH_MEMBER = "REFRESH_MEMBER"
  18. ChatModel.CLEAR_DATA = "CLEAR_DATA"
  19. ChatModel.SHOW_LINE_TIME = 60 * 30 --说话间隔大于该时间 就要添加横线时间显示项
  20. ChatModel.PLAY_VOICE = "PLAY_VOICE"--语音播放事件
  21. ChatModel.UPDATE_INDIVID_VIEW = "ChatModel.UPDATE_INDIVID_VIEW" --表情界面更新
  22. ChatModel.SEND_MSG_IN_VIEW = "ChatModel.SEND_MSG_IN_VIEW" --通过聊天界面发送内容
  23. ChatModel.UPDATE_HORNTV_NUM = "ChatModel.UPDATE_HORNTV_NUM" --更新喇叭排队数量
  24. ChatModel.SHOW_BAG_SELECT_BG = "ChatModel.SHOW_BAG_SELECT_BG" --显示背包选中图片
  25. ChatModel.REFRESH_VIEW = "ChatModel.REFRESH_VIEW" --刷新界面
  26. ChatModel.DEL_CHAT_ITEM = "ChatModel.DEL_CHAT_ITEM" --删除聊天
  27. ChatModel.DEL_NOTICE_CHAT_ITEM = "ChatModel.DEL_NOTICE_CHAT_ITEM" --删除公告聊天
  28. ChatModel.CROSS_HORN_HAS_CHANGE = "ChatModel.CROSS_HORN_HAS_CHANGE" --跨服喇叭数量变化
  29. ChatModel.HORN_HAS_CHANGE = "ChatModel.HORN_HAS_CHANGE" --喇叭数量变化
  30. ChatModel.SAVE_CHAT_HISTORY_INFO = "ChatModel.SAVE_CHAT_HISTORY_INFO" --保存历史输入
  31. ChatModel.SELECT_HISTORY_TEXT_ITEM = "ChatModel.SELECT_HISTORY_TEXT_ITEM" --点击历史item
  32. ChatModel.SAVE_MAINUI_CHAT_HISTORY_INFO = "ChatModel.SAVE_MAINUI_CHAT_HISTORY_INFO" --主界面UI聊天记录
  33. ChatModel.CLICK_POS_BTN = "ChatModel.CLICK_POS_BTN" --点击坐标按钮
  34. ChatModel.HIDE_MIAN_UI_CHAT_VIEW = "ChatModel.HIDE_MIAN_UI_CHAT_VIEW" --关闭打开聊天主界面的 处理表情包bug
  35. ChatModel.INIT_FIRST_GAME_CHAT_DATA = "ChatModel.INIT_FIRST_GAME_CHAT_DATA"
  36. ChatModel.SEND_PROTOCAL = "ChatModel.SEND_PROTOCAL" --发送协议
  37. ChatModel.CHANGE_HEIGHT = "ChatModel.CHANGE_HEIGHT" --高度计算用
  38. ChatModel.Update_MAINUI_GUILD_MSG_RED = "ChatModel.Update_MAINUI_GUILD_MSG_RED" -- 更新主界面社团红点
  39. --ChatModel.MIAN_UI_CHAT_VIEW_LOADED = "ChatModel.MIAN_UI_CHAT_VIEW_LOADED" --左下加载完毕
  40. --如果这边键值对改变的话 MainUIModel.VoiceType 这边也要对应调整
  41. ChatModel.CHANNEL_GENERAL = 99 --综合频道
  42. ChatModel.CHANNEL_SYSTEM = 10 --系统
  43. ChatModel.CHANNEL_WORLD = 1 --世界
  44. ChatModel.CHANNEL_HORN = 2 --喇叭
  45. ChatModel.CHANNEL_NEAR = 3 --区域
  46. ChatModel.CHANNEL_GUILD = 4 --社团
  47. ChatModel.CHANNEL_TEAM = 5 --队伍
  48. ChatModel.CHANNEL_CECRET = 6 --私聊频道
  49. ChatModel.CHANNEL_INVITE = 11 --组队(招募)频道(用于发布组队邀请)
  50. ChatModel.CHANNEL_BARRAGE = 12--弹幕聊天(只针对活动场景的聊天)
  51. ChatModel.CHANNEL_CROSS = 13 --跨服聊天
  52. ChatModel.CHANNEL_REPLY = 14 --答题频道
  53. ChatModel.CHANNEL_3V3_TEAM = 15 --3v3
  54. ChatModel.CHANNEL_1VN = 16 --1vN频道
  55. ChatModel.CHANNEL_BEACH = 17 --温泉
  56. ChatModel.CHANNEL_GUILDTV = 19 --跑马弹幕频道
  57. ChatModel.CHANNEL_GUARDIAN_THREE = 20 --绝地守卫频道
  58. ChatModel.CHANNEL_COUNTRY = 21 -- 本国跨服频道
  59. ChatModel.ALL = 90 -- 显示“世界” “招募” “社团” “队伍”
  60. ChatModel.CHANNEL_NONE = 0 --无
  61. --把频道放进列表,主界面顺序滑动切换(暂时弃用)
  62. ChatModel.CHANNEL_MAINUI_SHOW =
  63. {
  64. [1] = ChatModel.ALL,
  65. [2] = ChatModel.CHANNEL_WORLD,
  66. [3] = ChatModel.CHANNEL_GUILD,
  67. [4] = ChatModel.CHANNEL_INVITE,
  68. [5] = ChatModel.CHANNEL_TEAM,
  69. [6] = ChatModel.CHANNEL_SYSTEM
  70. -- [7] = ChatModel.CHANNEL_CROSS
  71. }
  72. -- info 里的 chuanwen_type (后端是这样定的)
  73. -- 1:传闻跑马灯飘(屏幕上方)、2:频道普通消息、
  74. -- 3:传闻跑马灯中部(屏幕中部)、4:玩法活动横幅
  75. ChatModel.CHUANWEN_TYPE = {
  76. UP_CHUANWEN = 1,
  77. NORMAL = 2,
  78. MIDDLE_CHUANWEN = 3,
  79. ACTIVITY_CHUANWEN = 4,
  80. }
  81. --11001--is_mySelf_send
  82. ChatModel.CHAT_COMMON_TYPE = {
  83. COMMON = 0,
  84. SYSTEM = 1,
  85. }
  86. ChatModel.INDIVIDUATION_FACE = 1
  87. ChatModel.INDIVIDUATION_TEXT = 3
  88. ChatModel.INDIVIDUATION_ITEM = 5
  89. ChatModel.INDIVIDUATION_PARTNER = 2
  90. ChatModel.INDIVIDUATION_POS = 4
  91. ChatModel.INDIVIDUATION_HISTROY = 6
  92. ChatModel.REQUEST_CCMD_EVENT = "ChatModel.REQUEST_CCMD_EVENT"--请求协议
  93. ChatModel.REQUEST_CACHE_EVENT = "ChatModel.REQUEST_CACHE_EVENT"--请求缓存协议
  94. ChatModel.ON_RESULT_OF_SPEECH = "ChatModel.ON_RESULT_OF_SPEECH"--语音SDK识别结果返回
  95. ChatModel.ON_END_OF_SPEECH = "ChatModel.ON_END_OF_SPEECH"--语音SDK录制结果返回
  96. ChatModel.BROADCAST_VOICE_TEXT = "ChatModel.BROADCAST_VOICE_TEXT"--广播语音文字
  97. ChatModel.WORLD_CHAT_ITEM_ID = 240202--世界聊天消耗的道具
  98. ChatModel.STOP_VOICE_PLAY = "ChatModel.STOP_VOICE_PLAY"
  99. ChatModel.CHANGE_LIMIT_WAY = "ChatModel.CHANGE_LIMIT_WAY" --改变频道屏蔽选项
  100. ChatModel.ADD_MAINUI_WELCOME_HORN = "ChatModel.ADD_MAINUI_WELCOME_HORN" --主界面喇叭显示用语添加
  101. ChatModel.Bubble = 1 --气泡
  102. ChatModel.Photo = 2 --相框
  103. ChatModel.MAX_LEN_LIST =
  104. {
  105. [ChatModel.CHANNEL_GENERAL] = 30,
  106. [ChatModel.CHANNEL_SYSTEM] = 30,
  107. [ChatModel.CHANNEL_WORLD] = 30,
  108. [ChatModel.CHANNEL_GUILD] = 30,
  109. [ChatModel.CHANNEL_TEAM] = 30,
  110. [ChatModel.CHANNEL_CECRET] = 20,
  111. [ChatModel.CHANNEL_HORN] = 30,
  112. [ChatModel.CHANNEL_NEAR] = 30,
  113. [ChatModel.CHANNEL_INVITE] = 30,
  114. [ChatModel.CHANNEL_CROSS] = 30,
  115. [ChatModel.CHANNEL_COUNTRY] = 30,
  116. [ChatModel.CHANNEL_REPLY] = 30,
  117. [ChatModel.CHANNEL_3V3_TEAM] = 30,
  118. [ChatModel.CHANNEL_1VN] = 30,
  119. [ChatModel.CHANNEL_GUILDTV] = 20,
  120. [ChatModel.CHANNEL_BEACH] = 20,
  121. [ChatModel.CHANNEL_GUARDIAN_THREE] = 20,
  122. }
  123. ChatModel.MSG_TYPE = {
  124. TEXT = 1,
  125. VOICE = 2,
  126. }
  127. ChatModel.LIMIY_WAY = {
  128. CHAT = 1,
  129. BABY = 2,
  130. RECRUIT = 3 --招募
  131. }
  132. ChatModel.LIMIY_WAY_NAME = {
  133. [1] = "屏蔽聊天",
  134. [2] = "屏蔽晒娃",
  135. [3] = "屏蔽招募"
  136. } --玩家屏蔽频道列表
  137. ChatModel.RedPointType = { -- 11016协议的红点类型
  138. GUILD_APPLY_LIST = 1,
  139. }
  140. function ChatModel:__init()
  141. ChatModel.Instance = self
  142. self.tv_state = true
  143. self.tv_list = {}
  144. self.selected_chatView_tabbar_item = nil
  145. self.selected_histroy_item = nil
  146. self.selected_textface_item = nil
  147. self.selected_face_item = nil
  148. self.selected_partner_item = nil
  149. self.selected_good_item = nil
  150. self.clicked_item = nil --点击超链接item(包括mainui)
  151. self.clicked_role_item = nil --点击人物菜单
  152. self.main_role_chat_list = ChatModel:GetAllMainRoleContent() or {} --缓存玩家聊天记录 --最大20条
  153. self.send_timer_list = {} --用来缓存所有发送时间间隔Timer
  154. self.send_start_time_list = {} --用来缓存所有频道的发送时间间隔
  155. self.request_cache = false -- 是否已经请求缓存信息
  156. self.curr_channel = 0 --当前频道 -- 这个是玩家选择tab后更新的
  157. self.chating_key_id = 0 -- 当前密聊玩家的值
  158. self.pre_bar_index = 0 --上一个tabbar的索引
  159. self.curr_bar_index = ChatModel.CHANNEL_WORLD -- 当前tabbar的索引 -- 这个curr_bar_index是外边主界面传进来的,这个为主
  160. self.world_chat_method = 0 -- 世界聊天发言的方式,可能通过次数或者道具 0 次数 1 道具
  161. self.chat_args_dic = {} --当前聊天内容所需发送的参数列表 [类型,列表[参数]]
  162. self.chick_hyperlink_mark = false
  163. self.curr_individuation_bar_index = 1
  164. self.reg_channel = 0
  165. self.voice_id = 0
  166. self.voice_path = 0
  167. self.cecret_chat_list = {} --密聊列表
  168. self.all_chat_list = {} -- 用来记录每个频道的数据
  169. self.all_chat_list_count = {} -- 用来记录每个频道收到的消息的数量,用来显示红点
  170. self.check_timer_list = {}
  171. self.delay_timer_list = {}
  172. self.gonggao_vo = nil
  173. self.delay_horn_list = {}
  174. self.say_cache = nil
  175. self.need_feast_chat = false
  176. self.chat_bag_view_is_open = false
  177. self.last_Gg_list = {} --用来记录上一次的公告数据
  178. self.require_11010_times = 4
  179. self.limit_way_list = {} --频道屏蔽
  180. self.chat_priate_info = {}
  181. self.welcomeList = {} -- 新主界面欢迎喇叭显示文本列表
  182. self.welcomeListIndex = 1 --显示的index
  183. self.has_new_guild_red = 0 -- 未读社团消息数量
  184. end
  185. function ChatModel:Clear()
  186. self.tv_state = true
  187. self.tv_list = {}
  188. self.selected_chatView_tabbar_item = nil
  189. self.selected_histroy_item = nil
  190. self.selected_textface_item = nil
  191. self.selected_face_item = nil
  192. self.selected_partner_item = nil
  193. self.selected_good_item = nil
  194. self.clicked_item = nil
  195. self.clicked_role_item = nil
  196. self.main_role_chat_list = ChatModel:GetAllMainRoleContent() or {}
  197. self.send_timer_list = {}
  198. self.send_start_time_list = {}
  199. self.request_cache = false
  200. self.curr_channel = 0
  201. self.chating_key_id = 0
  202. self.pre_bar_index = 0
  203. self.curr_bar_index = ChatModel.CHANNEL_WORLD--CHANNEL_SYSTEM
  204. self.world_chat_method = 0
  205. self.chat_args_dic = {}
  206. self.chick_hyperlink_mark = false
  207. self.curr_individuation_bar_index = 1
  208. self.reg_channel = 0
  209. self.voice_id = 0
  210. self.voice_path = 0
  211. self.reg_txt = nil
  212. self.loading_voice = nil
  213. self.cecret_chat_list = {}
  214. self.all_chat_list = {}
  215. self.all_chat_list_count = {}
  216. self.limit_way_list = {}
  217. self:ClearGongGaoTimer()
  218. self.get_chat = false
  219. self.chatMessage = nil
  220. self.chat_priate_info = {}
  221. end
  222. --计算每种频道收到的信息数量
  223. function ChatModel:CaclulationMsgCount(info)
  224. if info then
  225. --不记录自己发的信息
  226. local main_role_id = RoleManager.Instance:GetMainRoleId()
  227. if info.player_id == main_role_id then return end
  228. if info.channel == ChatModel.CHANNEL_CECRET then
  229. local cur_list = self.all_chat_list_count[info.channel]
  230. if cur_list == nil then
  231. cur_list = {}
  232. end
  233. self.all_chat_list_count[info.channel] = cur_list
  234. local len = TableSize(info.player_list)
  235. if len == 2 then
  236. local key_id = info.player_list[1].player_id == main_role_id and info.player_list[2].player_id or info.player_list[1].player_id
  237. local condition_1 = key_id ~= self.chating_key_id
  238. if condition_1 then
  239. if cur_list[key_id] == nil then
  240. cur_list[key_id] = 0
  241. end
  242. cur_list[key_id] = cur_list[key_id] + 1
  243. self:Fire(ChatModel.SHOW_TAB_RED_POINT, self.all_chat_list_count)
  244. end
  245. end
  246. elseif info.channel ~= ChatModel.CHANNEL_SYSTEM then
  247. local channel = info.channel --== ChatModel.CHANNEL_HORN and ChatModel.CHANNEL_WORLD or info.channel
  248. if self.curr_channel ~= channel then
  249. if channel == ChatModel.CHANNEL_HORN then
  250. if self.curr_channel ~= ChatModel.CHANNEL_WORLD then
  251. if self.all_chat_list_count[ChatModel.CHANNEL_WORLD] == nil then
  252. self.all_chat_list_count[ChatModel.CHANNEL_WORLD] = 0
  253. end
  254. self.all_chat_list_count[ChatModel.CHANNEL_WORLD] = self.all_chat_list_count[ChatModel.CHANNEL_WORLD] + 1
  255. end
  256. end
  257. if self.all_chat_list_count[channel] == nil then
  258. self.all_chat_list_count[channel] = 0
  259. end
  260. self.all_chat_list_count[channel] = self.all_chat_list_count[channel] + 1
  261. self:Fire(ChatModel.SHOW_TAB_RED_POINT, self.all_chat_list_count)
  262. end
  263. end
  264. end
  265. end
  266. --获取需要私聊的id
  267. function ChatModel:GetNeedChatKey()
  268. local cur_list = self.all_chat_list_count[ChatModel.CHANNEL_CECRET]
  269. if cur_list ~= nil then
  270. for k, v in pairs(cur_list) do
  271. if v > 0 then
  272. return k
  273. end
  274. end
  275. end
  276. end
  277. function ChatModel:AddMsg(info)
  278. -- 以下频道发言有次数限制 需要协议获取
  279. if info.channel == ChatModel.CHANNEL_CROSS then
  280. self:Fire(ChatModel.REQUEST_CCMD_EVENT, 11011, ChatModel.CHANNEL_CROSS)
  281. -- elseif info.channel == ChatModel.CHANNEL_COUNTRY then
  282. -- self:Fire(ChatModel.REQUEST_CCMD_EVENT, 11011, ChatModel.CHANNEL_COUNTRY)
  283. end
  284. -- 历史聊天记录
  285. if info.player_id == RoleManager:getInstance():GetMainRoleVo().role_id then
  286. if info.channel ~= ChatModel.CHANNEL_INVITE then --非组队邀请信息
  287. local s, e = string.find(info.msg, "<a@.+></a>")
  288. local args = false
  289. local save_str = ""
  290. if s == 1 then
  291. args = Split(info.msg, "@")
  292. end
  293. if args then
  294. save_str = string.format("<%s>", GoodsModel:getInstance():getGoodsName(tonumber(args[3])))
  295. else
  296. save_str = info.msg
  297. end
  298. local count
  299. local c_list = {}--保存color标签的所有数据
  300. if save_str then
  301. p1, p2, color_str, content_str = string.find(save_str, "%<color%=([^%>^/.]-)%>([^%>^/.]-)%<%/color")
  302. count = 1
  303. while p1 do
  304. c_list[count] = {}
  305. c_list[count].color = color_str
  306. c_list[count].text = content_str
  307. c_list[count].start_pos = p1
  308. p1, p2, color_str, content_str = string.find(save_str, "%<color%=([^%>^/.]-)%>([^%>^/.]-)%<%/color", p1 + 1)
  309. count = count + 1
  310. end
  311. end
  312. if #c_list > 0 then
  313. save_str = ""
  314. for i,v in ipairs(c_list) do
  315. save_str = save_str..v.text
  316. end
  317. end
  318. local cookie = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, ChatModel.SAVE_CHAT_HISTORY_INFO)
  319. cookie = cookie or {}
  320. local has_same_str = false
  321. for i, v in ipairs(cookie) do
  322. if v == save_str then
  323. has_same_str = true
  324. break
  325. end
  326. end
  327. if not has_same_str then
  328. table.insert(cookie, 1, save_str)
  329. for i = Config.ConfigChat.custom_history_num + 1, #cookie do
  330. table.remove(cookie, Config.ConfigChat.custom_history_num + 1)
  331. end
  332. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, ChatModel.SAVE_CHAT_HISTORY_INFO, cookie)
  333. end
  334. end
  335. end
  336. if info and info.channel ~= ChatModel.CHANNEL_NONE then
  337. if self:MsgNeedFilter(info) then
  338. return false
  339. end
  340. if self:IsPlayerInBlack(info) then
  341. return false
  342. end
  343. if info.channel == ChatModel.CHANNEL_CECRET then
  344. self:DealWithCerectSystemMsg(info)
  345. elseif info.channel == ChatModel.CHANNEL_HORN then
  346. self:DealWithHornSystemMsg(info)
  347. elseif info.channel == ChatModel.CHANNEL_REPLY then
  348. elseif info.channel == ChatModel.CHANNEL_1VN then
  349. else
  350. self:DealWithOtherSystemMsg(info)
  351. end
  352. --记录当前世界聊天剩余的次数
  353. if info.channel == ChatModel.CHANNEL_WORLD then
  354. info.world_chat_method = self.world_chat_method
  355. end
  356. --判断是否是答题频道
  357. --[[
  358. if info.channel == ChatModel.CHANNEL_1VN then
  359. info.channel = ChatModel.CHANNEL_CROSS --消息发到队伍频道里去
  360. CSOnevNModel:getInstance():SetOnevNChatInfo(info) --设置1vn
  361. CSOnevNModel:getInstance():Fire(BattleFieldDefine.CSOnevN.Event.UPDATE_CHAT_MSG, info)
  362. elseif info.channel == ChatModel.CHANNEL_INVITE then
  363. CSPvPModel.GetInstance():SetMessageEnlist(info)
  364. EventSystem.Fire(GlobalEventSystem,CSPvPEvent.REFRESH_TALK_DATA,ChatModel.CHANNEL_INVITE,info.msg,info)--3v3
  365. elseif info.channel == ChatModel.CHANNEL_3V3_TEAM then
  366. info.channel = ChatModel.CHANNEL_TEAM --消息发到队伍频道里去
  367. EventSystem.Fire(GlobalEventSystem,CSPvPEvent.REFRESH_TALK_DATA,ChatModel.CHANNEL_3V3_TEAM,info.msg,info)--3v3
  368. elseif info.channel == ChatModel.CHANNEL_GUILD or info.channel == ChatModel.CHANNEL_WORLD then
  369. if info.is_pvp_enlist then
  370. CSPvPModel.GetInstance():SetMessageEnlist(info)
  371. EventSystem.Fire(GlobalEventSystem,CSPvPEvent.REFRESH_TALK_DATA,ChatModel.CHANNEL_INVITE,info.msg,info)
  372. end
  373. end
  374. ]]
  375. -- 社团消息需要记录未读的消息数目
  376. if info.channel == ChatModel.CHANNEL_GUILD and info.player_id then
  377. local is_old_msg = not (self.login_time_cache and info.time - self.login_time_cache >= 0) -- 刚登陆拿的历史消息不管
  378. local role_id = RoleManager.Instance:GetMainRoleId()
  379. local is_self = info.player_id == role_id -- 自己的消息不算
  380. if not is_old_msg and not is_self then
  381. self:SetGuildChannelRedDot(true)
  382. end
  383. end
  384. self:CaclulationMsgCount(info)
  385. self:Fire(ChatModel.ADD_NEW_MSG, info)
  386. end
  387. return true
  388. end
  389. --获得正在聊天的玩家名字
  390. function ChatModel:GetChatingRoleName(key_id)
  391. local len = #self.cecret_chat_list
  392. local vo = nil
  393. for i = 1, len do
  394. vo = self.cecret_chat_list[i]
  395. if vo.key_id == key_id then
  396. return vo.name
  397. end
  398. end
  399. return "玩家名字"
  400. end
  401. --打包指定频道的时间信息 目的是为了添加一项横线时间显示
  402. function ChatModel:PackChatInfo(channel, time, key_id)
  403. local info = {}
  404. info.channel = channel
  405. info.time = time
  406. info.key_id = key_id
  407. info.is_line = true
  408. return info
  409. end
  410. --通过聊天界面的tabbar索引来获取当前频道值
  411. function ChatModel:GetChannelWithId(id)
  412. for k, v in pairs(Config.ConfigChat.channel_level) do
  413. if v.channel == id then
  414. return v
  415. end
  416. end
  417. end
  418. --根据频道获取Icon
  419. function ChatModel:GetChannelIconWithChannel(channel)
  420. local vo = nil
  421. for k,v in pairs(Config.ConfigChat.channel_level) do
  422. if v.channel == channel then
  423. return v.channel_icon
  424. end
  425. end
  426. return "chat_channel_1"
  427. end
  428. --根据频道获取name 包括颜色
  429. function ChatModel:GetChannelNameWithChannel(channel)
  430. local vo = nil
  431. for i = 1, #Config.ConfigChat.channel_level do
  432. vo = Config.ConfigChat.channel_level[i]
  433. if vo.channel == channel then
  434. if not vo.color2 then return end
  435. local name = "<color="..vo.color2..">".."["..vo.name.."]".."</color>"
  436. -- if vo.channel == ChatModel.CHANNEL_SYSTEM then --这会综合频道变成系统
  437. -- name = "<color="..vo.color2..">".."[系统]".."</color>"
  438. -- end
  439. return (name)
  440. end
  441. end
  442. if channel == ChatModel.ALL then
  443. return string.format("<color=%s>[所有]</color>", ColorUtil.ORANGE)
  444. end
  445. return "[未知]"
  446. end
  447. --根据频道获取Icon
  448. function ChatModel:GetChannelColorWithChannel(channel)
  449. local vo = nil
  450. for i = 1, #Config.ConfigChat.channel_level do
  451. vo = Config.ConfigChat.channel_level[i]
  452. if vo.channel == channel then
  453. return vo.color
  454. end
  455. end
  456. return "#848484"
  457. end
  458. function ChatModel:GetTipWithShowType(showtype)
  459. local vo = nil
  460. for i = 1, #Config.ConfigChat.tips do
  461. vo = Config.ConfigChat.tips[i]
  462. if vo.type == showtype then
  463. return vo.icon, vo.color
  464. end
  465. end
  466. return "chat_channel_1", "#333c4e" --"#848484"
  467. end
  468. function ChatModel:getInstance()
  469. if ChatModel.Instance == nil then
  470. ChatModel.New()
  471. end
  472. return ChatModel.Instance
  473. end
  474. function ChatModel:SeletedChatViewTabbar(item, not_fire_event)
  475. if self.selected_chatView_tabbar_item == item then
  476. return
  477. end
  478. if self.selected_chatView_tabbar_item then
  479. self.selected_chatView_tabbar_item:SetSelect(false)
  480. end
  481. self.selected_chatView_tabbar_item = item
  482. if self.selected_chatView_tabbar_item then
  483. self.selected_chatView_tabbar_item:SetSelect(true)
  484. if not not_fire_event then
  485. self:Fire(ChatModel.SELECT_CHAT_VIEW_TARBAR, self.selected_chatView_tabbar_item)
  486. end
  487. end
  488. end
  489. function ChatModel:SeletedTextFaceItem(item)
  490. if self.selected_textface_item then
  491. self.selected_textface_item:SetSelect(false)
  492. end
  493. self.selected_textface_item = item
  494. if self.selected_textface_item then
  495. self.selected_textface_item:SetSelect(true)
  496. self:Fire(ChatModel.SELECT_TEXT_FACE_ITEM, self.selected_textface_item)
  497. end
  498. end
  499. function ChatModel:SeletedHistroyItem(item)
  500. if self.selected_histroy_item then
  501. self.selected_histroy_item:SetSelect(false)
  502. end
  503. self.selected_histroy_item = item
  504. if self.selected_histroy_item then
  505. self.selected_histroy_item:SetSelect(true)
  506. self:Fire(ChatModel.SELECT_HISTROY_ITEM, self.selected_histroy_item)
  507. end
  508. end
  509. function ChatModel:SeletedFaceItem(item)
  510. if self.selected_face_item then
  511. self.selected_face_item:SetSelect(false)
  512. end
  513. self.selected_face_item = item
  514. if self.selected_face_item then
  515. self.selected_face_item:SetSelect(true)
  516. self:Fire(ChatModel.SELECT_FACE_ITEM, self.selected_face_item)
  517. end
  518. end
  519. function ChatModel:SeletedHistoryTextItem(item)
  520. if self.selected_history_text_item then
  521. self.selected_history_text_item:SetSelect(false)
  522. end
  523. self.selected_history_text_item = item
  524. if self.selected_history_text_item then
  525. self.selected_history_text_item:SetSelect(true)
  526. self:Fire(ChatModel.SELECT_HISTORY_TEXT_ITEM, self.selected_history_text_item.str)
  527. end
  528. end
  529. function ChatModel:SelectedPartnerItem(item)
  530. if self.selected_partner_item == item then return end
  531. if self.selected_partner_item then
  532. self.selected_partner_item:SetSelect(false)
  533. end
  534. self.selected_partner_item = item
  535. if self.selected_partner_item then
  536. self.selected_partner_item:SetSelect(true)
  537. self:Fire(ChatModel.SELECT_PARTNER_ITEM, self.selected_partner_item.vo)
  538. end
  539. end
  540. function ChatModel:SelectedGoodItem(item)
  541. if self.selected_good_item == item then return end
  542. if self.selected_good_item then
  543. self.selected_good_item:SetSelect(false)
  544. end
  545. self.selected_good_item = item
  546. if self.selected_good_item then
  547. self.selected_good_item:SetSelect(true)
  548. self:Fire(ChatModel.SELECT_GOOD_ITEM, self.selected_good_item.vo)
  549. end
  550. end
  551. function ChatModel:GetTVList()
  552. return self.tv_list
  553. end
  554. --处理不需要特殊处理的信息
  555. function ChatModel:DealWithOtherSystemMsg(info)
  556. local curr_list = self.all_chat_list[info.channel]
  557. if curr_list == nil then
  558. curr_list = {}
  559. self.all_chat_list[info.channel] = curr_list
  560. end
  561. table.insert(curr_list, info)
  562. if #curr_list > ChatModel.MAX_LEN_LIST[info.channel] then
  563. table.remove(curr_list, 1)
  564. end
  565. end
  566. --根据频道删除玩家聊天信息
  567. function ChatModel:DelMsgInChannelById(channel, id)
  568. local index_tb = {}
  569. local channel_list = self.all_chat_list[channel]
  570. if channel_list then
  571. if channel == ChatModel.CHANNEL_CECRET then
  572. self:ClearChannelMessageNum(ChatModel.CHANNEL_CECRET, id)
  573. CookieWrapper.Instance:DeleteChatHistroyFile(id)
  574. else
  575. for k, v in pairs(channel_list) do
  576. if v.player_id == id then
  577. table.insert(index_tb, k)
  578. end
  579. end
  580. local del = 0
  581. local num = 0
  582. for k, v in ipairs(index_tb) do
  583. del = v - num
  584. table.remove(channel_list, del)
  585. num = num + 1
  586. if self.all_chat_list_count[channel] and self.all_chat_list_count[channel] > 0 then
  587. self.all_chat_list_count[channel] = self.all_chat_list_count[channel] - 1
  588. end
  589. end
  590. end
  591. end
  592. end
  593. function ChatModel:DelMsgInNoticeChannelById( notice_id )
  594. local index_tb = {}
  595. if self.all_chat_list[ChatModel.CHANNEL_SYSTEM] then
  596. for k, v in pairs(self.all_chat_list[ChatModel.CHANNEL_SYSTEM]) do
  597. if v.notice_id == notice_id then
  598. table.insert(index_tb, k)
  599. end
  600. end
  601. local del = 0
  602. local num = 0
  603. for k, v in ipairs(index_tb) do
  604. del = v - num
  605. table.remove(self.all_chat_list[ChatModel.CHANNEL_SYSTEM], del)
  606. num = num + 1
  607. if self.all_chat_list_count[ChatModel.CHANNEL_SYSTEM] and self.all_chat_list_count[ChatModel.CHANNEL_SYSTEM] > 0 then
  608. self.all_chat_list_count[ChatModel.CHANNEL_SYSTEM] = self.all_chat_list_count[ChatModel.CHANNEL_SYSTEM] - 1
  609. end
  610. end
  611. end
  612. self:Fire(ChatModel.SHOW_TAB_RED_POINT, self.all_chat_list_count)
  613. end
  614. --处理喇叭信息 gg_flag --只发滚屏而且频道不是 CHANNEL_WORLD CHANNEL_HORN 就要设为ture
  615. function ChatModel:DealWithHornSystemMsg(info, front,gg_flag)
  616. --插入喇叭延迟列表
  617. info.gm = 0
  618. table.insert(self.delay_horn_list, info)
  619. --触发喇叭滚动
  620. SysInfoCtrl.Instance:AppendMsg(SysInfoCtrl.SysInfoType.HORN)
  621. if gg_flag then return end
  622. local curr_list = self.all_chat_list[ChatModel.CHANNEL_WORLD]
  623. local horn_list = self.all_chat_list[ChatModel.CHANNEL_HORN]
  624. if curr_list == nil then
  625. curr_list = {}
  626. self.all_chat_list[ChatModel.CHANNEL_WORLD] = curr_list
  627. end
  628. if horn_list == nil then
  629. horn_list = {}
  630. self.all_chat_list[ChatModel.CHANNEL_HORN] = horn_list
  631. end
  632. if front then --插入到最前面
  633. table.insert(curr_list, 1, info)
  634. else
  635. table.insert(curr_list, info)
  636. end
  637. -- print("ChatModel:DealWithHornSystemMsg", curr_list[#curr_list].msg)
  638. table.insert(horn_list, info)
  639. if #curr_list > ChatModel.MAX_LEN_LIST[ChatModel.CHANNEL_WORLD] then
  640. table.remove(curr_list, 1)
  641. end
  642. if #horn_list > ChatModel.MAX_LEN_LIST[ChatModel.CHANNEL_HORN] then
  643. table.remove(horn_list, 1)
  644. end
  645. end
  646. --移除喇叭延迟列表
  647. function ChatModel:RemoveDelayHorn()
  648. local info = table.remove(self.delay_horn_list, 1)
  649. self:Fire(ChatModel.UPDATE_HORNTV_NUM)
  650. return info
  651. end
  652. --获取喇叭延迟列表数量
  653. function ChatModel:GetDelayHornNum()
  654. return #self.delay_horn_list
  655. end
  656. --添加gm喇叭
  657. function ChatModel:AddGmHorn(scmd)
  658. local vo = {name = "系统", channel = scmd.channel, time = TimeUtil:getServerTime(), msg = scmd.msg, showtype = ChatModel.CHANNEL_HORN,
  659. lastTime = scmd.time, gm = scmd.gm}
  660. --插入喇叭延迟列表
  661. table.insert(self.delay_horn_list, vo)
  662. --排序
  663. local arg = {"gm", "time"}
  664. local condition = {Array.UPPER, Array.LOWER}
  665. SortTools.MoreKeysSorter(self.delay_horn_list, arg, condition)
  666. self:Fire(ChatModel.ADD_NEW_MSG, vo)
  667. --触发喇叭滚动
  668. SysInfoCtrl.Instance:AppendMsg(SysInfoCtrl.SysInfoType.HORN)
  669. end
  670. --处理私聊信息
  671. function ChatModel:DealWithCerectSystemMsg(info)
  672. --取私聊对象id作为key
  673. local curr_list = self.all_chat_list[info.channel]
  674. if curr_list == nil then
  675. --原先的祖传代码获取离线消息时根本就不读cookie直接创了个空表覆盖了,这里一定要拿一下缓存才行
  676. curr_list = CookieWrapper.Instance:GetChatHistroy(info.player_list[1].player_id,true)--根据id获取聊天缓存
  677. self.all_chat_list[info.channel] = curr_list
  678. end
  679. local len = TableSize(info.player_list)
  680. if string.find(info.msg,"<color@") then
  681. info.msg = ChuanWenManager:getInstance():FormatColorTag(info.msg)
  682. end
  683. if len == 2 then
  684. local role_id = RoleManager.Instance:GetMainRoleId()
  685. if role_id == info.player_list[1].player_id then
  686. info.key_id = info.player_list[2].player_id
  687. else
  688. info.key_id = info.player_list[1].player_id
  689. end
  690. --为了跟之前的结构匹配,对于私聊的信息,添加了以下几个信息
  691. info.name = info.player_list[1].name
  692. info.player_id = info.player_list[1].player_id
  693. info.level = info.player_list[1].level
  694. info.career = info.player_list[1].career
  695. info.dress_list = info.player_list[1].dress_list
  696. info.guild_id = info.player_list[1].guild_id
  697. info.sex = info.player_list[1].sex
  698. info.vip_flag = info.player_list[1].vip_flag
  699. info.sup_vip_type = info.player_list[1].sup_vip_type
  700. info.turn = info.player_list[1].turn
  701. info.ser_id = info.player_list[1].ser_id
  702. info.ser_num = info.player_list[1].ser_num
  703. info.ser_name = info.player_list[1].ser_name
  704. info.picture_ver = info.player_list[1].picture_ver
  705. info.picture = info.player_list[1].picture
  706. info.profile_photo_id = info.player_list[1].profile_photo_id
  707. info.GM = info.player_list[1].GM
  708. local key_id = tostring(info.key_id)
  709. local curr_player_list = curr_list[key_id]
  710. if curr_player_list == nil then
  711. curr_player_list = {}
  712. curr_list[key_id] = curr_player_list
  713. end
  714. table.insert(curr_player_list, info)
  715. --添加密聊消息
  716. local list = self:GetSimpleHistroyInfoSave(curr_player_list)
  717. CookieWrapper.Instance:SaveChatHistroy(key_id, CookieTimeType.TYPE_ALWAYS, list)
  718. --保存聊天记录
  719. CookieWrapper.Instance:WriteChatHistroy()
  720. if #curr_player_list > ChatModel.MAX_LEN_LIST[ChatModel.CHANNEL_CECRET] then
  721. table.remove(curr_player_list, 1)
  722. end
  723. local len = #self.cecret_chat_list
  724. local hasCache = false --是否是已有的密聊玩家
  725. local vo = nil
  726. for i = 1, len do
  727. vo = self.cecret_chat_list[i]
  728. if vo.key_id == tonumber(key_id) then
  729. --有可能上线缓存的信息 发过来
  730. if vo.time < info.time then
  731. vo.time = info.time
  732. end
  733. hasCache = true
  734. break
  735. end
  736. end
  737. if not hasCache then
  738. if #self.cecret_chat_list > 5 then
  739. table.remove(self.cecret_chat_list, 5)
  740. end
  741. table.insert(self.cecret_chat_list, DeepCopy(info))
  742. local function sort_func(v1, v2)
  743. return v1.time > v2.time
  744. end
  745. table.sort(self.cecret_chat_list, sort_func)
  746. self:GetSimpleCecretInfoSave()
  747. end
  748. end
  749. end
  750. --处理缓存信息, 私聊的缓存不需要处理
  751. function ChatModel:DealWithCacheMsg(info)
  752. if info.channel == ChatModel.CHANNEL_CECRET then return end
  753. local curr_list = self.all_chat_list[info.channel]
  754. if curr_list == nil then
  755. curr_list = {}
  756. self.all_chat_list[info.channel] = curr_list
  757. end
  758. local len = TableSize(info.player_list)
  759. if len > 0 then
  760. --为了跟之前的结构匹配,对于缓存的信息,添加了以下几个信息
  761. info.name = info.player_list[1].name
  762. info.player_id = info.player_list[1].player_id
  763. info.level = info.player_list[1].level
  764. info.career = info.player_list[1].career
  765. info.dress_list = info.player_list[1].dress_list
  766. info.guild_id = info.player_list[1].guild_id
  767. info.sex = info.player_list[1].sex
  768. info.turn = info.player_list[1].turn
  769. info.vip_flag = info.player_list[1].vip_flag
  770. info.sup_vip_type = info.player_list[1].sup_vip_type
  771. info.picture = info.player_list[1].picture
  772. info.picture_ver = info.player_list[1].picture_ver
  773. info.ser_id = info.player_list[1].ser_id
  774. info.ser_num = info.player_list[1].ser_num
  775. info.ser_name = info.player_list[1].ser_name
  776. info.profile_photo_id = info.player_list[1].profile_photo_id
  777. info.GM = info.player_list[1].GM
  778. if info.auto_id ~= 0 then --语音的
  779. info.voice_id = info.auto_id
  780. info.data_ver = info.client_ver
  781. info.iType = ChatModel.MSG_TYPE.VOICE
  782. info.length = info.voice_msg_time
  783. end
  784. -- print("=============>>> YiRan:ChatModel [start:830]info ------------------------------------------")
  785. -- PrintTable(info)
  786. -- print("=============>>> YiRan:ChatModel [end] ------------------------------------------")
  787. end
  788. end
  789. function ChatModel:GetSimpleHistroyInfoSave(chatlist)
  790. local list = {}
  791. for i, info in ipairs(chatlist) do
  792. --控制一下聊天记录数量,超过限制数量就不要加入转化了
  793. if #chatlist - i <= ChatModel.MAX_LEN_LIST[ChatModel.CHANNEL_CECRET] then
  794. --构造最基本信息
  795. info.msg = string.gsub(info.msg, '(["])', "")
  796. local vo = {
  797. channel = info.channel,
  798. msg = info.msg,
  799. time = info.time,
  800. player_id = info.player_id,
  801. key_id = info.key_id,
  802. level = info.level,
  803. name = info.name,
  804. career = info.career,
  805. dress_list = info.dress_list,
  806. guild_id = info.guild_id,
  807. iType = info.iType,
  808. length = info.length,
  809. voice_id = info.voice_id,
  810. data_ver = info.data_ver,
  811. sex = info.sex,
  812. turn = info.turn,
  813. vip_flag = info.vip_flag,
  814. sup_vip_type = info.sup_vip_type,
  815. ser_id = info.ser_id,
  816. ser_num = info.ser_num,
  817. ser_name = info.ser_name,
  818. GM = info.GM,
  819. profile_photo_id = info.profile_photo_id
  820. }
  821. table.insert(list, vo)
  822. end
  823. end
  824. return list
  825. end
  826. function ChatModel:GetSimpleCecretInfoSave()
  827. local list = {}
  828. for i, info in ipairs(self.cecret_chat_list) do
  829. --构造最基本信息
  830. local v = {}
  831. if info.key_id == info.player_list[1].player_id then
  832. v = info.player_list[1]
  833. else
  834. v = info.player_list[2]
  835. end
  836. local vo = {
  837. time = info.time,
  838. key_id = info.key_id,
  839. player_list = {
  840. [1] = {
  841. player_id = v.player_id,
  842. name = v.name,
  843. level = v.level,
  844. career = v.career,
  845. vip_flag = v.vip_flag,
  846. sup_vip_type = v.sup_vip_type,
  847. touxian = v.touxian,
  848. guild_id = v.guild_id,
  849. ser_id = v.ser_id,
  850. ser_num = v.ser_num,
  851. ser_name = v.ser_name,
  852. },
  853. },
  854. }
  855. table.insert(list, vo)
  856. end
  857. --密聊列表最大5个,只在有新的人才会保存信息。但这里可以再做优化
  858. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.CECRET_HISTROY, list)
  859. end
  860. --获取喇叭需要的配置信息
  861. function ChatModel:GetHornVo()
  862. local vo = nil
  863. for i = 1, #Config.ConfigChat.channel_level do
  864. vo = Config.ConfigChat.channel_level[i]
  865. if vo.channel == ChatModel.CHANNEL_HORN then
  866. return vo
  867. end
  868. end
  869. return nil
  870. end
  871. --获取当前所在频道所需等级
  872. function ChatModel:GetCurChannelNeedLevel()
  873. return Config.ConfigChat.channel_level[self.curr_bar_index].level
  874. end
  875. --获取私聊需要的等级
  876. function ChatModel:GetCecretNeedLevel()
  877. local vo = nil
  878. for i = 1, #Config.ConfigChat.channel_level do
  879. vo = Config.ConfigChat.channel_level[i]
  880. if vo.channel == ChatModel.CHANNEL_CECRET then
  881. return vo.level
  882. end
  883. end
  884. return 1
  885. end
  886. --根据频道获取频道所在的index
  887. function ChatModel:GetTabIndexWithChannel(channel)
  888. local vo = nil
  889. for i = 1, #Config.ConfigChat.channel_level do
  890. vo = Config.ConfigChat.channel_level[i]
  891. if vo.channel == channel then
  892. return i
  893. end
  894. end
  895. return 1
  896. end
  897. --检查当前时间是否能发送
  898. function ChatModel:CheckCurrentTimeCanSend(channel, send_interval)
  899. if self.send_start_time_list[channel] == nil or Status.NowTime - self.send_start_time_list[channel] >= send_interval then
  900. return true
  901. end
  902. return false
  903. end
  904. function ChatModel:GetPassTimeFromSend(channel, send_interval)
  905. if self.send_start_time_list[channel] == nil then
  906. return - 1
  907. else
  908. return send_interval - (Status.NowTime - self.send_start_time_list[channel])
  909. end
  910. end
  911. --改变频道的发送时间
  912. function ChatModel:ChangeChannelSendStartTime(vo, time)
  913. local main_role_id = RoleManager.Instance:GetMainRoleId()
  914. if vo.player_id == main_role_id then
  915. self.send_start_time_list[vo.channel] = time
  916. end
  917. end
  918. --是否需要显示私聊Item的红点
  919. function ChatModel:NeedShowCecretItemRedPoint(key_id)
  920. local cur_list = self.all_chat_list_count[ChatModel.CHANNEL_CECRET]
  921. if cur_list == nil then return false end
  922. if cur_list[key_id] ~= nil and cur_list[key_id] > 0 then
  923. return true, cur_list[key_id]
  924. end
  925. return false
  926. end
  927. --清除消息记录的条数
  928. function ChatModel:ClearChannelMessageNum(channel, key_id)
  929. if channel == ChatModel.CHANNEL_CECRET then
  930. local cur_list = self.all_chat_list_count[channel]
  931. if cur_list ~= nil and cur_list[key_id] ~= nil then
  932. cur_list[key_id] = nil
  933. end
  934. else
  935. self.all_chat_list_count[channel] = nil
  936. end
  937. end
  938. --是否黑名单玩家
  939. function ChatModel:IsPlayerInBlack(info)
  940. return SocialityModel:getInstance():GetVoById(Config.ConfigSocial.RelativeType.black, info.player_id)
  941. end
  942. --判断频道信息是否需要屏蔽
  943. function ChatModel:MsgNeedFilter(info)
  944. local channel = info.channel
  945. local setting_type = SettingModel.TYPE.TEXT--info.iType 语音随文字的 就这样写
  946. --如果是自己则不屏蔽
  947. local main_role_id = RoleManager.Instance:GetMainRoleId()
  948. if channel == ChatModel.CHANNEL_CECRET then
  949. local len = TableSize(info.player_list)
  950. if len == 2 then
  951. if main_role_id == info.player_list[1].player_id then
  952. return false
  953. end
  954. end
  955. else
  956. if main_role_id == info.player_id then
  957. return false
  958. end
  959. end
  960. local subtype = SettingModel.C2T[channel]
  961. if subtype then
  962. return SettingModel:getInstance():GetSettingInfo(setting_type, subtype) == 0
  963. else
  964. return false
  965. end
  966. end
  967. function ChatModel:AddArgs(key, t)
  968. --只能保存一个
  969. -- if not IsTableEmpty(self.chat_args_dic) then
  970. -- self.chat_args_dic = {}
  971. -- end
  972. self.chat_args_dic[key] = t
  973. end
  974. function ChatModel:IsHasArgs(str)
  975. for w in string.gmatch(str, "<.->") do
  976. if self.chat_args_dic[w] ~= nil then
  977. return w
  978. end
  979. end
  980. return false
  981. end
  982. function ChatModel:GetAllArgsText(str)
  983. --目前能保存多个key,每次替换Input<>内容,遍历dic与<>内容作比较,有则发送参数,可用于发送多个道具信息
  984. --只发送一个则可以只保存单个参数,不需要用到dic结构(对比优化)
  985. local text = ""
  986. for w in string.gmatch(str, "<.->") do
  987. if self.chat_args_dic[w] ~= nil then
  988. text = text .. self.chat_args_dic[w][1] .. ","
  989. end
  990. end
  991. text = string.sub(text, 1, -2)
  992. return "[" .. text .. "]"
  993. end
  994. function ChatModel:GetHyperlinkText(str)
  995. local text = ""
  996. for w in string.gmatch(str, "<.->") do
  997. if self.chat_args_dic[w] ~= nil then
  998. text = LanguageFilter.ConvPartten(w)
  999. str = string.gsub(str, text, self.chat_args_dic[w][2])
  1000. end
  1001. end
  1002. return str
  1003. end
  1004. function ChatModel:AddMainRoleChatContent(content, player_id)
  1005. if player_id ~= RoleManager.Instance:GetMainRoleId() then return end
  1006. if #self.main_role_chat_list >= 20 then
  1007. table.remove(self.main_role_chat_list, 1)
  1008. end
  1009. content = PackageSpecialTab(content)
  1010. content = self:DeleteSpecialSign(content)
  1011. table.insert(self.main_role_chat_list, content)
  1012. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.CHAT_HISTROY, self.main_role_chat_list)
  1013. end
  1014. function ChatModel:GetAllMainRoleContent()
  1015. return CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.CHAT_HISTROY)
  1016. end
  1017. function ChatModel:DeleteSpecialSign(content)
  1018. content = string.gsub(content, "<a.->", "")
  1019. content = string.gsub(content, "</a>", "")
  1020. content = string.gsub(content, "<color.->", "")
  1021. content = string.gsub(content, "</color>", "")
  1022. content = string.gsub(content, "<u.->", "")
  1023. content = string.gsub(content, "</u>", "")
  1024. content = string.gsub(content, '(["])', "")
  1025. return content
  1026. end
  1027. function ChatModel:ShowGoodTips(vo)
  1028. if not self.clicked_item or not self.clicked_item.transform then
  1029. --协议返回后,界面已销毁
  1030. self.chick_hyperlink_mark = false
  1031. return
  1032. end
  1033. local t = ConfigItemMgr.Instance:GetGoodItem(vo.type_id) --
  1034. if t.type then
  1035. local pos = self.clicked_item.transform.localPosition
  1036. GoodsModel:getInstance():SetBaseInfo(vo)
  1037. if t.type == GoodsModel.TYPE.EQUIP then
  1038. -- UIToolTipMgr:getInstance():AppendEquipTips(vo.type_id, pos.x, pos.y, vo,nil,true)
  1039. local equip_cfg = EquipModel:getInstance():GetEquipmentCfg(vo.type_id)
  1040. if equip_cfg then
  1041. local equip_pos = equip_cfg.equip_type
  1042. local series = equip_cfg.series
  1043. vo.equip_suit_type = equip_pos
  1044. local stren_data = EquipModel:getInstance():GetBagEquipAwaraItemInfo(vo)
  1045. stren_data.key_value = "other_show"
  1046. UIToolTipMgr:getInstance():AppendEquipTips(vo.type_id, pos.x, pos.y,stren_data and stren_data.goods_vo,nil,nil,nil,stren_data and stren_data.key_value)
  1047. else
  1048. -- Message.show("没有装备配置哦")
  1049. end
  1050. elseif t.type == 39 then
  1051. UIToolTipMgr:getInstance():AppendBeastShowTips(vo, pos.x, pos.y)
  1052. else
  1053. UIToolTipMgr:getInstance():AppendGoodsTips(vo.type_id, pos.x, pos.y, vo)
  1054. end
  1055. end
  1056. self.chick_hyperlink_mark = false
  1057. self.clicked_item = nil
  1058. end
  1059. function ChatModel:FireSpecialTab(param_list,x,y)
  1060. if param_list[1] == "goods3" then --请求刷新装备数据
  1061. local type_id = tonumber(param_list[2])
  1062. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
  1063. if basic and (basic.type == GoodsModel.TYPE.EQUIP or basic.type == 39) then
  1064. local rating = tonumber(param_list[3])
  1065. local intro = StrToTable(param_list[4]) or {}
  1066. local vo = SCMD15001.New()
  1067. vo.equip_extra_attr = intro
  1068. vo.rating = rating
  1069. vo.type_id = type_id
  1070. vo.color = basic.color
  1071. vo.overall_rating = rating
  1072. GoodsModel:getInstance():AddDynamic(vo)
  1073. if basic.type == GoodsModel.TYPE.EQUIP then
  1074. ChatModel:getInstance():ShowGoodTips(vo)
  1075. elseif basic.type == 39 then
  1076. UIToolTipMgr:getInstance():AppendBeastShowTips(vo)
  1077. end
  1078. else
  1079. UIToolTipMgr:getInstance():AppendGoodsTips(tonumber(param_list[2]),x,y)
  1080. end
  1081. self.chick_hyperlink_mark = false
  1082. self.clicked_item = nil
  1083. elseif param_list[1] == "goods6" then
  1084. --goods3是后台填传闻用到,收到协议后进行特殊解析
  1085. --goods6是客户端用的,无需解析,直接把极品属性字符串转成table
  1086. local type_id = tonumber(param_list[2])
  1087. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
  1088. if basic and (basic.type == GoodsModel.TYPE.EQUIP or basic.type == 39) then
  1089. local rating = tonumber(param_list[3])
  1090. local intro = StrToTable(param_list[4])
  1091. local vo = SCMD15001.New()
  1092. vo.equip_extra_attr = intro
  1093. vo.rating = rating
  1094. vo.type_id = type_id
  1095. vo.color = basic.color
  1096. vo.overall_rating = rating
  1097. GoodsModel:getInstance():AddDynamic(vo)
  1098. if basic.type == GoodsModel.TYPE.EQUIP then
  1099. ChatModel:getInstance():ShowGoodTips(vo)
  1100. elseif basic.type == 39 then
  1101. UIToolTipMgr:getInstance():AppendBeastShowTips(vo)
  1102. end
  1103. else
  1104. UIToolTipMgr:getInstance():AppendGoodsTips(tonumber(param_list[2]))
  1105. end
  1106. self.chick_hyperlink_mark = false
  1107. self.clicked_item = nil
  1108. elseif param_list[1] == "goods8" then
  1109. local type_id = tonumber(param_list[2])
  1110. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
  1111. if basic and (basic.type == GoodsModel.TYPE.EQUIP or basic.type == 39) then
  1112. local rating = tonumber(param_list[3])
  1113. local intro = StrToTable(param_list[4])
  1114. local vo = SCMD15001.New()
  1115. vo.equip_extra_attr = intro
  1116. vo.rating = rating
  1117. vo.type_id = type_id
  1118. vo.color = basic.color
  1119. vo.overall_rating = rating
  1120. GoodsModel:getInstance():AddDynamic(vo)
  1121. if basic.type == GoodsModel.TYPE.EQUIP then
  1122. ChatModel:getInstance():ShowGoodTips(vo)
  1123. elseif basic.type == 39 then
  1124. UIToolTipMgr:getInstance():AppendBeastShowTips(vo)
  1125. end
  1126. else
  1127. UIToolTipMgr:getInstance():AppendGoodsTips(tonumber(param_list[2]))
  1128. end
  1129. self.chick_hyperlink_mark = false
  1130. self.clicked_item = nil
  1131. elseif param_list[1] == "goods4" then --请求刷新物品数据
  1132. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(tonumber(param_list[2]))
  1133. if basic and basic.type == GoodsModel.TYPE.EQUIP then
  1134. GoodsModel:getInstance():Fire(GoodsModel.REQUEST_GOODS_DYNAMIC, tonumber(param_list[3]), tonumber(param_list[4]))
  1135. else
  1136. UIToolTipMgr:getInstance():AppendGoodsTips(tonumber(param_list[2]))
  1137. self.chick_hyperlink_mark = false
  1138. self.clicked_item = nil
  1139. end
  1140. elseif param_list[1] == "team" then --进入组队
  1141. local teamInfo = TeamModel:getInstance():GetTeamInfoByID( tonumber(param_list[2]) )
  1142. if teamInfo and teamInfo.need_password and teamInfo.need_password ~= "" then
  1143. GlobalEventSystem:Fire(EventName.OPEN_TEAM_PASSWORD_VIEW, teamInfo.team_id)
  1144. return
  1145. end
  1146. GlobalEventSystem:Fire(TeamModel.APPLY_JOIN_TEAM, param_list[2])
  1147. elseif param_list[1] == "race_act" then
  1148. local subtype = LimitTimeRankModel:getInstance():GetSubTypeByType(tonumber(param_list[2]))
  1149. if subtype then
  1150. LimitTimeRankModel:getInstance():Fire(LimitTimeRankDefine.OPEN_LIMIT_TIME_RANK_VIEW, tonumber(param_list[2]), subtype)
  1151. end
  1152. end
  1153. end
  1154. function ChatModel:AddInfoToChatView(content, channel, tip) -- tip 为小喇叭弹出,记得其他模块没特殊要求别填1
  1155. --和传闻事件基本相似,除了系统频道外,都会隐藏红色背景
  1156. if not content or not channel then return end
  1157. local vo = {channel = channel, time = TimeUtil:getServerTime(), msg = content, showtype = ChatModel.CHANNEL_SYSTEM, tip = tip}
  1158. self:AddMsg(vo)
  1159. end
  1160. function ChatModel:GetErrorCode(code, strParam)
  1161. local tmp = Config.Errorcode[code]
  1162. local str = "未知返回码" .. code
  1163. if tmp then
  1164. str = Config.Errorcode[code].about
  1165. if strParam then
  1166. local args = Split(strParam, ",")
  1167. for i, v in ipairs(args) do
  1168. str = string.gsub(str, "{"..i.."}", v)
  1169. end
  1170. end
  1171. end
  1172. return str
  1173. end
  1174. function ChatModel:StartGongGaoList(vo)
  1175. if not vo then return end
  1176. for i,data in pairs(self.last_Gg_list) do --遍历旧表 如果新的公告记录表里面有旧表的数据就不做操作 没有的话就删除记录
  1177. local boo = false --判断标志 是否有记录
  1178. for i,v in ipairs(vo.notice_list) do
  1179. if data.id == v.id then --如果有记录 标志为true
  1180. boo = true
  1181. end
  1182. end
  1183. if not boo then --没有记录就做删除
  1184. ChatModel:getInstance():Fire(ChatModel.DEL_NOTICE_CHAT_ITEM,data.id)
  1185. ChatModel:getInstance():DelMsgInNoticeChannelById(data.id)
  1186. end
  1187. end
  1188. for i,v in ipairs(vo.notice_list) do --每次都缓存新的公告记录
  1189. self.last_Gg_list[v.id] = v
  1190. end
  1191. self:ClearGongGaoTimer()
  1192. if #vo.notice_list < 1 then return end
  1193. --self:ClearGongGaoTimer()
  1194. self.gonggao_vo = vo
  1195. local count = 0
  1196. for k, v in pairs(vo.notice_list) do
  1197. local tb = Split(v.source, ",")
  1198. for m, n in pairs(tb) do
  1199. if n == ClientConfig.plat_name or n == "" then
  1200. local ser_time = TimeUtil:getServerTime()
  1201. local time = v.start_time - ser_time
  1202. if time <= 0 then --超过时间, 就按照顺序隔180秒播放
  1203. count = count + 1
  1204. v.start_time = TimeUtil:getServerTime() + count * 180
  1205. end
  1206. self:GongGaoTimer(v)
  1207. end
  1208. end
  1209. end
  1210. end
  1211. function ChatModel:GongGaoTimer(vo)
  1212. if not vo then return end
  1213. if TimeUtil:getServerTime() > vo.end_time then return end
  1214. if vo.state == 0 then
  1215. ChatModel:getInstance():Fire(ChatModel.DEL_NOTICE_CHAT_ITEM,vo.id)
  1216. ChatModel:getInstance():DelMsgInNoticeChannelById(vo.id)
  1217. return
  1218. end
  1219. local ser_time = TimeUtil:getServerTime()
  1220. local time = vo.start_time - ser_time
  1221. vo.content = "<color="..vo.color..">"..vo.content.."</color>"
  1222. local count = 0
  1223. local check_time_id, delay_time_id = nil, nil
  1224. --数据开始时间>现在时间,马上发送
  1225. local function onCheck()
  1226. local cfg, scmd = {subtype = ChatModel.CHANNEL_SYSTEM} ,{url = vo.url,notice_id = vo.id}
  1227. if vo.type == 0 then
  1228. self:DealWithHornSystemMsg({name = "公告", msg = vo.content}, true,true)
  1229. elseif vo.type == 1 then
  1230. GlobalEventSystem:Fire(EventName.SHOW_CHUANWEN, vo.content, cfg, scmd)
  1231. elseif vo.type == 2 then
  1232. self:DealWithHornSystemMsg({name = "公告", msg = vo.content}, true,true)
  1233. GlobalEventSystem:Fire(EventName.SHOW_CHUANWEN, vo.content, cfg, scmd)
  1234. end
  1235. count = count + 1
  1236. if (vo.send_count ~= 0 and vo.send_count <= count) or TimeUtil:getServerTime() > vo.end_time then
  1237. GlobalTimerQuest:CancelQuest(check_time_id)
  1238. check_time_id = nil
  1239. end
  1240. end
  1241. local function onDelay()
  1242. check_time_id = GlobalTimerQuest:AddPeriodQuest(onCheck, vo.send_gap, -1)
  1243. table.insert(self.check_timer_list, check_time_id)
  1244. GlobalTimerQuest:CancelQuest(delay_time_id)
  1245. delay_time_id = nil
  1246. end
  1247. if vo.send_gap > 3 then --不能小于3 间隔太小,定时器有问题
  1248. if time > 0 then
  1249. delay_time_id = GlobalTimerQuest:AddDelayQuest(onDelay, time) --时间大于0 就延迟发送
  1250. table.insert(self.delay_timer_list, delay_time_id)
  1251. else
  1252. check_time_id = GlobalTimerQuest:AddPeriodQuest(onCheck, vo.send_gap, -1) --不大于0 立马发送
  1253. table.insert(self.check_timer_list, check_time_id)
  1254. end
  1255. end
  1256. onCheck()--修改后立马要发送一条 然后其他按间隔来
  1257. end
  1258. function ChatModel:ClearGongGaoTimer()
  1259. for i, v in ipairs(self.delay_timer_list) do
  1260. GlobalTimerQuest:CancelQuest(v)
  1261. end
  1262. for i, v in ipairs(self.check_timer_list) do
  1263. GlobalTimerQuest:CancelQuest(v)
  1264. end
  1265. self.delay_timer_list = {}
  1266. self.check_timer_list = {}
  1267. end
  1268. function ChatModel:UpdateRegText(scmd)
  1269. local check_list = self.all_chat_list[scmd.channel]
  1270. if check_list then
  1271. for k, v in pairs(check_list) do
  1272. if v.voice_id == scmd.auto_id then
  1273. v.msg = scmd.voice_text
  1274. break
  1275. end
  1276. end
  1277. end
  1278. end
  1279. --argStr 格式是 "@A@B@C"
  1280. function ChatModel:GetSpecFindStr()
  1281. local key, argStr = "", ""
  1282. if SceneManager:getInstance():IsValhallaFightScene() then
  1283. key = "valhallapk"
  1284. argStr = "@"..ValhallaModel:GetInstance().pk_id
  1285. end
  1286. return key, argStr
  1287. end
  1288. function ChatModel:GetDressIdByType(dress_list, dress_type)
  1289. if dress_list then
  1290. for i, v in ipairs(dress_list) do
  1291. --1气泡 2相框
  1292. if v.dress_type == dress_type then
  1293. return v.dress_id
  1294. end
  1295. end
  1296. end
  1297. end
  1298. function ChatModel:SetCrossChatTime(count)
  1299. -- print("ChatModel:SetCrossChatTime", count)
  1300. self.crossChatTime = count
  1301. self:Fire(ChatModel.CROSS_HORN_HAS_CHANGE, count)
  1302. end
  1303. function ChatModel:GoodChange()
  1304. self:Fire(ChatModel.HORN_HAS_CHANGE)
  1305. end
  1306. function ChatModel:SetChannelGennealList(channelID)
  1307. if channelID ~= ChatModel.CHANNEL_GENERAL then return end --只在需要设置综合频道才使用
  1308. local all_chat_list = self.all_chat_list
  1309. local channelGeneralList = {}
  1310. if all_chat_list then
  1311. for channel,list in pairs(all_chat_list) do
  1312. if channel ~= ChatModel.CHANNEL_GENERAL and channel ~= ChatModel.CHANNEL_HORN and channel ~= ChatModel.CHANNEL_CECRET then --喇叭会加入世界频道····可能祖传代码就要这样做
  1313. for k,v in pairs(list) do
  1314. table.insert(channelGeneralList,v)
  1315. end
  1316. end
  1317. end
  1318. end
  1319. local sort_func = function ( a, b ) --生成是倒序
  1320. return a.time < b.time
  1321. end
  1322. table.sort(channelGeneralList, sort_func)
  1323. local cutNum = #channelGeneralList - ChatModel.MAX_LEN_LIST[ChatModel.CHANNEL_GENERAL]
  1324. if cutNum > 0 then
  1325. for i=1,cutNum do
  1326. table.remove(channelGeneralList,1)
  1327. end
  1328. end
  1329. all_chat_list[ChatModel.CHANNEL_GENERAL] = channelGeneralList
  1330. --Message.show(#self.all_chat_list[ChatModel.CHANNEL_GENERAL])
  1331. end
  1332. --存储未读私聊消息
  1333. function ChatModel:SetPriateChatInfo(info)
  1334. if not info then return end
  1335. local len = TableSize(info.player_list)
  1336. if len == 2 then
  1337. local role_id = RoleManager.Instance:GetMainRoleId()
  1338. if role_id == info.player_list[1].player_id then
  1339. info.key_id = info.player_list[2].player_id
  1340. else
  1341. info.key_id = info.player_list[1].player_id
  1342. end
  1343. info.name = info.player_list[1].name
  1344. self.chat_priate_info[info.key_id] = {}
  1345. self.chat_priate_info[info.key_id] = info.player_list[1].player_id
  1346. end
  1347. end
  1348. --获取未读私聊消息
  1349. function ChatModel:GetPriateChatInfo( )
  1350. return self.chat_priate_info
  1351. end
  1352. --更新未读私聊消息
  1353. function ChatModel:UpdatePriateChatInfo(id)
  1354. if not id then return end
  1355. for k,v in pairs(self.chat_priate_info) do
  1356. if k == id then
  1357. self.chat_priate_info[k] = nil
  1358. end
  1359. end
  1360. end
  1361. function ChatModel:SetChatInfo( info,vo )
  1362. self.get_chat = info
  1363. self.chatMessage = vo
  1364. end
  1365. function ChatModel:GetChatInfo( )
  1366. return self.get_chat,self.chatMessage
  1367. end
  1368. function ChatModel:SetConfigLangExtraWelcomeList( )
  1369. local config_language_extra = Config.Languageextra
  1370. self.welcomeList = {}
  1371. for k,v in pairs(config_language_extra) do
  1372. if v.module_id == 110 then
  1373. --if v.id ~= 1 then --开始显示第一条
  1374. --if v.tip == 1 then -- tip 为1的才加
  1375. local str = Trim( ChuanWenManager:getInstance():FormatColorTag2(v.content, true) )
  1376. table.insert(self.welcomeList,str)
  1377. --end
  1378. --end
  1379. end
  1380. end
  1381. end
  1382. function ChatModel:StopWelcomeHorn( )
  1383. if self.play_welcom_horn_id then
  1384. GlobalTimerQuest:CancelQuest(self.play_welcom_horn_id)
  1385. self.play_welcom_horn_id = nil
  1386. end
  1387. end
  1388. function ChatModel:StartMainUIWelcomeHorn( )
  1389. self:StopWelcomeHorn( )
  1390. local function onTimer( )
  1391. local new_index = math.random(1, #self.welcomeList)
  1392. if new_index == self.welcomeListIndex then
  1393. self.welcomeListIndex = self.welcomeListIndex + 1
  1394. if self.welcomeListIndex > #self.welcomeList then
  1395. self.welcomeListIndex = 1
  1396. end
  1397. else
  1398. self.welcomeListIndex = new_index
  1399. end
  1400. welcomeShowTxt = self.welcomeList[self.welcomeListIndex]
  1401. self:Fire(ChatModel.ADD_MAINUI_WELCOME_HORN, welcomeShowTxt)
  1402. end
  1403. self.play_welcom_horn_id = GlobalTimerQuest:AddPeriodQuest(onTimer,Config.ConfigChat.MainUIWelcomeHornTime)
  1404. onTimer() -- 先调一次
  1405. end
  1406. function ChatModel:GetGoodsTipNum( )--11060协议专用小喇叭显示,后端无法传只得前端写死读
  1407. local config_language_extra = Config.Languageextra
  1408. return config_language_extra["0@2"].tip
  1409. end
  1410. function ChatModel:SetVo11023(vo)
  1411. self.vo11023 = vo
  1412. end
  1413. function ChatModel:GetVo11023( )
  1414. return self.vo11023
  1415. end
  1416. function ChatModel:GetAiMsgList( )
  1417. if not self:GetVo11023( ) or not self:GetVo11023( ).cache_list then return end
  1418. --print("=============>>> YiRan:ChatModel [start:1459] self:GetVo11023( ).cache_list ------------------------------------------")
  1419. --PrintTable(self:GetVo11023( ).cache_list)
  1420. --print("=============>>> YiRan:ChatModel [end] ------------------------------------------")
  1421. local role_id = RoleManager.Instance:GetMainRoleId()
  1422. local server_id = RoleManager.Instance.mainRoleInfo.server_id
  1423. local creatMsg =
  1424. {
  1425. ["args"] = {},
  1426. ["result"] = 0,
  1427. ["auto_id"] = 0,
  1428. ["player_list"] =
  1429. {
  1430. [1] =
  1431. {
  1432. ["GM"] = 0,
  1433. ["guild_name"] = "",
  1434. ["vip_flag"] = 0,
  1435. ["profile_photo_id"] = 0,
  1436. ["realm"] = 0,
  1437. ["player_id"] = 0,
  1438. ["ser_num"] = 666,
  1439. ["sex"] = 1,
  1440. ["role_id"] = role_id,
  1441. ["touxian"] = 0,
  1442. ["picture_ver"] = 0,
  1443. ["turn_stage"] = 0,
  1444. ["grade_id"] = 0,
  1445. -- ["deity_id"] = 0,
  1446. -- ["image_id"] = 0,
  1447. -- ["marriage_id"] = 0,
  1448. -- ["is_marriage"] = 0,
  1449. ["picture"] = 0,
  1450. ["sup_vip_type"] = 0,
  1451. -- ["escort_state"] = 0,
  1452. -- ["marriage_name"] = "",
  1453. ["level"] = "",
  1454. ["god_id"] = 0,
  1455. ["star_soul_id"] = 0,
  1456. ["ser_id"] = 125,
  1457. ["position_name"] = "",
  1458. ["turn"] = 0,
  1459. ["career"] = 0,
  1460. ["position"] = 0,
  1461. ["guild_id"] = 0,
  1462. ["dsgt_id"] = 0,
  1463. ["sprite_id"] = 607001,
  1464. ["name"] = "信息自定义",
  1465. ["ser_name"] = "one server",
  1466. ["ser_id"] = server_id,
  1467. }
  1468. },
  1469. ["channel"] = 1,
  1470. ["voice_msg_time"] = 0,
  1471. ["time"] = 1579058986,
  1472. ["msg"] = "模拟信息自定义~~~~",
  1473. ["client_ver"] = 0,
  1474. }
  1475. local transf_cache_list = {}
  1476. for k,v in pairs(self:GetVo11023( ).cache_list) do
  1477. transf_cache_list[k] = DeepCopy(creatMsg)
  1478. transf_cache_list[k].msg = v.msg
  1479. transf_cache_list[k].player_list[1].profile_photo_id = v.picture
  1480. transf_cache_list[k].player_list[1].sex = v.sex
  1481. transf_cache_list[k].player_list[1].vip_flag = v.vip --暂时没有vip
  1482. transf_cache_list[k].player_list[1].lv = v.lv
  1483. transf_cache_list[k].player_list[1].name = v.name
  1484. transf_cache_list[k].time = v.time
  1485. end
  1486. return transf_cache_list
  1487. -- self:AddMsg(msgVo)
  1488. end
  1489. function ChatModel:IsCrossServerChannel( channel_id )
  1490. return channel_id == ChatModel.CHANNEL_CROSS or
  1491. channel_id == ChatModel.CHANNEL_BEACH or
  1492. channel_id == ChatModel.CHANNEL_COUNTRY
  1493. end
  1494. -- 根据频道channel清除聊天缓存和聊天内容条目数量
  1495. function ChatModel:ClearAllMsgDataByChannel(channel)
  1496. if not channel then return end
  1497. self.all_chat_list[channel] = nil
  1498. self.all_chat_list_count[channel] = nil
  1499. end
  1500. ----------主界面聊天社团图标红点-start---------
  1501. function ChatModel:SetGuildChannelRedDot( bool )
  1502. if self.has_new_guild_red == nil then
  1503. self.has_new_guild_red = 0
  1504. end
  1505. if bool then
  1506. self.has_new_guild_red = self.has_new_guild_red + 1
  1507. else
  1508. self.has_new_guild_red = 0
  1509. end
  1510. self:Fire(ChatModel.Update_MAINUI_GUILD_MSG_RED)
  1511. end
  1512. function ChatModel:GetGuildChannelRedDot( )
  1513. return self.has_new_guild_red or 0
  1514. end
  1515. -- 初始化登陆时间(用来区别历史消息)
  1516. function ChatModel:InitLoginTime( )
  1517. self.login_time_cache = TimeUtil:getServerTime()
  1518. self:SetGuildChannelRedDot( false )
  1519. end
  1520. ----------主界面聊天社团图标红点-end-----------
  1521. --版本更新的提示
  1522. function ChatModel:SetClientUpdateInfo( vo )
  1523. self.client_update_info = vo
  1524. end
  1525. function ChatModel:GetClientUpdateInfo( )
  1526. return self.client_update_info
  1527. end