| 147 | | post nil, RPL_WHOISUSER, me.nick, pref.nick, pref.user, pref.host, "*", real_name |
| 148 | | post nil, RPL_WHOISSERVER, me.nick, pref.nick, pref.nick, pref.host, server_info |
| 149 | | # post nil, RPL_WHOISOPERATOR, me.nick, pref.nick, "is an IRC operator" |
| 150 | | # post nil, RPL_WHOISIDLE, me.nick, pref.nick, idle, "seconds idle" |
| 151 | | post nil, RPL_WHOISCHANNELS, me.nick, pref.nick, channels.map {|i| "@#{i}" }.join(" ") |
| 152 | | post nil, RPL_ENDOFWHOIS, me.nick, pref.nick, "End of WHOIS list" |
| | 149 | post nil, RPL_WHOISUSER, me.nick, prefix.nick, prefix.user, prefix.host, "*", real_name |
| | 150 | post nil, RPL_WHOISSERVER, me.nick, prefix.nick, prefix.nick, prefix.host, server_info |
| | 151 | # post nil, RPL_WHOISOPERATOR, me.nick, prefix.nick, "is an IRC operator" |
| | 152 | # post nil, RPL_WHOISIDLE, me.nick, prefix.nick, idle, "seconds idle" |
| | 153 | post nil, RPL_WHOISCHANNELS, me.nick, prefix.nick, channels.join(" ") |
| | 154 | post nil, RPL_ENDOFWHOIS, me.nick, prefix.nick, "End of WHOIS list" |
| 167 | | post nil, RPL_WHOREPLY, me.nick, channel, o_id, "lingr.com", "lingr.com", prefix.nick, "H*@", "0 #{o["description"].to_s.gsub(/\s+/, " ")}" |
| | 170 | op = (o["client_type"] == "human") ? "@" : "" |
| | 171 | post nil, RPL_WHOREPLY, me.nick, channel, o_id, "lingr.com", "lingr.com", prefix.nick, "H*#{op}", "0 #{o["description"].to_s.gsub(/\s+/, " ")}" |
| 254 | | when "system:enter" |
| 255 | | unless prefix.nick == myprefix.nick |
| 256 | | post prefix, JOIN, chan |
| 257 | | if m["client_type"] == "human" |
| 258 | | post server_name, MODE, chan, "+o", prefix.nick |
| 259 | | end |
| 260 | | info[:users][prefix.nick] = prefix |
| 261 | | end |
| 262 | | when "system:leave" |
| 263 | | unless prefix.nick == myprefix.nick |
| 264 | | post prefix, PART, chan |
| 265 | | info[:users].delete(prefix.nick) |
| 266 | | end |
| 267 | | when "system:nickname_change" |
| 268 | | m["nickname"] = m["new_nickname"] |
| 269 | | _, _, newprefix = *make_ids(m) |
| 270 | | post prefix, NICK, newprefix.nick |
| 271 | | info[:users].delete prefix.nick |
| 272 | | info[:users][newprefix.nick] = newprefix |
| | 268 | ## process as occupants list. |
| | 269 | # when "system:enter" |
| | 270 | # unless prefix.nick == myprefix.nick |
| | 271 | # post prefix, JOIN, chan |
| | 272 | # if m["client_type"] == "human" |
| | 273 | # post server_name, MODE, chan, "+o", prefix.nick |
| | 274 | # end |
| | 275 | # info[:users][prefix.nick] = m.merge("prefix" => prefix) |
| | 276 | # end |
| | 277 | # when "system:leave" |
| | 278 | # unless prefix.nick == myprefix.nick |
| | 279 | # post prefix, PART, chan |
| | 280 | # info[:users].delete(prefix.nick) |
| | 281 | # end |
| | 282 | # when "system:nickname_change" |
| | 283 | # m["nickname"] = m["new_nickname"] |
| | 284 | # _, _, newprefix = *make_ids(m) |
| | 285 | # post prefix, NICK, newprefix.nick |
| | 286 | # info[:users].delete prefix.nick |
| | 287 | # info[:users][newprefix.nick] = m.merge("prefix" => newprefix) |
| 281 | | res["occupants"].each do |o| |
| 282 | | if o["nickname"] |
| 283 | | u_id, o_id, prefix = make_ids(o) |
| 284 | | o["user_id"] = nil |
| 285 | | _, _, anonprefix = make_ids(o) |
| 286 | | |
| 287 | | unless info[:users].key?(prefix.nick) |
| 288 | | if info[:users].key?(anonprefix.nick) |
| 289 | | # when non-auth user be promoted to auth user. |
| 290 | | post anonprefix, NICK, prefix.nick |
| 291 | | info[:users].delete anonprefix.nick |
| 292 | | else |
| 293 | | post prefix, JOIN, chan |
| 294 | | if o["client_type"] == "human" |
| 295 | | post server_name, MODE, chan, "+o", prefix.nick |
| 296 | | end |
| 297 | | end |
| 298 | | info[:users][prefix.nick] = prefix |
| 299 | | end |
| | 296 | enter = [], leave = [] |
| | 297 | newusers = res["occupants"].reject {|i| i["nickname"].nil? }.inject({}) {|r,i| |
| | 298 | _, _, i["prefix"] = make_ids(i) |
| | 299 | r.update(i["prefix"].nick => i) |
| | 300 | } |
| | 301 | |
| | 302 | |
| | 303 | nickchange = newusers.inject({:new => [], :old => []}) {|r,(k,new)| |
| | 304 | old = info[:users].find {|l,old| |
| | 305 | # same occupant_id and different nickname |
| | 306 | # when nickname was changed and when un-authed user promoted to authed user. |
| | 307 | new["prefix"] != old["prefix"] && new["id"] == old["id"] |
| | 308 | } |
| | 309 | p old |
| | 310 | if old |
| | 311 | old = old[1] |
| | 312 | post old["prefix"], NICK, new["prefix"].nick |
| | 313 | r[:old] << old["prefix"].nick |
| | 314 | r[:new] << new["prefix"].nick |
| | 315 | end |
| | 316 | r |
| | 317 | } |
| | 318 | |
| | 319 | entered = newusers.keys - info[:users].keys - nickchange[:new] |
| | 320 | leaved = info[:users].keys - newusers.keys - entered - nickchange[:old] |
| | 321 | |
| | 322 | leaved.each do |leave| |
| | 323 | leave = info[:users][leave] |
| | 324 | post leave["prefix"], PART, chan, "" |
| | 325 | end |
| | 326 | |
| | 327 | entered.each do |enter| |
| | 328 | enter = newusers[enter] |
| | 329 | prefix = enter["prefix"] |
| | 330 | post prefix, JOIN, chan |
| | 331 | if enter["client_type"] == "human" |
| | 332 | post server_name, MODE, chan, "+o", prefix.nick |