Open the0x1d3 opened 2 months ago
Hi @the0x1d3, It’s better to keep the discussion in English so others who have the same question or issue can find the solution more easily. Regarding:
… it publishes “tot” of them en masse…e.g. 4 or 5 in a few seconds. Could this be made maybe more “natural”? Do you have any tricks to recommend?
If I understood correctly, you want to add more time between sending different messages, right? For example:
• Send the first message.
• Wait 35 seconds.
• Send the second message.
• Wait 1 minute.
• Send the third message.
• Wait 2 minutes and 34 seconds.
• Send the fourth message.
• And so on…
If this is correct, then currently, there is no built-in way to adjust the timing through a simple parameter like the bot’s working time. However, you can achieve this by adding a sleep
function with a list of preselected times in seconds. Alternatively, you can introduce a probability distribution for the waiting times.
Here’s how you can modify the code:
Open the file src/utils/bot_starter.py
and modify the code as follows:
asin_sended_list = []
sleep_times = [10, 30, 75, 85, 120] # List of sleep durations in seconds (10sec, 30sec, 1min 15 sec ....)
for product in selected_products:
result = communication_handler.single_message(bot, product)
if result:
asin = database_builder.add_to_database(product)
asin_sended_list.append(asin)
# Sleep for a random duration before the next iteration
sleep_duration = random.choice(sleep_times)
time.sleep(sleep_duration)
database_builder.correctly_added(asin_sended_list)
time_scheduler.waiting_next_iteration()
You can adjust the list of seconds based on your preference. After each message, the bot will wait for a randomly chosen duration from the list before proceeding to the next iteration.
Open the file src/utils/bot_starter.py
and modify the code as follows:
asin_sended_list = []
# List of sleep durations in seconds (10sec, 30sec, 1min 15 sec ....)
sleep_times = [10, 30, 75, 85, 120]
# Probability distribution for each sleep time (The probability that the bot take the value 10
# (in a scale between 0 and 1) is 0.1, the third is 0.4 ...) **Note:** the total sum of the value
# in the probabilitylist must be 1 and the number of element in the list sleep_times
# must be the same as the one in probabilities.
probabilities = [0.1, 0.2, 0.4, 0.2, 0.1]
for product in selected_products:
result = communication_handler.single_message(bot, product)
if result:
asin = database_builder.add_to_database(product)
asin_sended_list.append(asin)
# Sleep for a random duration based on the probability distribution
sleep_duration = random.choices(sleep_times, probabilities)[0]
time.sleep(sleep_duration)
database_builder.correctly_added(asin_sended_list)
time_scheduler.waiting_next_iteration()
In this case, the bot selects a waiting time with the corresponding probability after each iteration.
You can also set a range so that the bot picks a random value and then selects a time within that range. For example:
asin_sended_list = []
sleep_times = [1, 2, 3, 4, 5] # List of sleep durations in seconds
probabilities = [0.1, 0.2, 0.4, 0.2, 0.1] # Probability distribution for each sleep time
for product in selected_products:
result = communication_handler.single_message(bot, product)
if result:
asin = database_builder.add_to_database(product)
asin_sended_list.append(asin)
# Select a sleep duration based on the probability distribution
selected_sleep_time = random.choices(sleep_times, probabilities)[0]
# Choose a random sleep time between the selected value and its half
sleep_duration = random.uniform(selected_sleep_time / 2, selected_sleep_time)
time.sleep(sleep_duration)
database_builder.correctly_added(asin_sended_list)
time_scheduler.waiting_next_iteration()
In this version, the bot picks a random sleep time between the selected value and half of that value.
Note: If you’d like to contribute to the project by adding new features or making improvements, feel free to fork the repository and create a pull request with your changes. I’ll review your contributions and, if everything looks good, I’ll merge them into the main project.
Dear Pietro24,
I thank you again for the excellent work of the bot.
I wanted to ask you a little information, I noticed that the bot when it has valid bids to be published, it publishes “tot” of them en masse...e.g. 4 or 5 in a few seconds.
Could this be made maybe more “natural”? do you have any tricks to recommend?
This is my test channel: https://t.me/AffariTechItalia
PS: if you want we can talk in Italian :) PPS: if you need API Keys to improve the bot I can provide them to you on Telegram.
Regards,