controller shouldnt call tg directry

This commit is contained in:
Alexander Zveruk 2020-05-03 20:31:20 +03:00
parent 48d9cfdee5
commit 763cbc15da
2 changed files with 14 additions and 13 deletions

View file

@ -82,7 +82,7 @@ class Controller:
msg = self.view.get_input()
if msg:
chat_id = self.model.get_current_chat_id()
self.model.msgs.tg.send_message(
self.model.msgs.send_message(
chat_id=chat_id,
text=msg,
)

View file

@ -79,17 +79,6 @@ class Model:
chat_id, offset=offset, limit=limit
)
def send_msg(self, chat_id, msg):
result = self.users.tg.send_message(
chat_id=chat_id,
text=msg,
)
result.wait()
if result.error:
log.info(f'send message error: {result.error_info}')
else:
log.info(f'message has been sent: {result.update}')
class ChatModel:
@ -213,7 +202,19 @@ class MsgModel:
# if len(self.msgs[chat_id]) >= offset + limit:
# break
return sorted(self.msgs[chat_id], key=lambda d: d['id'])[::-1][offset:limit]
return sorted(self.msgs[chat_id], key=lambda d: d["id"])[::-1][
offset:limit
]
def send_message(self, chat_id, text):
log.info('Sending msg')
result = self.tg.send_message(chat_id=chat_id, text=text)
result.wait()
if result.error:
log.info(f'send message error: {result.error_info}')
else:
log.info(f'message has been sent: {result.update}')
class UserModel: