Skip to content

Botreview#25

Merged
borlowsky merged 49 commits intomainfrom
botreview
Nov 4, 2025
Merged

Botreview#25
borlowsky merged 49 commits intomainfrom
botreview

Conversation

@Nemat7
Copy link
Collaborator

@Nemat7 Nemat7 commented Nov 3, 2025

Merging botreview with main. Main changes in bot.py file

jdavid and others added 30 commits July 7, 2025 18:52
- get_irrigation_data now takes optional chat_id
- use job ids to simplify code
- minor coding style
- remove unused functions
- use databases instead of PyMySQL
1. translated all comments from russian into english.
2. Deleted No water button.
3. Changed buttons name to Start Irrigation and Irrigation finished also in message handlers.
4. In get_irrigation_data function in SQL script add new measurement_device as device (in Sites table in fieldproperties column we need to add measurement_device parameter).
1. Added conditions for control and treatment plots with three type of devices
2. Added new save_irrigation_data function (in some places i used this function just to check.)
3. new message handler waiting_for_water_level_control was added
4. Also other message handlers was amended (according to Boris flow that he sent)
fixed save_irrigation_data, check_irrigation function
added function send_message_safe
put logging in all steps
changed check_irrigation function and get_irrigation_data function
1. Remove the “Select action” message after the /start command
2. Add 0 value in WATER_FLOW_RATES dictionary
3.  added a reset of the user_irrigation_data at the beginning of a new irrigation session Line:403
added new conditions 
1. if irrigation_app is not None and irrigation_app != 'NA'
2. if (phic is not None and phit is not None and phic >= phit and irrigation_need != 'NA'
3. if row get_irrigation_data is none
Changed /start command text into "The bot has started successfully." #40 issue on Git
in line: 640 msg was edited according to issue #45 on Git
line 516 structured as was required:
'type': 'control',
'device': 'thomson_profile',
New logic was added in start function. Complete clearing of irrigation data with the /start command.
case PHIc > PHIt was moved to check_irrigation function
NA was changed by NULL
round minutes
removed None and NULL conditions
Before we converted minutes to hour as float, and then back to hours +
minutes in 3 different places.

Now we calculate hours + minutes once in the beginning.
Simplify get_irrigation_data:
- Consider it's an error when no irigiation data is found (send message to user)
- Return None instead of False when there is an error

Review calls to get_irrigation_data
Removed finally block that incorrectly reset user state on every execution. State now resets only on successful completion or critical exceptions. Maintains state for logical errors (end <= start) for correct re-entry (in waiting_for_counter_end handler)
Also in irrigation_finished handler removed (else condition) in control and treatment type with incremental_meter device
Removed waiting_for_traditional_start and waiting_for_traditional_end handlers
add condition to check for negative numbers in start_irrigation
add conditions in treatment and control types for incremental_meter device if user push Irrigation finished button instead Start irrigation button
changed condition in L396 (set it to if remaining_time >= 0)
borlowsky and others added 19 commits September 26, 2025 16:11
In Start irrigation and Irrigation finished handlers for device = incremental_meter for control and treatment types condition was added in one
Also for total_meter device conditions for control and treatment was changed into one
In the beginning for control type with thomson_profile device save message was different then others. Now insert changes and now all save messages are the same
Add condition for negative check numbers in handle_actual_data function.
L:466 return was missed. Now fixed
changed to 24 * 60
The basic idea is to get the data once at the top level and pass it down the call stack, instead of requesting it again each time in save_irrigation data. Callbacks also was changed.
And don't send cryptic message to the user on error
check for 'type' was removed for "incremental_meter" device and also for "total_meter" device was removed check for "type" in handle_recommendation function.
Additional conditions were removed in L702 and L709
Fixed handle_actual_data function. Moved user_states[chat_id]=None after save_irrigation_data. Now even when you type wrong number bot will wait until you type correct number
Removed 'Enough water, stop irrigation' message in handle_water_level function. Now we get only one message when irrigation time is finished
Removed send_recommendation function and also removed else condition where it was calling to this function
changed int type into float type where we requesting users to send counter number
@borlowsky borlowsky merged commit bdc2c6a into main Nov 4, 2025
2 checks passed
@jdavid jdavid deleted the botreview branch December 4, 2025 12:13
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.

3 participants