чутка отполировал

This commit is contained in:
kirill 2025-01-27 23:51:42 +03:00
parent 81b0975b31
commit ae98e62a7f
6 changed files with 18 additions and 16 deletions

View File

@ -1,3 +1,5 @@
"""Файл инициализации приложения"""
from src.app import TelegramTUI
if __name__ == "__main__":

View File

@ -1,3 +1,5 @@
"""Главный файл приложения"""
from telethon import TelegramClient, events
from textual.app import App
from tokens import api_id, api_hash

View File

@ -1,12 +1,14 @@
"""Файл с кастомными экранами приложения"""
from textual.screen import Screen
from textual.widgets import Label, Input, Footer, Static
from textual.containers import Vertical, Horizontal, VerticalScroll
from telethon.errors import SessionPasswordNeededError
from telethon import TelegramClient, events, utils
from telethon import TelegramClient, events
from src.widgets import Dialog, Chat
class AuthScreen(Screen):
"""Класс логина в аккаунт"""
"""Класс экрана логина в аккаунт"""
def __init__(
self,
@ -14,7 +16,7 @@ class AuthScreen(Screen):
id = None,
classes = None,
telegram_client: TelegramClient | None = None
):
):
super().__init__(name, id, classes)
self.client = telegram_client
@ -55,7 +57,6 @@ class AuthScreen(Screen):
await self.client.start()
self.app.pop_screen()
self.app.push_screen("chats")
self.app.notify("")
class ChatScreen(Screen):
"""Класс экрана чатов, он же основной экран приложения"""
@ -117,14 +118,16 @@ class ChatScreen(Screen):
async def update_chat_list(self, event = None):
print("Запрос обновления чатов")
if not self.is_chat_update_blocked:
self.is_chat_update_blocked = True
dialogs = await self.telegram_client.get_dialogs(
limit=self.limit, archived=False
)
print("Получены диалоги")
limit = len(dialogs)
#limit = 30
self.mount_chats(limit)
for i in range(limit):
@ -132,7 +135,6 @@ class ChatScreen(Screen):
chat.username = str(dialogs[i].name)
chat.msg = str(dialogs[i].message.message)
chat.peer_id = dialogs[i].id
#self.notify("Новое сообщение") #колхоз дебаг
self.is_chat_update_blocked = False
print("Чаты обновлены")

View File

@ -38,10 +38,6 @@ Message Container {
width: 65%;
}
#send {
}
#auth_container{
align: center middle;
}

View File

@ -1,3 +1,5 @@
"""Файл с кастомными виджетами приложения"""
from textual.containers import Horizontal, Vertical, Container, VerticalScroll
from textual.widget import Widget
from textual.reactive import Reactive
@ -13,22 +15,20 @@ class Chat(Widget):
def __init__(
self,
name: str | None = None,
notify_func = None,
id: str | None = None,
classes: str | None = None,
disabled: bool = False
):
):
super().__init__(
name=str(name),
id=id,
classes=classes,
disabled=disabled
)
self.notify = notify_func
def _on_click(self):
self.msg = str(self.peer_id)
self.notify("нажат чат")
self.app.notify("нажат чат")
def compose(self):
with Horizontal():