Merge pull request #69 from paul-nameless/fix-esc

Decrese esc delay
This commit is contained in:
Alex 2020-06-06 20:55:58 +03:00 committed by GitHub
commit 447f70076a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 16 deletions

View file

@ -56,6 +56,7 @@ def main():
library_path=config.TDLIB_PATH,
)
tg.login()
utils.set_shorter_esc_delay()
wrapper(partial(run, tg))

View file

@ -283,14 +283,6 @@ class MsgModel:
msg_set.remove(msg_id)
return True
def update_msg_content(
self, chat_id: int, msg_id: int, message_content: Dict[str, Any]
) -> bool:
log.info(f"updating {msg_id=} {message_content=}")
return self.update_msg_fields(
chat_id, msg_id, fields=dict(content=message_content)
)
def update_msg_content_opened(self, chat_id: int, msg_id: int):
for message in self.msgs[chat_id]:
if message["id"] != msg_id:
@ -305,9 +297,7 @@ class MsgModel:
# https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1update_message_content_opened.html
return
def update_msg_fields(
self, chat_id: int, msg_id: int, fields: Dict[str, Any]
):
def update_msg(self, chat_id: int, msg_id: int, **fields: Dict[str, Any]):
msg = None
for message in self.msgs[chat_id]:
if message["id"] == msg_id:

View file

@ -41,8 +41,8 @@ def update_handler(update_type):
def update_message_content(controller: Controller, update: Dict[str, Any]):
chat_id = update["chat_id"]
message_id = update["message_id"]
controller.model.msgs.update_msg_content(
chat_id, message_id, update["new_content"]
controller.model.msgs.update_msg(
chat_id, message_id, content=update["new_content"]
)
current_chat_id = controller.model.current_chat_id
@ -55,9 +55,7 @@ def update_message_edited(controller: Controller, update: Dict[str, Any]):
chat_id = update["chat_id"]
message_id = update["message_id"]
edit_date = update["edit_date"]
controller.model.msgs.update_msg_fields(
chat_id, message_id, fields=dict(edit_date=edit_date)
)
controller.model.msgs.update_msg(chat_id, message_id, edit_date=edit_date)
current_chat_id = controller.model.current_chat_id
if current_chat_id == chat_id:

View file

@ -205,3 +205,7 @@ class suspend:
self.view.stdscr.keypad(True)
curses.curs_set(0)
curses.doupdate()
def set_shorter_esc_delay(delay=25):
os.environ.setdefault("ESCDELAY", str(delay))