class Lita::Handlers::Ops

Public Instance Methods

op(payload) click to toggle source
# File lib/lita-ops.rb, line 31
def op(payload)
  cinch = robot.send(:adapter).cinch
  nick = cinch.user_list.find_ensured(payload[:user].name)
  channel = payload[:room].name

  payload[:room].op(robot, nick) if should_be_oped?(channel, nick)
end
should_be_oped?(channel, nick) click to toggle source
# File lib/lita-ops.rb, line 19
def should_be_oped?(channel, nick)
  if config.should_be_oped.include?(channel)
    config.should_be_oped[channel].each do |u|
      if Cinch::Mask.new(u) =~ nick.mask
        log.debug "#{u} matched!"
        return true
      end
    end
  end
  return false
end