fix: address issue causing failure to receive heartbeat#435
fix: address issue causing failure to receive heartbeat#435qin8948050 wants to merge 3 commits intowechaty:mainfrom
Conversation
|
xwqin seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
## Walkthrough
The changes in this pull request include renaming the `heart-beat` event to `heartbeat` in the `Wechaty` class for consistent event naming, whitespace cleanup and trailing space removal in the `Contact` class with an added explicit `return None` in the `say` method, and an enhancement to the `Room` class methods to support forced synchronization of room data via a new `force_sync` parameter.
## Changes
| File Path | Change Summary |
|------------------------------|-------------------------------------------------------------------------------------------------|
| src/wechaty/wechaty.py | Changed event name from `heart-beat` to `heartbeat` in `init_puppet_event_bridge` method for consistency. |
| src/wechaty/user/contact.py | Whitespace cleanup and trailing space removal; added explicit `return None` after sending `FileBox` in `say` method. |
| src/wechaty/user/room.py | Added `force_sync` parameter to `find_all` and `ready` methods to enable forced room data synchronization. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant Caller
participant Room
participant Puppet
Caller->>Room: find_all(query, force_sync)
loop for each room
Room->>Room: ready(force_sync)
alt force_sync is True or room not ready
Room->>Puppet: load room data
Puppet-->>Room: room data
else
Room-->>Room: return cached readiness
end
end
Room-->>Caller: list of ready rooms
|
There was a problem hiding this comment.
👍 Looks good to me! Reviewed everything up to a118af1 in 9 seconds
More details
- Looked at
13lines of code in1files - Skipped
0files when reviewing. - Skipped posting
0drafted comments based on config settings.
Workflow ID: wflow_2PHvTa8He8mPfgfT
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.
| await self.on_heartbeat(payload) | ||
|
|
||
| puppet.on('heart-beat', heartbeat_listener) | ||
| puppet.on('heartbeat', heartbeat_listener) |
There was a problem hiding this comment.
💡 Codebase verification
The event name 'heart-beat' still exists in the code and needs to be updated
Found remaining instances of 'heart-beat' in src/wechaty/wechaty.py that need to be updated for consistency:
- Line with
elif event_name == 'heart-beat': The condition should use 'heartbeat' - Line with
log.info('receive <heart-beat> event <%s>', payload): The log message should use 'heartbeat'
🔗 Analysis chain
LGTM! The event name change looks correct.
The change from 'heart-beat' to 'heartbeat' aligns with:
- The emit function's usage of 'heartbeat'
- The naming convention of other events in the codebase
- The event name in puppet.py
Let's verify there are no other occurrences of 'heart-beat' that need to be updated:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining instances of 'heart-beat' in the codebase
rg "heart-beat" -l
# Search for heartbeat event usage to ensure consistency
rg "heartbeat" -A 2 -B 2
Length of output: 2532
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/wechaty/user/room.py (1)
197-197: Fix spacing in method signature.The
force_syncparameter needs proper spacing around the comma and colon for PEP 8 compliance.- query: Optional[Union[str, RoomQueryFilter, Callable[[Contact], bool]]] = None,force_sync:bool=False) -> List[Room]: + query: Optional[Union[str, RoomQueryFilter, Callable[[Contact], bool]]] = None, force_sync: bool = False) -> List[Room]:
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/wechaty/user/room.py(3 hunks)
🔇 Additional comments (2)
src/wechaty/user/room.py (2)
231-231: LGTM! Proper parameter passing for forced synchronization.The
force_syncparameter is correctly passed to eachroom.ready()call, enabling forced synchronization when requested by the caller.
318-318: LGTM! Correct logic for force_sync behavior.The modified conditional logic properly implements the force_sync functionality:
- When
force_sync=Falseand room is ready: returns early (existing behavior)- When
force_sync=True: continues with synchronization regardless of current readiness stateThis ensures forced synchronization bypasses the cached readiness state as intended.
Rename 'heart-beat' to 'heartbeat' to align with emit in puppet.py:1017.
Important
Fixes heartbeat event listener in
wechaty.pyby renaming event from'heart-beat'to'heartbeat'.wechaty.pyby renaming event from'heart-beat'to'heartbeat'to match the emitted event name.wechaty.pyfor consistency.This description was created by
for a118af1. It will automatically update as commits are pushed.
Summary by CodeRabbit