-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to figure out how to get robut to join rooms when invited #41
Comments
OK! I figured this out. It turns out that you can't join rooms from within an xmpp4r callback. So you'll have to somehow flag that robut wants to join a room from within the callback, and actually join the room from the main thread. I was able to hack it into working by doing something like: in pm.rb def invited(message, conn)
if message.type.nil?
p message.to_s
if message.to_s =~ /invite/ # because I didn't want to figure out how to traverse to see the <invite> just to see if this worked at all
begin
room_name = "#{message.from.node}@conf.hipchat.com"
puts "joining #{room_name}"
connection.joins = room_name
rescue => e
p e
end
end
end
end in connection.rb attr_accessor :joins
def handle_join
self.config.logger.info 'trying join...'
if self.joins
room = Robut::Room.new(self, self.joins)
room.join
self.rooms << room
room.reply("I am here", nil)
self.joins = nil
end in bin/robut loop { connection.handle_join; sleep 1 } But this is pretty clearly terrible. I'm sure there's a way to do it relatively cleanly, though! |
Thanks for looking into it. Terrible is a great start. I'll give this a spin soon |
Been using this for a long time now it's great |
The only thing, on a private server (#47) room_name = "#{message.from.node}@conf.hipchat.com" has to be changed to room_name = "#{message.from.node}@conf.btf.hipchat.com" or, when mentioned in another room robut will crash |
Nice! This has been on my list of things to follow up on. The change works, but I wanted to write some tests for it, and couldn't figure out how to fake XMPP messages to try it out. |
Also, holy crap March!? Where did the year go |
@justinweiss, @will , I'm working on the same thing as you did to get a bot join a channel on invite. I've got most of it working. I'm seeing the "joining message" (nice work on that) on invites but I'm having issues with adding the loop part to /bin/robut.. Do you have a working sample of bin/robut ?? |
Lucky me, I somehow still had my uncommitted code on this machine! I'll push it to a branch. |
Thanks so much
|
OK, give https://github.com/justinweiss/robut/tree/accept_invites a try. I don't remember quite what state it was in, but I think it should be working. |
The supplied code throws this error:
Here's my working config:
pm.rb
connection.pm
I tried pushing this change to this branch but I don't have permissions |
Hi Justin, You code example throws some errors. I added it to the branch. Thanks so much for you help Gerard
|
Thanks! Sorry it wasn’t totally working — it’s been a while since I’ve had the chance to work on it.
|
I'd like to have the bot appear in rooms when you @ mention it.
I've figured out how to notice the invite, but joining the room after
Connection.new.connect
doesn't seem to workInvitaitons look like
Notably the message does not have a type.
I was able to just quick hack into the PM class to print something when invited:
The Room.new and the #join don't raise exceptions, but the bot never joins the room.
Any ideas how to do this?
The text was updated successfully, but these errors were encountered: