Skip to content

Commit

Permalink
FIxed Queue voting issues
Browse files Browse the repository at this point in the history
1. Upvote check to ensure not attempting to vote again which has had a tendency to lock up the bot.
2. Sends discord message when bot is sleeping to avoid early voting (<15 min)
  • Loading branch information
anthonyadavisii authored Jan 24, 2019
1 parent c82c13b commit 8e12349
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions sfrbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def fill_embed(embed: discord.Embed, names: list, template: str):

async def queue_voting(ctx, sfr):
"""
Voting on steemflagrewards mentions one after one once the voting power of the account reached 90%. This maintains a rather staple flagging ROI
Voting on steemflagrewards mentions one after one once the voting power of the account reached 90%. This maintains a rather stable flagging ROI
"""
global queueing
while queueing:
Expand All @@ -285,18 +285,32 @@ async def queue_voting(ctx, sfr):
comment_age = comment.time_elapsed()
if comment_age < datetime.timedelta(minutes=15):
sleeptime = (datetime.timedelta(minutes=15) - comment_age).total_seconds()
await ctx.send('Comment is younger than 15 mins - sleeping for %.1f mins.' % (sleeptime/60))
logging.info('Comment is younger than 15 mins - sleeping for %.1f mins.' % (sleeptime/60))
await asyncio.sleep(sleeptime)
try:
comment.upvote(weight, sfr.name)
await asyncio.sleep(cfg.STEEM_MIN_VOTE_INTERVAL) # sleeps to account for STEEM_MIN_VOTE_INTERVAL
if not sfr.get_vote(comment):
comment.upvote(weight, sfr.name)
await asyncio.sleep(cfg.STEEM_MIN_VOTE_INTERVAL) # sleeps to account for STEEM_MIN_VOTE_INTERVAL
else:
await ctx.send('Already voted on this!')
cursor.execute('UPDATE steemflagrewards SET queue = 0 WHERE comment == ?', (authorperm,))
db.commit()
sfr.refresh()
return
except VotingInvalidOnArchivedPost:
await ctx.send(
'Sadly one comment had to be skipped because it got too old.'
'Maybe the author can delete the comment and write a new one?')
cursor.execute('UPDATE steemflagrewards SET queue = 0 WHERE comment == ?', (authorperm,))
db.commit()
continue
except Exception as e:
await ctx.send(f'Something went wrong while upvoting {comment.author}\'s comment. Skipping it.')
logging.exception(e)
cursor.execute('UPDATE steemflagrewards SET queue = 0 WHERE comment == ?', (authorperm,))
db.commit()
continue
await ctx.send(f'Sucessfully voted on mention by {flagger} out of the queue.')
if not follow_on:
await asyncio.sleep(get_wait_time(sfr))
Expand All @@ -310,7 +324,6 @@ async def queue_voting(ctx, sfr):
sfr.refresh()
return


loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
bot = Bot(description='SteemFlagRewards Bot', command_prefix='?')
Expand Down

0 comments on commit 8e12349

Please sign in to comment.