Commit ddad14fbd6cd20efc2be6aea8ceb313b39c647ea

Authored by dg
1 parent a7ed90d5

fix


git-svn-id: http://svn.net-core.org/repos/t-engine4@2893 51575b47-30f0-44d4-a5cc-537603b46e54
... ... @@ -73,14 +73,14 @@ function _M:event(e)
73 73 self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
74 74 self.channels[e.channel].users[e.login] = {name=e.name, login=e.login}
75 75 self.channels_changed = true
76   - self:addMessage(e.channel, e.user, "#{italic}##FIREBRICK#has joined the channel#{normal}#")
77   - if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has joined channel %s (press space to talk).#{normal}#", e.user, e.channel) end
  76 + self:addMessage(e.channel, e.login, e.name, "#{italic}##FIREBRICK#has joined the channel#{normal}#")
  77 + if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has joined channel %s (press space to talk).#{normal}#", e.login, e.channel) end
78 78 elseif e.se == "Part" then
79 79 self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
80 80 self.channels[e.channel].users[e.login] = nil
81 81 self.channels_changed = true
82   - self:addMessage(e.channel, e.user, "#{italic}##FIREBRICK#has left the channel#{normal}#")
83   - if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has left channel %s.#{normal}#", e.user, e.channel) end
  82 + self:addMessage(e.channel, e.login, e.name, "#{italic}##FIREBRICK#has left the channel#{normal}#")
  83 + if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has left channel %s.#{normal}#", e.login, e.channel) end
84 84 elseif e.se == "UserInfo" then
85 85 local info = e.data:unserialize()
86 86 if not info then return end
... ...
... ... @@ -328,6 +328,13 @@ function _M:orderChatJoin(o)
328 328 end
329 329 end
330 330
  331 +function _M:orderChatPart(o)
  332 + self:command("Part", o.channel)
  333 + if self:read("200") then
  334 + self.chat:parted(o.channel)
  335 + end
  336 +end
  337 +
331 338 function _M:orderChatUserInfo(o)
332 339 self:command("UINF", o.user)
333 340 if self:read("200") then
... ...
... ... @@ -25,33 +25,41 @@ module(..., package.seeall, class.make)
25 25 function _M:init(client)
26 26 self.client = client
27 27 self.channels = {}
28   - self.joined = {}
  28 + self.cjoined = {}
29 29 end
30 30
31 31 function _M:event(e)
32 32 if e.e == "ChatTalk" then
33 33 cprofile.pushEvent(string.format("e='Chat' se='Talk' channel=%q login=%q name=%q msg=%q", e.channel, e.login, e.name, e.msg))
34   - print("[USERCHAT] channel talk", e.user, e.channel, e.msg)
  34 + print("[USERCHAT] channel talk", e.login, e.channel, e.msg)
35 35 elseif e.e == "ChatJoin" then
36 36 self.channels[e.channel] = self.channels[e.channel] or {}
37   - self.channels[e.channel][e.user] = true
  37 + self.channels[e.channel][e.login] = true
38 38 cprofile.pushEvent(string.format("e='Chat' se='Join' channel=%q login=%q name=%q ", e.channel, e.login, e.name))
39   - print("[USERCHAT] channel join", e.user, e.channel)
  39 + print("[USERCHAT] channel join", e.login, e.channel)
40 40 elseif e.e == "ChatPart" then
41 41 self.channels[e.channel] = self.channels[e.channel] or {}
42   - self.channels[e.channel][e.user] = nil
  42 + self.channels[e.channel][e.login] = nil
43 43 cprofile.pushEvent(string.format("e='Chat' se='Part' channel=%q login=%q name=%q ", e.channel, e.login, e.name))
44   - print("[USERCHAT] channel part", e.user, e.channel)
  44 + print("[USERCHAT] channel part", e.login, e.channel)
45 45 end
46 46 end
47 47
48 48 function _M:joined(channel)
49   - self.joined[channel] = true
  49 + self.cjoined[channel] = true
  50 + print("[ONLINE PROFILE] connected to channel", channel)
  51 +end
  52 +
  53 +function _M:parted(channel)
  54 + self.cjoined[channel] = nil
  55 + print("[ONLINE PROFILE] parted from channel", channel)
50 56 end
51 57
52 58 function _M:reconnect()
53 59 -- Rejoin every channels
54   - for chan, _ in pairs(self.joined) do
55   - client:orderChatJoin{channel=chan}
  60 + print("[ONLINE PROFILE] reconnecting to channels")
  61 + for chan, _ in pairs(self.cjoined) do
  62 + print("[ONLINE PROFILE] reconnecting to channel", chan)
  63 + self.client:orderChatJoin{channel=chan}
56 64 end
57 65 end
... ...
... ... @@ -23,7 +23,7 @@ local Client = require "profile-thread.Client"
23 23 local c = Client.new()
24 24
25 25 function step_profile()
26   - local ok, res = xpcall(function() return c:run() end, function(...) server:logError("[profile-thread-error:stacktrace] %s", debug.traceback(...)) end)
  26 + local ok, res = xpcall(function() return c:run() end, debug.traceback)
27 27 if not ok and res then
28 28 print("[PROFILE THREAD] error", res)
29 29 return false
... ...