Skip to content
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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

karlvonbonin
Copy link

Hi,

ive added a counter and Telegram message to post all 5 (or x minutes) that the bot is still running.

@karlvonbonin karlvonbonin mentioned this pull request Dec 22, 2021
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"})
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamtodor should be done

Copy link
Contributor

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
Copy link
Collaborator

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

Copy link
Collaborator

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")
Copy link
Collaborator

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"})
Copy link
Collaborator

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

@Linus045 Linus045 linked an issue Dec 28, 2021 that may be closed by this pull request
@Linus045 Linus045 changed the base branch from master to develop January 3, 2022 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Status messages
3 participants