cinchrb / cinch

The IRC Bot Building Framework
http://www.rubydoc.info/gems/cinch
MIT License
1k stars 180 forks source link

User.channels returns an empty array #123

Closed tilegg closed 11 years ago

tilegg commented 11 years ago

I'm writing a bot for quakenet, when trying to get a users channels using the user.channels-method, cinch returns an empty array.

A short snippet what I'm trying to archive:

on :private, "!status" do |m|
  auth_by_channel(m.user)
end

auth_by_channel(user)
  user.whois
  puts "CHANNELS: #{user.channels}"
end

=> []

I assume this is caused by the array generated by Cinch::IRC::on_319 is overwritten by Cinch::User::end_of_whois. If instead the array is submitted by using the @whois_updates[user].merge!-method in Cinch::IRC::on_319 the channels are assigned correctly (at least for me).

Additionally the regex (/#{@isupport["CHANTYPES"].join}[^ ]+/o) used by Cinch::IRC::on_319 did not create an array of Channel-objects in my project.

I'm using ruby 2.0.0p247 and cinch 2.0.5 on Linux.

I'm not sure if my change does not break any design-principles of cinch. Anyway I commited it to my fork, 3cd4e6c47c17f063f0a44288ef69a845ec7102c2

Maybe it's going to help you solving the problem :)

dominikh commented 11 years ago

Yeah, looks like you found two bugs in the on_319 method (wrong regexp and wrong way of setting the channels). I'll test your change later today and commit it if it works.

If you send your change as a pull request I'll merge them with your name.