Sha256: 8436c9d0149814e1b15d796706ed6cf374bcde52e48a39bd5da90c98d140611e
Contents?: true
Size: 1.27 KB
Versions: 13
Compression:
Stored size: 1.27 KB
Contents
class SlackSmartBot def check_vacations(date: Date.today, user: nil, set_status: true, only_first_day: true) get_vacations() if user.nil? users = @vacations.keys else users = [user] end on_vacation = [] users.each do |user| type = nil expiration = nil @vacations[user].periods.each do |p| if only_first_day and p.from == date.strftime("%Y/%m/%d") type = p.type on_vacation << user expiration = p.to break elsif !only_first_day and p.from <= date.strftime("%Y/%m/%d") and p.to >= date.strftime("%Y/%m/%d") type = p.type on_vacation << user expiration = p.to break end end unless type.nil? or !set_status icon = '' if type == 'vacation' icon = ':palm_tree:' elsif type == 'sick' icon = ':face_with_thermometer:' elsif type == 'sick child' icon = ':baby:' end unless icon.empty? expiration_date = Date.parse(expiration,'%Y/%m/%d') + 1 #next day at 0:00 set_status(@vacations[user].user_id, status: icon, expiration: expiration_date, message: "#{type} until #{expiration}") end end end return on_vacation end end
Version data entries
13 entries across 13 versions & 1 rubygems