mirror of
https://github.com/avitoras/telegram-tui.git
synced 2025-07-27 19:26:10 +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
|
from src.app import TelegramTUI
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Главный файл приложения"""
|
||||||
|
|
||||||
from telethon import TelegramClient, events
|
from telethon import TelegramClient, events
|
||||||
from textual.app import App
|
from textual.app import App
|
||||||
from tokens import api_id, api_hash
|
from tokens import api_id, api_hash
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
|
"""Файл с кастомными экранами приложения"""
|
||||||
|
|
||||||
from textual.screen import Screen
|
from textual.screen import Screen
|
||||||
from textual.widgets import Label, Input, Footer, Static
|
from textual.widgets import Label, Input, Footer, Static
|
||||||
from textual.containers import Vertical, Horizontal, VerticalScroll
|
from textual.containers import Vertical, Horizontal, VerticalScroll
|
||||||
from telethon.errors import SessionPasswordNeededError
|
from telethon.errors import SessionPasswordNeededError
|
||||||
from telethon import TelegramClient, events, utils
|
from telethon import TelegramClient, events
|
||||||
from src.widgets import Dialog, Chat
|
from src.widgets import Dialog, Chat
|
||||||
|
|
||||||
class AuthScreen(Screen):
|
class AuthScreen(Screen):
|
||||||
"""Класс логина в аккаунт"""
|
"""Класс экрана логина в аккаунт"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -14,7 +16,7 @@ class AuthScreen(Screen):
|
|||||||
id = None,
|
id = None,
|
||||||
classes = None,
|
classes = None,
|
||||||
telegram_client: TelegramClient | None = None
|
telegram_client: TelegramClient | None = None
|
||||||
):
|
):
|
||||||
super().__init__(name, id, classes)
|
super().__init__(name, id, classes)
|
||||||
self.client = telegram_client
|
self.client = telegram_client
|
||||||
|
|
||||||
@ -55,7 +57,6 @@ class AuthScreen(Screen):
|
|||||||
await self.client.start()
|
await self.client.start()
|
||||||
self.app.pop_screen()
|
self.app.pop_screen()
|
||||||
self.app.push_screen("chats")
|
self.app.push_screen("chats")
|
||||||
self.app.notify("")
|
|
||||||
|
|
||||||
class ChatScreen(Screen):
|
class ChatScreen(Screen):
|
||||||
"""Класс экрана чатов, он же основной экран приложения"""
|
"""Класс экрана чатов, он же основной экран приложения"""
|
||||||
@ -117,14 +118,16 @@ class ChatScreen(Screen):
|
|||||||
|
|
||||||
async def update_chat_list(self, event = None):
|
async def update_chat_list(self, event = None):
|
||||||
print("Запрос обновления чатов")
|
print("Запрос обновления чатов")
|
||||||
|
|
||||||
if not self.is_chat_update_blocked:
|
if not self.is_chat_update_blocked:
|
||||||
self.is_chat_update_blocked = True
|
self.is_chat_update_blocked = True
|
||||||
|
|
||||||
dialogs = await self.telegram_client.get_dialogs(
|
dialogs = await self.telegram_client.get_dialogs(
|
||||||
limit=self.limit, archived=False
|
limit=self.limit, archived=False
|
||||||
)
|
)
|
||||||
print("Получены диалоги")
|
print("Получены диалоги")
|
||||||
|
|
||||||
limit = len(dialogs)
|
limit = len(dialogs)
|
||||||
#limit = 30
|
|
||||||
self.mount_chats(limit)
|
self.mount_chats(limit)
|
||||||
|
|
||||||
for i in range(limit):
|
for i in range(limit):
|
||||||
@ -132,7 +135,6 @@ class ChatScreen(Screen):
|
|||||||
chat.username = str(dialogs[i].name)
|
chat.username = str(dialogs[i].name)
|
||||||
chat.msg = str(dialogs[i].message.message)
|
chat.msg = str(dialogs[i].message.message)
|
||||||
chat.peer_id = dialogs[i].id
|
chat.peer_id = dialogs[i].id
|
||||||
#self.notify("Новое сообщение") #колхоз дебаг
|
|
||||||
|
|
||||||
self.is_chat_update_blocked = False
|
self.is_chat_update_blocked = False
|
||||||
print("Чаты обновлены")
|
print("Чаты обновлены")
|
||||||
|
@ -38,10 +38,6 @@ Message Container {
|
|||||||
width: 65%;
|
width: 65%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#send {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#auth_container{
|
#auth_container{
|
||||||
align: center middle;
|
align: center middle;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Файл с кастомными виджетами приложения"""
|
||||||
|
|
||||||
from textual.containers import Horizontal, Vertical, Container, VerticalScroll
|
from textual.containers import Horizontal, Vertical, Container, VerticalScroll
|
||||||
from textual.widget import Widget
|
from textual.widget import Widget
|
||||||
from textual.reactive import Reactive
|
from textual.reactive import Reactive
|
||||||
@ -14,11 +16,10 @@ class Chat(Widget):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str | None = None,
|
name: str | None = None,
|
||||||
notify_func = None,
|
|
||||||
id: str | None = None,
|
id: str | None = None,
|
||||||
classes: str | None = None,
|
classes: str | None = None,
|
||||||
disabled: bool = False
|
disabled: bool = False
|
||||||
):
|
):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
name=str(name),
|
name=str(name),
|
||||||
id=id,
|
id=id,
|
||||||
@ -28,7 +29,7 @@ class Chat(Widget):
|
|||||||
global personid
|
global personid
|
||||||
personid = 0
|
personid = 0
|
||||||
self.notify = notify_fun
|
self.notify = notify_fun
|
||||||
|
|
||||||
def _on_click(self):
|
def _on_click(self):
|
||||||
global personid
|
global personid
|
||||||
self.msg = str(self.peer_id)
|
self.msg = str(self.peer_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user