mirror of
https://github.com/avitoras/telegram-tui.git
synced 2025-07-27 11:20:31 +00:00
Merge branch 'fish_dev' into dev
This commit is contained in:
commit
32c57cd404
2
main.py
2
main.py
@ -1,3 +1,5 @@
|
||||
"""Файл инициализации приложения"""
|
||||
|
||||
from src.app import TelegramTUI
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,3 +1,5 @@
|
||||
"""Главный файл приложения"""
|
||||
|
||||
from telethon import TelegramClient, events
|
||||
from textual.app import App
|
||||
from tokens import api_id, api_hash
|
||||
|
@ -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("Чаты обновлены")
|
||||
|
@ -38,10 +38,6 @@ Message Container {
|
||||
width: 65%;
|
||||
}
|
||||
|
||||
#send {
|
||||
|
||||
}
|
||||
|
||||
#auth_container{
|
||||
align: center middle;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
"""Файл с кастомными виджетами приложения"""
|
||||
|
||||
from textual.containers import Horizontal, Vertical, Container, VerticalScroll
|
||||
from textual.widget import Widget
|
||||
from textual.reactive import Reactive
|
||||
@ -14,11 +16,10 @@ 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,
|
||||
@ -28,7 +29,7 @@ class Chat(Widget):
|
||||
global personid
|
||||
personid = 0
|
||||
self.notify = notify_fun
|
||||
|
||||
|
||||
def _on_click(self):
|
||||
global personid
|
||||
self.msg = str(self.peer_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user