How to automate HoneyGain lucky pot opening with Celery
In the world of passive income, HoneyGain is a popular choice for sharing unused internet bandwidth. One of its engaging features is the Lucky Pot, which gives users a chance to win extra credits every day. However, remembering to log in and open it manually can be a chore. In this post, we'll show how to automate this process using Celery and the pyHoneygain library.
Why Automate?
The Lucky Pot is available once every 24 hours after you've shared a certain amount of data. Automating this ensures:
- Consistency: You never miss a day of extra credits.
- Efficiency: No need to manually log into the dashboard or app.
- Integration: Receive an email notification with the results of your daily "win".
We'll use a Celery task that logs into HoneyGain, attempts to open the Lucky Pot, and sends the result via email. Here's the code for the task:
from decouple import config
from django.core.mail import EmailMessage
from pyHoneygain import HoneyGain
from core.celery import app
@app.task
def task_honeygain_open_lucky_pot():
# Your HoneyGain (HG) login username and password from environment variables
USER = config("HONEYGAIN_USER")
PASSWORD = config("HONEYGAIN_PASSWORD")
# Initialize the HoneyGain object
user = HoneyGain()
# Call the login method
user.login(USER, PASSWORD)
# Attempts to open Honeypot
honeypot_information = user.open_honeypot()
subject = "HoneyGain - lucky pot information"
if honeypot_information["success"]:
message = (
f"Congratulations, you received {honeypot_information['credits']} credits!"
)
else:
message = "The HoneyGain lucky pot is unavailable at the moment!"
email = EmailMessage(
subject, message, "sender@example.com", ["receiver@domain.com"]
)
email.send(fail_silently=False)
Scheduling with Celery Beat
Since the Lucky Pot reset time can vary slightly, we schedule the task to run twice a day to ensure we catch the availability window. We use crontab for precise scheduling:
from celery.schedules import crontab
app.conf.beat_schedule = {
# ... other tasks ...
"task_honeygain_open_lucky_pot": {
"task": "frontend.tasks.task_honeygain_open_lucky_pot",
"schedule": crontab(hour="0, 12", minute="12"),
},
}
Prerequisites
To run this automation, you'll need:
- A Django project with Celery and Redis configured.
- The
pyHoneygainlibrary installed (pip install pyHoneygain). You can find it on PyPI. - Environment variables
HONEYGAIN_USERandHONEYGAIN_PASSWORDset in your.envfile.
Conclusion
Automating repetitive tasks like opening the HoneyGain Lucky Pot is a perfect use case for Celery. It saves time and ensures you're maximizing your passive income with zero daily effort. Happy automating!