Skip to content

Commit 7cba0c8

Browse files
committed
fix:修改workflows文件配置。python版本3.8->3.9
fix:优化wechaty.room.py中 upload_cache 逻辑。更规范
1 parent 675c667 commit 7cba0c8

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

.github/workflows/pypi.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- uses: actions/checkout@v2
1111
- uses: actions/setup-python@v1
1212
with:
13-
python-version: 3.8
13+
python-version: 3.9
1414
- name: Install dependencies
1515
run: |
1616
python -m pip install --upgrade pip
@@ -36,7 +36,7 @@ jobs:
3636
- uses: actions/checkout@v2
3737
- uses: actions/setup-python@v1
3838
with:
39-
python-version: 3.8
39+
python-version: 3.9
4040
- name: Install dependencies
4141
run: |
4242
python -m pip install --upgrade pip
@@ -57,7 +57,7 @@ jobs:
5757
- name: Set up Python
5858
uses: actions/setup-python@v1
5959
with:
60-
python-version: 3.8
60+
python-version: 3.9
6161
- name: Install dependencies
6262
run: |
6363
python -m pip install --upgrade pip
@@ -75,7 +75,7 @@ jobs:
7575
- uses: actions/setup-node@v3
7676
with:
7777
node-version: 16
78-
- name: Building Wechaty-ui
78+
- name: Building Wechaty-ui
7979
id: build-ui
8080
run: |
8181
make ui

src/wechaty/user/room.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,18 @@ def load(cls, room_id: str) -> Room:
293293
return room
294294

295295
@classmethod
296-
def upload_cache(cls, room_id: str)->None:
296+
def upload_cache(cls, room_id: str) -> Room:
297297
"""
298298
dynamic upload
299-
clear the room_id of _pool and upload it use load
299+
clear the room_id from _pool and re-upload it using load
300+
Args:
301+
room_id: The Roo ID to refresh
302+
Return:
303+
Room:The refreshed room instance
300304
"""
301-
cls._pool[room_id] = None
302-
cls.load(room_id)
305+
if room_id in cls._pool:
306+
del cls._pool[room_id]
307+
return cls.load(room_id)
303308

304309
def __str__(self) -> str:
305310
"""

src/wechaty/wechaty.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999

100100
from wechaty.utils import timestamp_to_date, qr_terminal
101101

102-
103102
log: logging.Logger = get_logger('Wechaty')
104103

105104
DEFAULT_TIMEOUT = 300
@@ -472,7 +471,7 @@ async def start(self) -> None:
472471
loop = asyncio.get_event_loop()
473472
loop.stop()
474473

475-
except Exception as e: # pylint: disable=broad-except
474+
except Exception as e: # pylint: disable=broad-except
476475
print(e)
477476

478477
async def restart(self) -> None:
@@ -713,7 +712,8 @@ async def room_leave_listener(payload: EventRoomLeavePayload) -> None:
713712
async def room_topic_listener(payload: EventRoomTopicPayload) -> None:
714713
log.info('receive <room-topic> event <%s>', payload)
715714

716-
room: Room = self.Room.upload_cache(payload.room_id)
715+
self.Room.upload_cache(payload.room_id)
716+
room: Room = self.Room.load(payload.room_id)
717717
await room.ready()
718718

719719
changer = self.Contact.load(payload.changer_id)

0 commit comments

Comments
 (0)