Skip to content

Commit

Permalink
Fix checks on missed events
Browse files Browse the repository at this point in the history
  • Loading branch information
iranzo committed Jul 3, 2017
1 parent 066bf02 commit c7f825f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion stampy/plugin/comic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ def init():
if botname == 'redken_bot':
delay = int(random.randint(0, 10))
when = 30 + delay
sched.add_job(comics, 'interval', id='comic', minutes=when, replace_existing=True, misfire_grace_time=120)
sched.add_job(comics, 'interval', id='comic', minutes=when,
replace_existing=True, misfire_grace_time=120,
coalesce=True)

triggers = ["^/comic"]
for comic in getcomics():
triggers.extend(["/%s" % comic])

# Refresh comics in case bot was down:
comics()

return triggers


Expand Down
10 changes: 7 additions & 3 deletions stampy/plugin/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def init():
botname = stampy.stampy.getme()
if botname == 'redken_bot':
when = 5
sched.add_job(feeds, 'interval', id='feeds', minutes=when, replace_existing=True, misfire_grace_time=120)
sched.add_job(feeds, 'interval', id='feeds', minutes=when,
replace_existing=True, misfire_grace_time=120,
coalesce=True)

triggers = ["^/feed"]

Expand Down Expand Up @@ -212,8 +214,8 @@ def feeds(message=False, name=False):
"""
logger = logging.getLogger(__name__)

date = datetime.datetime.now()
utc = pytz.utc
date = utc.localize(datetime.datetime.now())

if message:
msgdetail = stampy.stampy.getmsgdetail(message)
Expand Down Expand Up @@ -276,7 +278,9 @@ def feeds(message=False, name=False):
# If more time has passed since last check than the interval for
# checks, run the check

if timediff >= interval:
if timediff < interval:
logger.debug(msg=_L("Skipping feed %s because last run was %s mins ago (%s required") % (name, timediff, interval))
else:
# Get the feed
feed = feedparser.parse(url)
news = []
Expand Down

0 comments on commit c7f825f

Please sign in to comment.