-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
account.py
40 lines (30 loc) · 1.09 KB
/
account.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING
from satori.client.account import Account
from avilla.core.account import AccountStatus, BaseAccount
from avilla.core.selector import Selector
if TYPE_CHECKING:
from .protocol import SatoriProtocol
@dataclass
class SatoriAccount(BaseAccount):
protocol: SatoriProtocol
status: AccountStatus
client: Account
def __init__(self, route: Selector, protocol: SatoriProtocol):
super().__init__(route, protocol.avilla)
self.protocol = protocol
self.status = AccountStatus()
@property
def identity(self):
return f"{self.route['land']}/{self.route['account']}"
# @contextmanager
# def _status_update(self):
# prev = self.available
# yield
# if prev != (curr := self.available):
# avilla = self.protocol.avilla
# avilla.broadcast.postEvent((AccountAvailable if curr else AccountUnavailable)(avilla, self))
@property
def available(self) -> bool:
return self.client.connected.is_set()