获取当前聊天列表中的所有聊天对象 Args: reset (bool): 是否重置SessionItemList newmessage (bool): 是否只获取有新消息的聊天对象 Returns: SessionList (dict): 聊天对象列表,键为聊天对象名,值为新消息条数
(self, reset=False, newmessage=False)
| 251 | return newmessages |
| 252 | |
| 253 | def GetSessionList(self, reset=False, newmessage=False): |
| 254 | """获取当前聊天列表中的所有聊天对象 |
| 255 | |
| 256 | Args: |
| 257 | reset (bool): 是否重置SessionItemList |
| 258 | newmessage (bool): 是否只获取有新消息的聊天对象 |
| 259 | |
| 260 | Returns: |
| 261 | SessionList (dict): 聊天对象列表,键为聊天对象名,值为新消息条数 |
| 262 | """ |
| 263 | self.SessionItem = self.SessionBox.ListItemControl() |
| 264 | if reset: |
| 265 | self.SessionItemList = [] |
| 266 | SessionList = {} |
| 267 | for i in range(100): |
| 268 | if self.SessionItem.BoundingRectangle.width() != 0: |
| 269 | try: |
| 270 | name, amount = self.GetSessionAmont(self.SessionItem) |
| 271 | except: |
| 272 | break |
| 273 | if name not in self.SessionItemList: |
| 274 | self.SessionItemList.append(name) |
| 275 | if name not in SessionList: |
| 276 | SessionList[name] = amount |
| 277 | self.SessionItem = self.SessionItem.GetNextSiblingControl() |
| 278 | if not self.SessionItem: |
| 279 | break |
| 280 | |
| 281 | if newmessage: |
| 282 | return {i:SessionList[i] for i in SessionList if SessionList[i] > 0} |
| 283 | return SessionList |
| 284 | |
| 285 | def GetSession(self): |
| 286 | """获取当前聊天列表中的所有聊天对象 |
no test coverage detected