-
-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Telegram update every 5 (or X minutes) - that the bot is still alive #125
base: develop
Are you sure you want to change the base?
Add Telegram update every 5 (or X minutes) - that the bot is still alive #125
Conversation
src/main.py
Outdated
@@ -464,4 +463,4 @@ def main(): | |||
if __name__ == '__main__': | |||
logger.info('started working...') | |||
main() | |||
logger.info('stopped working...') | |||
logger.info('coinbot is offline', extra={"TELEGRAM": "STOPPED_WORKING"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alphavader I'd suggest changing the start bot message as well. In the same way, you've done it for stopping: add extra for telegram. And, please, make the message consistent: online - offline, start - stop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamtodor should be done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alphavader please, make the message consistent: coinbot is online - coinbot is offline. not like started working and coinbot is offline
@@ -140,13 +141,17 @@ def search_and_update(): | |||
""" | |||
Pretty much our main func | |||
""" | |||
counter = 0 | |||
botPostAllMinutes = 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value should be configurable via the config,yml and not be hardcoded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also have some value to disable it e.g. 0 or -1.
@@ -155,7 +160,11 @@ def search_and_update(): | |||
if os.path.isfile('test_new_listing.json.used'): | |||
os.remove('test_new_listing.json.used') | |||
os.rename('test_new_listing.json', 'test_new_listing.json.used') | |||
logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread)") | |||
logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread) - bot is running for {str(counter / 3600)} hours - {str(counter/60)} minutes and {str(counter)} seconds") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the total runtime matter? Why is it printed here?
logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread)") | ||
logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread) - bot is running for {str(counter / 3600)} hours - {str(counter/60)} minutes and {str(counter)} seconds") | ||
if ((counter / 60) % botPostAllMinutes) == 0: | ||
logger.info(f"Bot is still running for {str(counter/60)} minutes - will give live sign in {str(botPostAllMinutes)} Minutes again.", extra={"TELEGRAM": "START_WORKING"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should generally be done outside of the listings scraper functionality.
If you just want a sign that the bot is still running, there is no need to do it here.
I would prefer a separate thread which which utilises time.sleep instead of having a counter variable which requires unnecessary processing power
Hi,
ive added a counter and Telegram message to post all 5 (or x minutes) that the bot is still running.