diff --git a/folder.rb b/folder.rb index 12f3cb2..900bc23 100644 --- a/folder.rb +++ b/folder.rb @@ -11,8 +11,17 @@ class Folder end def curse(user) - @steves.delete(user.id) - @fallen.append(user.id) + if @steves.include?(user.id) + @steves.delete(user.id) + @fallen.append(user.id) + end + end + + def bless(user) + if @fallen.include?(user.id) + @steves.append(user.id) + @fallen.delete(user.id) + end end def steve?(user) @@ -35,21 +44,17 @@ class Folder end message = @submissions.sample i = 0 - #until message.sender != target or i == 5 do - # message = @submissions.sample - # i = i + 1 - #end + until message.sender != target or i == 5 do + message = @submissions.sample + i = i + 1 + end if i == 5 return nil end @submissions.delete(message) - if File.exist?(message.content) + if message.local and not File.exist?(message.content) return nil end - - if message.local - File.delete(message.content) if File.exist?(message.content) - end return target,message end end diff --git a/main.rb b/main.rb index 10f6b72..202b88b 100755 --- a/main.rb +++ b/main.rb @@ -99,7 +99,9 @@ loop do logger.info("sleeping for #{timer} seconds") sleep timer t = Time.new - if t.hour < 9 or t.hour > 2 + if t.hour < 9 and t.hour > 2 + puts t.hour + logger.info("skipping send cuz it's late") next end sid,msg = folder.harass_steve() @@ -111,6 +113,7 @@ loop do logger.info("sending submission #{msg.id}") if msg.local steve.send_file(File.open(msg.content,'r')) + File.delete(msg.content) else steve.pm(msg.content) end