Getting IRC Nicks
Closed this issue · 2 comments
So I'm trying to get nicks via IRC and keep a live sync / feed of them in my system. Is this the proper way?
c := irc.Client(cfg)
c.EnableStateTracking()
c := conn.StateTracker().GetChannel(*channel)
if c == nil {
log.Println("failed to get channel, skipping..")
return
}
nicks := c.NicksStr()
fmt.Printf("adding %d nicks to monitor\n", len(nicks))
I also noticed that the GetChannel randomly returns empty.
I'm catching "366" and trying to catch after /names runs on a channel.
First, you probably want to pull the changes I just merged into master. That ought to take care of the possibility that it's the state tracking race conditions that are causing your problems.
Second, I could do with a little more detail, ideally your Actual Code. Your example here doesn't include actually joining any channels or sending a NAMES command to elicit the 366 response. The state tracking handlers in client/state_handlers.go only track channels the client has JOINed, and send WHO #channel instead of NAMES #channel to get the list of channel users.
If you want speedy help find me on freenode #go-nuts; I've got about an hour left this evening before I have to go be a responsible adult again.
For reference: this is a problem with Twitch's "IRC" server which is not dealing well under load. I say "IRC" because they have clearly implemented their own half-arsed fake IRCd that:
- doesn't support a pretty wide range of commands (including WHO which the state tracker uses)
- has multiple-minute latency problems joining a new nick to a channel containing 3k+ users
- provides an empty NAMES list on "joining" a channel, then issues post-hoc JOIN and MODE lines for other channel users
It looks suspiciously like they've backed this thing off a persistent data store and are having problems doing whatever SELECT (or equivalent) queries they need to to model an IRC channel. I imagine this is so that web clients can sync chat too, but ye gods the latency.