|
#!/usr/bin/ruby -Ku
|
|
|
|
$: << "./lib"
|
|
|
|
require 'cyborghood/cyborg'
|
|
|
|
module CyborgHood
|
|
class Guard < Cyborg
|
|
ROOM_PARAMS = {
|
|
'muc#roomconfig_allowinvites' => 0,
|
|
'muc#roomconfig_changesubject' => 0,
|
|
'muc#roomconfig_membersonly' => 1,
|
|
'muc#roomconfig_publicroom' => 1,
|
|
'muc#roomconfig_persistentroom' => 1,
|
|
'muc#roomconfig_roomsecret' => 'moderators',
|
|
}
|
|
|
|
def initialize
|
|
super {
|
|
@in_room = true
|
|
}
|
|
end
|
|
|
|
def run
|
|
super do
|
|
logger.debug "COIN !"
|
|
p @muc.roster.collect{|k, v| [k, v.show] }
|
|
#sleep 3
|
|
Thread.stop
|
|
p "pompompom"
|
|
p @muc.roster.collect{|k, v| [k, v.show] }
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def on_missing_room
|
|
logger.info "CyborgHood HeadQuarters meeting room does not exist yet; creating..."
|
|
|
|
logger.debug "Fetching and checking room config form"
|
|
room_config_form = @muc.get_room_configuration
|
|
missing_params = ROOM_PARAMS.keys - room_config_form
|
|
unless missing_params.empty?
|
|
logger.fatal "CyborgHood HeadQuarters do not provide the following meeting room facilities: " + missing_params.join(", ")
|
|
quit(true)
|
|
end
|
|
|
|
logger.debug "Setting room configuration"
|
|
@muc.submit_room_configuration(ROOM_PARAMS)
|
|
end
|
|
|
|
def on_existing_room
|
|
logger.debug "Checking ownership"
|
|
unless @muc.owner?
|
|
logger.fatal "CyborgHood HeadQuarters meeting room has been taken over !!!"
|
|
quit(true)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
#Jabber::debug = true
|
|
|
|
bot = CyborgHood::Guard.new
|
|
|
|
trap('INT') do
|
|
bot.ask_to_stop
|
|
end
|
|
trap('TERM') do
|
|
bot.ask_to_stop
|
|
end
|
|
|
|
bot.run
|
|
|