Project

General

Profile

« Previous | Next » 

Revision 2fd36b40

Added by Marc Dequènes over 14 years ago

  • ID 2fd36b409515560b0d0b84b02f065750db8a935d

[fix] repaired bot stop action

View differences:

lib/cyborghood/imap.rb
end
def check_mails(&message_handler)
@stop_mail_check = false
until @stop_mail_check
t = Time.now.to_i
r = check_mails_once(&message_handler)
......
# wait before new check either if the IMAP server does not support IDLE mode
# or if an error occured
sleep_time = @min_check_interval - (t2 - t)
if sleep_time > 0
if sleep_time > 0 and not @stop_mail_check
logger.debug "Having a break before new check..."
begin
sleep(sleep_time)
rescue
t = Time.now.to_i
while Time.now.to_i - t < sleep_time and not @stop_mail_check
sleep(1)
end
end
end
end
def stop_mail_check
@stop_mail_check = true
end
def check_inbox(&message_handler)
logger.debug "Examining INBOX"
@imap.select('INBOX')
logger.debug "Starting mail check"
@imap.search(["ALL"], "UTF-8").each do |message_id|
break if @stop_mail_check
logger.debug "*** Fetched mail ##{message_id}"
unless message_handler.call IMAPMessage.new(@imap, message_id)
@stop_mail_check = true
......
end
logger.debug "Mail check finished"
# TODO: expunge after <n> mails processed in IDLE mode
@imap.expunge
end

Also available in: Unified diff