Ajout du listing des conversations disponibles

This commit is contained in:
hadware
2018-05-28 19:00:02 +02:00
parent 18c3d02044
commit 0a73a2dc73
+8 -3
View File
@@ -1,5 +1,5 @@
import random
from typing import List, Dict, Tuple, Union
from typing import List, Dict, Tuple, Union, Set
from .requests import LoginRequest, PostLoginRequest, PulseRequest, SendMsgRequest
from ..commons import BotMessage, Message, AbstractResponse
@@ -40,7 +40,7 @@ class Interlocutor:
class CocoClient:
def __init__(self):
self.interlocutors = [] # type: List[Interlocutor]
self.interlocutors = set() # type: Set[Interlocutor]
self.current_interlocutor = None # type: Interlocutor
self.histories = {} # type:Dict[Interlocutor,List[Tuple]]
@@ -59,6 +59,7 @@ class CocoClient:
out = []
for user_code, msg in received_msgs:
user = Interlocutor.from_string(user_code)
self.interlocutors.add(user)
self.histories[user].append((user.nick, msg))
if user == self.current_interlocutor:
@@ -109,4 +110,8 @@ class CocoClient:
else:
self.current_interlocutor = new_interlocutor
return [new_interlocutor.to_botmessage()] + \
self._format_history(self.current_interlocutor)
self._format_history(self.current_interlocutor)
def list_convs(self):
return BotMessage("Conversations : " + ", ".join(["%s(%i)" % (usr.nick, usr.age)
for usr in self.interlocutors]))